instruction stringlengths 71 71.9k |
|---|
I have got a JTable implementing a TableModel interface. There are ID (primary key, auto-increment), tbl_Date, Flat, Mobile, Food, Alcohol, Transport, Outdoor, Pauls_stuff, Income, Stuff columns.
Every time I start the program, I want to get rows filled with data: tbl_Date until tommorow, everything else except ID, set... |
I was working on teaching myself some Scala and decided to tackle some Project Euler problems. The first four of these turned out to be one liners.
/* Find the sum of all the multiples of 3 or 5 below 1000 */
object Problem1 extends App {
println((1 to 999).filter((i: Int) => i % 3 == 0 || i % 5 == 0).sum)
}
/* B... |
I've written a FTPHelper class which should help to teach me more about code structure.
I don't know what I don't know so I would really value feedback on how I can be laying out and thinking about my programming better!
public class FtpHelper : BaseHelper
{
public FtpHelper(string ftpHostname, string ftpUsername, ... |
I have a function that has, as input, a ranges object which may define from, to and limit. Note that it might have one, two or all three of them.
I want the output to be a saneRanges object, where if partial values are provided, the other ones are inferred.
For example if only limit is provided, from should be 0 and to... |
I'm using a list comprehension to find an object that matches in two lists and return the object for its property. I know the object ALWAYS exists in both lists and no other item in the lists are shared but I don't know which one it is so I can't just reference it from the list.
The code I can give you is:
class Baseba... |
Photography is one of my hobbies, and, living in Canada, I have the possibility of seeing, and photographing, the Aurora Borealis (Northern Lights).
Now, these happen when there's ionization in the ionosphere typically resulting from strong solar winds which create a 'tear', resulting in the plasma visible as the 'Nort... |
Given the following definition:
data Cons a = Cons a (Cons a)
| Empty
deriving Show
I implemented the following attempt at its Applicative instance:
instance Applicative Cons where
pure x = Cons x Empty
Empty <*> _ = Empty
(Cons g gs) <*> x = app... |
I'm developing an implementation of the FizzBuzz game as part of an edutainment game for a retro video game platform. In its manual, I want to mention the history of writing a bot for the FizzBuzz game as a programmer screening test since Jeff Atwood's blog post, including sample answers in a few popular programming la... |
Here is my code I'm working with:
$('#slider_1').click( function change_slider(){
$('#slider_1').addClass('current_tab').siblings('.current_tab').removeClass('current_tab')
$('#cart_slider_1').show().siblings().hide();
$('#cart_slider_1').addClass('current').siblings('.current').removeClass('current');
numItems... |
I'm looking for comments on coding style, passing arguments, ...etc.
#include <iostream>
using namespace std;
void printImage(int** img, int N){
//check if image pointer is NULL
if(img == NULL){
return;
}
//check if any of the columns of the image are null (since its essentially an array of ... |
I have zip bundle, for example, abcd.zip, contains more zips like 1.zip, 2.zip etc. Inside of each child zip there is a .jpg file like 1.jpg, 2.jpg etc. There are so many other files but I need only .jpeg.
I need to extract the .jpeg's and and create a zip it again with same parent name like 1.zip.
This works fine, but... |
I'm working on implementing a custom TCP proxy server which acts like a load balancer. The proxy server will accept client requests and then forward them to available hosts.
I am concerned about the way that I am creating new client sockets between proxy server and host per request in the receiveHostResponse method and... |
I've just finished the Reverse Polish Notation task in Julia from rosettacode.com by porting the existing Python code.
There are only a few lines I don't get how to port:
maxcolwidths = [max(len(y) for y in x) for x in zip(*rp)]
and the subsequent lines that use maxcolwidths.
I managed to pretty print the test output ... |
I have some dispute with a colleague. I work with some REST-service, from which I get always same type data.
class File():
def __init__(self, name, created, modified, media_type, path, md5, type, mime_type, size,
public_key=None, public_url=None, preview=None):
self.public_url = public_url
... |
So I'm learning bits and pieces of python. Here's some code that just doesn't seem pythonic, and I'd like to improve it. I'm doing stochastic simulations with a Gillespie style approach, but if that doesn't mean anything to you, no worries. I'm trying to avoid some iterations and replace them with something like a l... |
This question over on SO about how to call a function "later" using Rx led me to post the following ill-advised piece of code to solve the problem:
void Main() {
getScheduleTimes()
.Where(t => t >= DateTimeOffset.Now)
.SelectMany(t => Observable.Timer(t).ToEnumerable())
.ToObservable()
.Subscribe(_ =... |
I'm learning C++ right now and one of the activity/tutorial things was to re-write the "High/Low Guess My Number" game - with a twist. I had to re-write it so that the computer had to guess the number.
Here's the exercise prompt:
Write a new version of the Guess My Number program in which the player and computer switc... |
Can this function be cleaner? It looks to me that I have too much nesting (Using + If + While).
Public Shared Function GetLocationsAutocomplete(ByRef userData As IUser, ByVal prefix As String) As List(Of AutocompleteItem)
Dim conn As DbConnection = DbProvider.GetDbConnection(ConnectionStringHelper.GetConnectionStri... |
I've built a multiplexer which takes 2 inputs: one array of std_logic_vector and one std_logic_vector to select the correct array. It should be written more generic, but I'm not sure how. The length of SEL grows if the length of X grows (4-bit if 16 inputs, 6-bit if 64, etc.). I'm currently using custom types as input,... |
The following code is intended to infer the alignment of double.
My questions include:
Is there a better to do this? Either by refining the code or using an entirely different approach.
Under what (reasonable) circumstances could this not work?
Under what (plausible) circumstances could this not work? See below.
Wh... |
This works fine and returns an object from a nested "structure" by Id.
I would like to know if you could suggest a better approach, possible a faster one.
<script>
var data = {
item: [
{
itemNested: [
{
itemNested2: [{
id: "2"
... |
I used some Java code to work out how often MPs and Senators cited their sources in tweets. The results are at here and the GitHub for the whole project is here, and the Java code I use to download the MPs statements from Twitter is below. I'm looking for any feedback on style, possible errors, and anything else you c... |
I've written a basic server/client application to use in an automation application written in C#. The code is working pretty good, but I have a few thing I want to improve:
Server:
public void socketListener()
{
peerListener = new TcpListener(IPAddress.Any, ControlLayer.control_GlobalParam.TCP_PORT);
peerL... |
I'm learning C# and I decided to write a chess program to help me practice the concepts I'm learning in my book. I started the Board class tonight, which is going to handle 1) the board state and 2) checking if moves are legal.
I feel like I need to give careful consideration to how I represent the board. I started wit... |
I have a query that returns records that have duplicate names within a given DBSTATUS. I used to do this with a direct connection to the remote oracle database server with this query. (Names changed to protect the innocent, but otherwise, this is my code.)
SELECT SUBSTR(NAME, 1, 3) AS CATID,
TABLE1.NAME,
TABL... |
I am modularizing some of my code in order to make it reusable in future projects. The latest thing that I have created is a simple class that saves user profiles. The list of profiles is loaded into a view, and the user can add a new profile to the list and select which profile is currently active. When a profile i... |
I have written some code that scrapes data on asteroids, but the problem is that is super slow! I understand that it has a lot to scrape, but as of now it has been running for 5 days and is bot even a tenth of the way through. Here is my code, the part I'm talking about is under GET-EPHEMERIDES:
from mechanize import B... |
I was trying just as a practice to implement substring on my own.
the Test is inside the Ctor just because it is easy.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
public class Substring
{
public Subs... |
I'm new to Susy and I'm loving it. I've been learning and trying a simple example - a simple grid that contains two columns at a fixed resolution of 320 pixels. One test would be to have two side by side columns (#x and #y) with gutter space in-between and another would be another two side by side columns (#a and #b) b... |
I am trying to make a script that generates every possible combination from an array of elements. I have found a script that does it, but it is too intensive and takes extremely long to generate anything that has more than 7 elements inside the array.
I am trying to achieve, where from an array of:
array("Quick", "Brow... |
Given the following Rust program:
fn main() {
let mut reader = io::stdin();
for line in reader.lock().lines() {
match line {
Ok(l) => print!("{}", l),
Err(_) => continue,
}
}
}
yes | program achieves 1.04MiB/s throughput, according to pv. The trivial C program below,... |
This is a naive implementation - I know that there are algorithms like KMP
However I was trying to implement it as best as I can.
string test = "giladdarmonwhatareyoudoing";
int index = StrStr(test, "are");
//Returns an index to the first occurrence of str2 in str1,
//or a -1 pointer if str2 is not part of str1.
pub... |
These are 2 implementations for the http://en.wikipedia.org/wiki/3SUM problem,
The first one is mine.
and in the second one I implemented Wiki's pseudo code.
Can someone please tell me if there is a difference between the two in complexity of runtime and memory space?
using System;
using System.Collections.Generic;
us... |
I am writing a control panel with Sliders but I think my code is messy and cumbersome, what can I do to improve it?
public class Input_Window extends JFrame {
JSlider myslideA,myslideB,myslideC,myslideD;
Input_Window(){
System.out.println("* Control Window");
setBackground(Color.GRAY);
... |
I carefully used smart pointer to avoid memory leaks and dangling pointers, but someone says my code has memory leaks. Is it true? If so, how can I fix it?
#include <iostream>
#include <initializer_list>
#include <memory>
using namespace std;
using Ptr2D = unique_ptr<unique_ptr<int[]>[]>;
using IniList = initializer_l... |
The objective was to see what numbers can be multiplied to equal 100.
Example:
1 x 1 = 1 //no match
5 x 20 = 100 //match
The objective (as I'm learning) was only to use an array as I wanted to practice how it functioned. There are probably other classes I could have used which would have been better, for example, an A... |
I wanted to dust off my C skills, so I decided to write a couple string manipulation functions.
I aimed for simplicity and safety. Performance was not a concern.
Please be a thorough as you like. C is not my everyday language, so I might have made
some obvious mistakes. I would also appreciate extra attention to the te... |
I made a post a couple of days ago asking if anyone noticed bad habits or thought of any suggestions: (First Hangman game)
I've made 2 math programs just to make sure I got it all down pat. The first one (the subject of this question) is a simple addition, multiplication, division, and subtraction program that would de... |
I've developed a class used for some epidemic simulations I'm doing. Individuals are 'S' (susceptible), 'I' (infected), or 'R' (recovered). These are standard abbreviations in the research community. I assume some calculations are done in advance to determine who will be infected (and recover) when. There will be m... |
I've been working on the Rubberduck (an add-in for the VBA Editor /"VBE"), specifically here the VBA.Parser namespace. Here's how I ended up implementing the syntax part.
[ComVisible(false)]
public interface ISyntax
{
/// <summary>
/// Parses an instruction into a syntax node, if possible.
/// </summary>
... |
The aim of the program is to find those points which comes under the intersection of at least 2 circles.(space is a 1000x1000 matrix)
n=input()
mat=[[0 for i in range(1005)] for i in range(1005)]
circles=[]
for i in range(n):
circles.append(map(int,raw_input().split()))
ans=0
for circle in circles:
minx=circ... |
I am writing possibly my first real C project, and it is almost finished. But as I was coming to a close I noticed something.
This is a simple operation to split a cookie string into a ~2D array. I don't expect you to read all of the code if you don't want to. It works, but that is not my current worry.
#include <stdi... |
I want to use Microsoft.AspNet.Identity's PasswordHasher but I don't want to pollute my Domain layer with knowledge of it. As such I created an interface in my Domain layer
public interface IPasswordService
{
string HashPassword(string password);
bool VerifyPassword(string hashedPassword, string testPassword);... |
This is supposed to be an immutable structure representing a time-stamped value. Since it represents a physical measurement, it cannot change, and I want to make sure it really doesn't change accidentally at runtime.
public struct Sample
{
public TimeSpan Time { get { return _time; } }
private readonly TimeSpan... |
A question was raised in chat (hi @malachi) about how you can count the number of badges of a given metal (bronze, silver, gold). This can be hard to do because the medal details are not stored in the SEDE tables. Together with Malachi, we came up with this Users and Badges query:
-- Find and classify all badge awards ... |
I have this program for counting calories. There isn't a whole lot to it yet. It's a moderately sized project, so I'll do my best to make it as short as possible, posting only the main of the program and my global variables. It's a Windows Forms project.
Before anyone tells me, yes, I should fix the global variables. I... |
I'm a Clojure novice working through 4Clojure problems. In one problem I am supposed to create a function that takes a number and returns that number of Fibonaccis. My first thought was to create a function that creates a lazy sequence of Fibonaccis and then just takes however many it needs. Here is what I came up with... |
I programmed Problem #22 from Project Euler in Python. It works but I want to know if it really is pythonic enough.
Using names.txt (right click and 'Save Link/Target As...'), a 46K text
file containing over five-thousand first names, begin by sorting it
into alphabetical order. Then working out the alphabetical v... |
I have been thinking about a way to implement this and I am not sure that what I have done is correct, because it surely sounds kinda dirty to me.
Basically what I have is a WCF duplex service which multiple clients subscribe to. My problem is the authentication. What I have done is I pass the username and password to ... |
I want to create a Treeview in C# which will group file by prefix (here the prefix is a marked by the separator _). The following files should give this tree:
Files list:
p_a
p_a_test
p_LIG
p_p
p_p_c
p_p_c2
p_p_ccc
p_p_test
p_tres
TestLineGraph1
TestLineGrpah
Corresponding tree:
|--p_
|--p_a
|--p_a_test
... |
This is a follow up to:
Messenger supporting notifications and requests
Shoot the Messenger pt. 2
I've written a lightweight (I think) class that acts as a messenger service between classes for both notifications (fire and forget updates to other classes) and requests (a notification sent out that expects a returned... |
I've written a script with the Google Maps JavaScript API v3.
I've ran it through JSHint and everything seems to be valid.
I'm wondering if my script has room for improvement.
Any suggestions are very much welcome!
(function () {
'use strict';
var map,
markers = [];
function initMap() {
va... |
I am trying to learn flex and have created this simple program. The rule for comments works correctly for single line comments such as:
// this is a comment
and this:
/* this is also a comment */
My code:
ID [A-Z][A-Za-z0-9]
KEYWORD if|else|then|for|fi|loop|pool|proc|func
OPERATOR "+"|"-"|"/"|"*"|"&"|"%"
PUNCTUATION ... |
I am new to programming but I tried to make my code as readable as possible! Hopefully you can see what it does before you run the program. I did not implement an ups or fps controller, the animation may be fast for some computers and slower for others.
import javax.swing.*;
import java.awt.*;
import java.util.Random;
... |
I'm making a section that shows a list of blogs and how many comments it has without loading any comment data. My Blog entity is as follows:
/**
* @ORM\Entity
* @ORM\Table(name="blogs")
*/
class Blog
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
... |
Play my game!
Having the name that I do (Simon), of course I have to participate in this challenge! (Even though I am a bit "late", but Simon says "have forgiveness!")
This is an implementation of the Simon Says challenge using libGDX. I started using this framework a couple of months ago, and I love the fact that it c... |
This function draws a Christmas tree (with an angel on top) with text (AKA, ASCII art).
#define ARRSZ(x) (sizeof(x)/sizeof(x[0]))
void drawChristmasTree (int height) {
const char * const angel[] = { " ._.", "(\\o/)", ")/|\\(", "/_*_\\", };
const char stars[] = "***************************************";
int... |
The task was to calculate all cyclic subgroups of a group \$ \textbf{Z} / n \textbf{Z} \$ under multiplication of modulo \$ \text{n} \$ and returning them as a list of lists. The first level has all subgroups and the secend level holds the elements of these groups.
The programm first calculates the numbers \$ \text{g} ... |
For a simple try at parallelization on my own outside of school, I've created a number factors calculator. I hope to eventually come up with something more creative.
Since I don't have access to parallel computers at this time, I'm using OpenMP provided by my compiler (gcc 4.8.1) and running it on my laptop (Intel Cor... |
I'm trying to extract room types and sizes from a descriptive text utilizing the following scripts as an exercise. Any tips on being more pythonic would be amazing!
The script is based off the help I received in this question.
The idea is that I find anything in the following sense: 16m2, 3.90 x 3,00m, 640x390 and that... |
Our company is planning on doing a fitness competition.
So as the hackathon project I threw together this team based tracking service.
It measure a walk from Seattle to New York
Player can log in via fitbit (moves/jawbone/fuel/etc.. to come later) once logged in you can select a team.
When you log in it automatically l... |
I've taken my previous block building game and added some performance improvements, and commented some things that needed to be commented for better explanation.
/** Here are few instructions before you start...
* IMPORTANT (ON KHANACADEMY ONLY): When you make changes to the code, all tiles will be black.
* Just hi... |
I'm about to start work on a large project using MVVM design pattern. I've worked on smaller projects in the past using MVVM, but I want to make sure my approach to MVVM is good/manageable as possible before I attempt something much larger.
The following view model is from a project that I have worked on in the past. I... |
My full code is running too slow. I do profile.run to my project and found out this function consumes a lot of time.
The main problem is just to return an array containing all \$x\$ satisfying both of these equations with some large primes like \$23857201\$.
$$(x^3+v) \mod P = 0$$
$$(3xx + 3hx + h^2) \mod P = 0$$
... |
Over the past couple of weeks I have been working on a general purpose logging library for C in my free time. At the moment I have stabilized the API and most of the features I wanted to implement have been implemented. I am looking for general suggestions (note I haven't done much API documentation yet) on code qualit... |
I was wondering if someone could tell me things I could improve in this code. This is one of my first Python projects. This program gets the script of a movie (in this case Interstellar) and then finds the occurrences of all words and prints out the 20 most common words in the script.
from bs4 import BeautifulSoup
impo... |
I have solved this assignment in online coding community, and it has run successfully. But it's showing 12.09s of execution.
How could this be optimized ?
The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input... |
This code controls whether the user has checked at least one checkbox field before saving the record. If the user has failed to do so the code throws an error message and cancels the operation.
Is there a better/more efficient way to write it?
function BusComp_PreWriteRecord ()
{
try
{
var sSMS = ... |
I've been coding C for almost 20 years and figured I should learn C++. As a starting point I wrote the following trivial code to generate the powerset of a set. I'm hoping that some experienced C++ coder could help me with three things:
Identify non-idiomatic constructions.
Explain where I'm doing unnecessary copying ... |
Finding a famous question with high score I haven't voted on yet was proving to be a bit difficult for me. So I came up with this simple SEDE query to find good candidates:
SELECT TOP 10
Id AS [Post Link], ViewCount
FROM Posts
WHERE ViewCount >= 10000 AND Score >= 25
ORDER BY ViewCount DESC
Can this be improved in ... |
So here is my next creation, a circular checkbox. This is my third custom control, so I'm still learning, but have the basics just about down. Tips and suggestions are most appreciated:
class CircularCheckbox : Control
{
private Color borderColor;
public Color BorderColor
{
get { return borderColor;... |
I have written an Optional type in groovy roughly based on java8s Optional. I implemented and use a fold method and would like to know if it can be improved. First, here comes the Optional (I will only use its fold method for my question though):
class Optional<T> {
T value
private Opional(T value) {
t... |
I have a base class and 3 sub-classes:
Item <-- Book, MusicCD, Software
They have some common and different properties but in the view I want to get a mixed list of them and show in one table, with these columns headers:
Title Price Volume Author Artist Edition Version
Classes:
abstract class Item {
protect... |
Here's a function for making multiple copies of a block of memory in another block of memory. It handles the case when the size of the target is smaller than or not a perfect multiple of the source pattern.
It proceeds by copying the pattern once, twice, four times, eight times, etc. until it can make a last 'massive' ... |
I want a code run just once (say in Dispose). WriteOnceBlock<T> from TPL Data Flow could be used here; but again if we need to check if it is done (in a 'not data flow' friendly manner), we have to call Receive and timeout and things.
I wrote this and it works, but I am not sure about when comparison takes place (==); ... |
This is my first attempt to provide some syntactic sugar for doing mutually independent loop iterations in parallel. Thanks to Java 8 lambdas, I can write the parallel loops in pretty elegant fashion compared to pre-lambda Java's.
Also, I have declared the actual forp as synchronized, which leads to the question will ... |
I am mostly interested in how the parse_string function could be improved. But any comments on my test strategy also welcome.
The input is a string which can be either all digits in which case the result should be the digits string OR there can be string formatting outside angle brackets which must be removed. the di... |
I have 2 objects and I am comparing them to see which fields are equal and which are different.
But I am not sure my loop is 100% correct. Does this look ok? If so, what other ways could this be coded to make it 'neater'. e.g. using LINQ
I want to: loop through each DocumentType in both objects, and for each document... |
I'm making a little script to run on the background and notify me when I received a new email in a mailinator inbox. I want to eventually daemonise it, but for now it just runs like a regular script.
Could you give me some pointers about the code itself, the code structure and so on? I'm not sure if I should have my fu... |
The end result I am trying to achieve is an array containing the total ordered qty for each product. I have been successful but the query takes about 20 minutes to run and I'm wondering if there is anyone who may know of some way of improving this? The details and current query are as follows:
All columns involved in ... |
I am new to programming but I tried to make my code as readable as possible! Hopefully you can see what it does before you run the program. I did not implement a ups or fps controller, the animation may be fast for some computers and slower for others. I also tried to use the information provided to me from my first co... |
The previous and initial iteration at Parallel for loop in Java 8.
Changes are as follows:
ParallelLoopBody removed; java.util.Function used instead.
The actual parallel loop synchronizes on a class monitor.
forp does not ask for the output list in arguments; instead, it creates a new list of output data on each call.... |
I have a pixel shader that needs to output either a plain colored pixel or a texel sampled from one of three textures - selected by a switch statement operating on an index fed in by the vertex shader:
// textures
tbuffer textures
{
SamplerState sState;
Texture2DArray ... |
My program (a daemon hosting a Minecraft server) exposes a D-Bus interface to allow interaction with the server from other processes. To that end, and to avoid a chain of repetitive conditionals in the invocation handler, I'm using a map of Glib::ustring keys (the method invoked) to std::bind-created function objects (... |
All those numerous merge sorts split the range in two halves. This is a modification that splits each range into 3 subranges. My demo suggests that 3-way merge sort is pretty efficient on large arrays.
So, what do you think?
Arrays.java:
package net.coderodde.util;
/**
* @author Rodion Efremov
* @version 2014.12.17
... |
My code is really ugly, but I don't know how to make it better.
#include "stdafx.h"
#include <iostream>
#include <math.h>
using namespace std;
bool palindromeTest(double numberVectorAddition){//tests if the factors of the palindrome are both below 3 digits each.
double p = numberVectorAddition;
double i = 999... |
I am currently working on my own implementation of the Buddhabrot. So far I am using the std::thread-class from C++11 to concurrently work through the following iteration:
void iterate(float *res){
//generate starting point
std::default_random_engine generator;
std::uniform_real_distribution<double> distrib... |
I was tasked with member creation on a site that was already developed for Active Directory, so the log in functionality was there and most of the site was all ready to go (after minor major tweaks).
Here is what I came up with for my create user method (Button_Click Event).
Please let me know what you think.
protected... |
* Time complexity: O(N)
* Memory complexity: \$O(1)\$
Is my calculation of complexity correct for this code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using Vector = vector<vector<int>>;
int main()
{
const size_t SIZE = 7;
Vector image(SIZE, vector<int>(SIZE));
cou... |
Here's a little script that enters text into a document when activated.
tell application "TextEdit"
activate
end tell
delay 0.2
tell application "System Events"
keystroke "Hello World!"
keystroke return
end tell
I stuck the delay in there because otherwise the first few keystrokes tend to trigger before the wind... |
I've implemented a code inspection that verifies whether a procedure has parameters that are implicitly passed by reference - in VBA a parameter is passed ByRef unless it's explicitly specified ByVal.
Here is the implementation in question:
[ComVisible(false)]
public class ImplicitByRefParameterInspection : IInspection... |
I thought I would learn a design pattern today and picked this one. I wrote a simple Android test demo to test the pattern.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_w... |
I started learning PHP and MySQL, was using MySQL_ functions. Then I learned they are deprecated, had to choose between PDO and MySQL. I chose MySQL and started using it.
As I learn OOP PHP, I thought I should change my code to OOP style, since it's cleaner. I was wondering whether this block of my code is secure or n... |
I have been using your expertise developing my application using parts of WPF that I have never touched before.
In this stage my View does all I need it to do, however, I am not sure if I've done my side of the job right. My guess is that it still going to need numerous changes to be called as code following "Best Pra... |
I have a URL which I am executing it and it is returning the below string as a JSON response. I am using GSON to parse JSON.
In the below JSON, "resourceId" contains an IP address.
{
"status":{
"code":"200",
"msg":"ok",
},
"hasmore":true,
"count":1000,
"result":[
{
"_type":"Cal... |
I'm reluctant to ask this question. My code below works, it's intelligible, and it seems reasonably efficient. It's just that there's a trivial, nitpicky issue that's driving me crazy. The function maxes below collects all elements of a sequence that are "maximum" according to some criterion.
;; Example of use of ma... |
I wrote a stable sort algorithm in C#. It is just a simple iteration, and is probably not very optimal:
static void StableSort(ref ObservableCollection<string> Vals, ref ObservableCollection<int> Weight)
{
for (int i = 0; i < Vals.Count; i++)
{
int LargestVal = -1;
int LargestValIndex = 0;
for (int j ... |
I'm learning Rust. I wrote the following library to format text and output it to terminal, so that the formatting markup is embedded with the string itself (looks similar to HTML4).
I feel the code is pretty unidiomatic and I'd really appreciate hints on how to make it better, more readable and easier to extend.
The pa... |
I'm a newbie in Delphi and I'm trying to create a client/server application using INDY. I want to have a server that is capable not only of receiving messages and streaming, but also sending data to clients at any given time. The clients must have same capabilities.
I built a prototype app using TIdTCPServer and TId... |
I've read somewhere on Stack Overflow that doing queries in a loop is very inefficient. It will hammer your SQL server and make your script very slow.
Sample code:
// Connect to SQL Server 1
$query = "SELECT * FROM
articles
";
$resource = mysql_query($query);
$articles = array();
while $record = mysql_fetch_assoc($res... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.