instruction stringlengths 71 71.9k |
|---|
I am interacting with a C library, whose documentation states that certain functions are not thread safe. Since its functions deal heterogeneously with multiple types, I have written a template wrapper to use it in a homogeneous manner from C++. However, I now need to ensure serialized access to certain functions, seri... |
I'm making a WindowsPhone 8 app in C#. With this an API so I can convert JSON data into useful objects. I've found a method but am wondering if it is any good at all.
The problem is it's been a while since I've really worked with C# and never for windows phone.
Because it's making use of web requests it has to be asyn... |
I am fairly new to C and am just overcoming my fear of pointers and segmentation faults. C is a strange language to me because I come from more object oriented languages like JavaScript and Java.
When I code in C, everything feels all "one-liney" to me. I'm used to things, for example in Java, being neatly spread out, ... |
In main:
for(int i = 1; i < upto; i *= 2)
{ for(int j = 0; j < (upto - i); j += (2*i))
{ int end2 = (2*i < (upto - j)) ? 2*i : upto - j;
mymerge(&(array[j]), i, end2); } }
Merge:
void mymerge(people *arr, int end1, int end2){
int i = 0;
int j = end1;
int k = 0;
people * temp = new peop... |
Today I needed to implement a class for representing rectangular regions with some binary operations such as merging or intersection.
public class Region
{
// Properties, such as top-left and bottom-right corner ...
// Ctors ...
public Region Merge(Region other)
{
// ...
}
public Regio... |
I'm trying to learn JavaScript, and as a practice tool I recently wrote a simple web app that uses the Google Maps API Geocoder to get the latitude and longitude of a location (user input), manipulate them, then query those against a Google Fusion Table listing the world's climate zone codes according to the Köppen-Gei... |
It echoes files or strings to output, never both at once. It does work (in both Linux and Windows), but I can NOT guarantee that it is bug free. It works much like echo, but it works with files as well, and has fewer formal arguments.
I'm looking for helpful and useful critiques, mainly in programming style, organizati... |
I need help making this code more efficient but still functions the same, such as by making it access the Twitter API fewer times. When I run this code for like 1 min, I get an error from Twitter saying that it exceeds limits.
List<Status> tweets = result.getTweets();
for (Status tweet : tweets) {
... |
I am trying find the total number of permutations possible with a given x, y, and z.
x is the initial number, y is the final number, and z is the total number of buttons pressed.
I am supposed to only move from number to number like the knight in chess, in an 'L' shape.
For example, if you just dialed a 1, the next nu... |
In Memoriam
Ralph H. Baer, co-inventor of the original "Simon" game, died Saturday December 6th 2014, at 92. With his passing, this friendly little challenge inadvertently became a memorial to the father of video game consoles. Rest in peace Mr. Baer, you have changed our lives forever.
I finally got my Simon Says i... |
I am looking for generic ideas and guidelines of how to improve the style of my coding and make it more readable and robust.
public class TemplatePart : ITemplatePart
{
#region Fields
private readonly List<ITemplatePart> _options = new List<ITemplatePart>();
private readonly List<ITemplatePart> _cables = n... |
Doing homework, implementation of the algorithm flood fills. I'm writing a program to this guide: http://en.wikipedia.org/wiki/Flood_fill. And I have some questions:
Is it normal to specify the parameters in function replaces the color of any character bucketFill.fill (0, 0, '*', 'O');, I do not know what kind of colo... |
My daughter had a question on her maths homework which was to write a value as a sum of 4 or fewer square numbers.
For example, x = 73 could be 36 + 36 + 1.
I came up with a really brute force algorithm that shows all combinations but when the values get above 1000 it becomes quite slow.
Is there a clever way of ac... |
I have to create an XML body for a web service call. I want to use:
private void createProductBody(Product product, StringBuilder body) {
body.append(WSConstants.WS_PRODUCT_ID_START_TAG)
.append(product.getId())
.append(WSConstants.WS_PRODUCT_ID_END_TAG)
.append(WSConstants.WS_SI... |
I am working on a banking application. I want to create a multithreaded TCP Payment Card (iso8583) server that can handle passbook printing requests simultaneously. Multiple devices are connected to the server from different locations.
I am going to use below code in my application. Is this thread safe? Can I face any ... |
I have written a simple image cache script, the purpose is to load the image locally, so i can control the cache times of the images, and i have better load times than the host server, (battle.net serves 350 ms, i serve 65ish ms) this times 20 images is a pretty good performance step.
But being the performance freak i ... |
I'm trying to improve my SQL syntax, take the following for the example
SELECT * FROM `Users:Timesheets`
WHERE
`start` >= '{$monday}'
AND `finish` <= '{$sunday}'
AND `username` = '{$username}'
AND `shift_type` = 'ONCALL'
OR
`start` >= '{$monday}'
AND `finish` IS NULL
AND `username` = '{$username}'
AND `shift... |
Given an ASCII string create a 'compressed' version of it. For example, aabccccddddddde would output a2bc4d7e whereas abc would output abc.
This is how I've implemented it. Is there a smarter way to do it without the need for two for loops?
import java.util.LinkedHashMap;
import java.util.Set;
public class CompressS... |
I've found myself on numerous occasions needing to with large text-files, where joining this on that, and filtering this out on arbitrary conditions.
The first couple of times, this turned into a loop in a loop in a loop mess which was indented more times than I care to either remember or admit.
More recently, I've att... |
I would like to get a feedback about the code below. Is there any way to improve its performance? Maybe you know input values that might print bad output? The idea of the code is to count unique characters from s2 that are not listed in s1.
Ideone.com URL
class Combine {
public static void main(String[] args) thro... |
I have a "litte" problem with my stored procedure because I need some values selected at a point in time.
I need to do many select and group by's in my Left outer join which looks and feels like I am doing something really wrong. It would be very nice if some one could take a look at it.
In this Select there are at lea... |
I've been working on a scheduling application and I have the middle tier completed at this point. It's not changed in a few days, so I feel it's ready for review. I have just this one routine that feels dirty. It's definitely verging on arrow code, but without short-circuiting, I'm not sure how it can be improved any f... |
I have this code that I was asked to maintain, it is a notification system for a third party application event system (a lot more involved than that but for the sake of this question...)
The Code uses a class DataTable Variable with 4 columns, it takes one of the columns and takes the distinct values and outputs them t... |
I am writing a script in JavaScript & HTML and have some optimization problems. In the for, loop I check a variable named visible in every if clause. I think it's meaningless because once I know that the variable value is false there is no need to check the remaining if clauses but skip to the last line. I thought abou... |
I've rewritten my original parser generator to a header-only library which uses templates and functionals for better type safety and clarity. The generated parser creates an abstract syntax tree which can be evaluated effectively using functionals and a visitor pattern. The parser memorizes intermediate steps resulting... |
I have this MSD (most-significant digit) radix sort sorting Entry objects holding a sorting key of type long and a satellite datum. It handles the issue of sign bits so that it produces a permutation that honours the sign bit: the Entry with the sign bit on will precede all the Entry objects with sign bit off.
It is hi... |
I recently created this for a coursework assignment. I am always looking to learn and would like some feedback on my code. Is there any OO principles I'm going against or anything irritating I'm doing?
Search Class:
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util... |
I wrote some JS to power an HTML/CSS "set theory" clock, and I'd like to share what I have so far and ask if anyone can suggest improvements.
Specifically, I'm wondering:
Should I bother checking to see if a variable is greater than zero before running the for loop?
Is there a better way to handle togging the classes?... |
This is a continuation of this question, at least the first part of that question.
I want to check if everything in the new code is right or if there are other way to make it better.
Exercise
The validBraces method takes a string of braces as a single parameter and determines if the order of the braces is valid. All i... |
So I have this code:
#include <iostream>
#include <string>
#include <list>
using std::cin;
using std::cout;
using std::string;
using std::endl;
using std::list;
using std::getline;
class Saw {
private:
string name;
int power, speed;
public:
Saw(string &name, int &power, int &speed) :
name(name), p... |
I wrote this code over night for a little project that my friend and I have been working on. This class template was created over a year ago during as a class assignment for C++ programming. I recently reviewed this program and I saw that I created multiple instances of my classes in order to print out different data... |
Consider the following:
#include <iostream>
struct State { virtual ~State() = default; };
struct Drunk : State {
void singWhileDrunk() {std::cout << "Singing while drunk.\n";}
};
struct Person {
State* state;
void singWhileDrunk() {dynamic_cast<Drunk*>(state)->singWhileDrunk();} // Is this good?
};
in... |
Just for review and may be useful for somebody
from os import walk
from time import time
from abc import ABCMeta, abstractmethod
class Reporter(object):
__metaclass__=ABCMeta
@abstractmethod
def report(self, catalogs_cntr, files_ctnr, speed):
""" output catalogs_cntr, files_ctnr, speed to somewhe... |
I am new to encryption and recently wanted to learn more about it. I researched how to do AES Encryption in java and assembled my own Java AES encryption class. I don't know if there are any major security holes, though.
Can someone experienced in Java encryption look at my code and tell me if there are any serious sec... |
import re
def replace_token_regex(s, token=" "):
return re.sub(token, '20%', s.strip())
def replace_token_inplace(s, token=" "):
for index, char in enumerate(s):
if ord(char) == ord(token):
s[index] = '20%'
return s
print replace_spaces_regex("Foo Bar ")
s = list("Foo Bar ")
replace... |
my task is to generate random strings and store in a file till the size of file is less than 10MB. My approach towards this problem is as follows.
import java.io.File;
import java.io.FileWriter;
public class Application {
public static void main(String[] args) throws Exception {
long start = System.current... |
I have an angular app using a restful API which works, but I know is structured poorly.
I'm using a projectService (factory) to do all interfacing with the REST back-end, for both of the backend Project and Task models. The ProjectController and TaskController both get the projectService (factory), and TaskController... |
This is a simulation of animal skins, like a cellular automat. I'd like it improved.
#Create Matrix with random numbers 0/1 with a 50% chance
createMatrix <- function(br,gen) {
mat <- matrix(rbinom(br*gen,1,0.5),br,gen)
return(mat)
}
nextMatrix <- function(mat,w) {
#Make that Matrix continuous
wideMatr... |
I want to sort a string which contains words and integers with the restriction that if the nth element in the list is an integer it must remain an integer and if it is a word, it must remain a word.
Currently, what I am doing is splitting the input string on spaces, putting the words and integers into their own lists, ... |
I'm new to the Swift language. I have a C# version of a simple A* route which is very fast. But I rewrote it with Swift, and the performance is very bad (3,4 seconds for a very simple road).
Could someone give me some suggestions? What I thought is that, the loop and compares logic spends most of the time.
Here is the ... |
I have a table with 3 columns in the format below:
WebcastChannelId, WebcastEventId, SortSequence
1 , 2 , 1
1 , 5 , 2
1 , 3 , 3
2 , 7 , 2
2 , 8 , 1
I would like to get the values for the webcastChannelId and WebcastEventId with the minimum sort sequence.
In the above example this would be:
WebcastChannelId, WebcastE... |
In this exercise we were asked to test a number for primality and print the results. Additionally – in the case the number is composite – the smallest divisor different from 1 should be printed out. Negative input values shall not pre processed and result in a message.
The second part of that task to improve the perfor... |
I am a bit of noob to jQuery so I got this jQuery code what I think can be way faster.
Does someone want to help me clean it up? Explaining why you did what would be real nice but not needed.
The working site is online here.
onResize = function() {
$('#spinner').delay(1000).fadeOut(500);
// blog
setTimeout(function() ... |
I'm implementing a solution in Java using Ebean and I'm having some issues choosing between using enums or simply look up tables.
I have a table "Tooth". A tooth can be "Temporary" or "Permanent".
I could create a simple enum:
@EnumMapping(nameValuePairs = "TEMPORARY=T, PERMANENT=P")
public enum DentitionType { TEMPORA... |
I got bored on my long weekend so I decided to have my coding exercise. And I successfully made a program that let you input the day and the month then it gives you the day of given date. But sadly it's only for 2014 calendar.
import java.io.*;
public class DaysToYears{
public static void main(String[] args) throws Ar... |
The task is to sum up scores mentioned in a text file. Scores are floating point numbers as defined by the regexp float immediately preceded by a * character to distinguish them from other numbers in the text. Scientific notation is not permitted.
Example input
Day 1:
Task 1: *5 Task 2: *2,8
Task 3 was the ha... |
I need to create a \${n} \times {n}\$ multidimensional array filled with default values.
Right now, I'm using this code:
//--- how many columns?
var colNumber = 10;
//--- how many rows?
var rowNumber = 20;
//--- default value
var defaultValue = "default";
var defRow = [];
var defaultArray = [];
for(var x = 0; x < co... |
The archived material for the Stanford University course on cryptography at coursera.org includes a problem where you have to predict the next output of a weak PRG. It can be briefly restated as follows:
$$\begin{align*}
P =&\ 295075153 \\
z_n =&\ x_n \oplus y_n,\qquad \textrm{where... |
One of the badges available on Stack Exchange is the Archaeologist badge. This is awarded for making 100 edits on posts that had been inactive (at the time of the edit) for 6 months.
There is no indication on your profile, or elsewhere, how close you are to this badge. Here's an SEDE query that can give you a good idea... |
I'm fairly new to VBA and just completed my first script. It's completing the task I want it to do just fine, but it's really slow in doing so. It has to open and read about 1000 CSV files for each CSV filter for specific rows and copy those into tabs in a newly created document. It then has to save and close that new ... |
I currently have a working implementation of a + and - tank level thingy (I don't really know what to call it). In which will be able to 'add' or 'remove' so-called 'liquid' from the container.
However, I feel my implementation of this is very inefficient, and would appreciate your input on this matter.
$(document)... |
I need to cut down the run time of this query. Currently it's taking 45 minutes. Is there something I can change in the table or the query to allow this to run faster?
SELECT SUM(B.PRICE),C.ST_FILE
FROM
TAD1D.ST_EUCM AS B,
TAD1D.ST_DSA_TRAN AS C,
TAD1A.TIBHLD T
WHERE C.ST_TRAN_FILE=B.ST_TRAN_FILE
AND C... |
In Java, there is no way I know of to wait for multiple events at the same time (see Stack Overflow). Since I would like to use that feature (similar to WaitForMultipleObjects() in the Win32 API), I decided to write my own event class that includes this feature. While the class is pretty straight-forward, thread synchr... |
I wrote the following custom validation annotation for my project to confirm that at least one checkbox of a group of checkboxes is checked:
public class ValidateAtLeastOneChecked : ValidationAttribute {
public string[] CheckBoxFields {get; set;}
public ValidateAtLeastOneChecked(string[] checkBoxFields) {
... |
I have an rspec spec test that has two sets of the same tests (from 24 Pull Requests). I thought I'd refactor the spec whilst I fixed something else.
Normally I just do a basic each ... do array to DRY things up:
require 'spec_helper'
describe ReminderMailer, type: :mailer do
# Half the code yay! :D
['daily','wee... |
I'm fairly new to PHP and am very interested in learning best practices, etc. I have just created a user registration system mostly in OOP that will dump user info into a database I've created. This is nothing revolutionary, but can you all tell me if my code is sound and clean? I want to be sure I'm on track for us... |
I'm using bluebird promises. I'm converting fs.exists to existsAsync (here's how) and fs.readFile (here's how) to promises.
existsAsync(o.inputFilePathJSON).then(function(exists) {
debug("%s exists %s", o.inputFilePathJSON, exists);
if (exists) return fs.readFile(o.inputFilePathJSON).then(JSON.parse);
return exis... |
public class AddPostCommand
{
public string Title { get; set; }
public string Body { get; set; }
public bool Published { get; set; }
}
public class AddPostCommandHandler
{
public string Handle(AddPostCommand command)
{
var param = new
{
Slug = command.Title.Replace(" ", ... |
While going through SICP and trying to implement the code in clojure, I've found that while I can get the code in chapter 3 to work, it seems to go against Clojure idioms, but I can't quite imagine the "Clojure way" to do it either.
Take for example, the digital circuit simulator. This is my implementation:
(declare ca... |
I have been going through some CodingBat exercises and I came across this problem. "Given a string, return the length of the largest "block" in the string. A block is a run of adjacent chars that are the same."
Required output:
maxBlock("hoopla") → 2
maxBlock("abbCCCddBBBxx") → 3
maxBlock("") → 0
My code seems to pa... |
In one of the web apps I contribute to, the main.js file has multiple interacting "objects". Unfortunately, I'm so bad at OOP in JavaScript, despite studying other questions, that I just have a bunch of functions divided by a comment block as follows for the editor "object":
//*****************
// Setup the editor
//**... |
So I've got a regular expression parsing tcp responses from a music daemon. In case responses pile up I've come up with an expression to separate full responses from the data, however I'd like to also reference which choice was matched. Using capturing groups results in different numbers for each group, so is there a w... |
I made a map based on a binary tree ordered by hashcodes, with collisions fixed with equals(). Are there any improvements I could make?
public class HashTreeMap<K, V> implements Map<K, V> {
Optional<Node<K, V>> root = Optional.empty();
@Override
public V put(final K key, final V value) {
// Return... |
This is my first ever program created after reading a book on Python. Do you have any suggestions for me? Anything that are considered bad habits that I should correct for my new project?
#HangMan - 2014
import random
import time
#TODO: add word support
#TODO: add already guessed letters
secret = ""
dash = ""
HANGMAN... |
Follow up from General Game Loop
I have two interfaces. Entity for ticks. Drawable for rendering.
Drawable.java
import java.awt.Graphics;
public interface Drawable
{
public void draw (Graphics g);
}
Entity.java
public interface Entity
{
public void tick ();
public void second ();
}
I have a class to init... |
So I have a method that looks like this:
public static List<List<List<string>>> Split(List<List<string>> source, int chunksize)
{
return source
.Select((x, i) => new { Index = i, Value = x })
.GroupBy(x => x.Index / chunksize)
.Select(x => x.Select(v => v.Value).ToList())
... |
I'm new to Java, and this code could likely be squashed down a whole heap. How can I make this code simpler and easier to read?
chance.base is a percentage. If it is = 40, it has a 40% chance of returning true.
public class battleManager {
void battle(Army playerArmy,Army enemyArmy,int armyModifier,int army2Modifier){... |
I made a simple script to implement basic mathematics operations by using variadic functions. I would like to know if my implementation is correct.
The code only works for Visual C++ compiler Nov 2013 CTP (CTP_Nov2013).
#include <iostream>
#include <string>
#include <exception>
using namespace std;
template <typename ... |
I have encountered a performance issue in Swift. I compared the same method between C# and Swift: Swift is much slower than C#.
Here is the code I'm working with. Could some one help me to speed it up in Swift?
CSharp version (for reference only - it takes 73 ticks):
var nodes = new Node[328];
for (int i =... |
My Model
public class AccountListFilterModel
{
public int page { get; set; }
public int pagesize { get; set; }
public string sortOrder { get; set; }
public string packageTypeFilter { get; set; }
public string usernameFilter { get; set; }
public string accountStatusFilter { get; set; }
public... |
I have a task that checks for campaigns that are supposed to be finished by checking the end_at date. If finished, then set the status of the campaign to finished, and send the owner of the campaign an email.
The way I see it, is approach 1 and 2 may have the worker queued more than once in the worker pool.
Approach 3,... |
I have made a Tic Tac Toe game in C#. How can I improve my code? The full listing is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace TicTacToe1
{
class Program
{
private char winChar;
... |
I have a situation with a base class for whom a container of itself is a subclass. So a Block of Item has various ways in which it acts like an Item itself. I want to be able to initialize Block as Block {foo, baz, bar...} in a variadic syntax.
Here are the twists:
When a Block is constructed, the parameters in the ... |
I've made a function to safely traverse deep objects.
var foo = {
bar: {
baz: 1
}
};
function getDeepProp(obj, properties) {
if (typeof properties === 'string')
properties = properties.split('.');
if (typeof obj === 'undefined')
return;
if (!properties.length)
ret... |
The original question is on careercup.
Write a multi threaded C code with one thread printing all even numbers and the other all odd numbers. The output should always be in sequence
ie. 0,1,2,3,4....etc
Now I want to use C# for it.
class Program
{
static Object obj = new Object();
static Thread t1;
... |
Context
I'm working on a new Enterprise Library at my company and I am implementing some code that will be used to read files into memory. Since this is an enterprise library to be shared across the organization, the size of the file to be read in is unknown. I chose to manually read the contents of the files into mem... |
Aim: Write a function that looks up empirical parameters A, B and C for a solar radiation model. Each parameter has a value for a certain interval of time, represented as the day of the year. For now, I basically translate the four-column (day_of_year-interval, A, B, C) table that I have on paper into the following lo... |
I have written two classes, one to represent the tree and a Util class to get the deepest node from the tree. Can you please review the code?
Below is the class for Tree:
package org.vik.ds.tree;
public class BinaryTree<E>{
private E data;
private BinaryTree<E> leftNode;
private BinaryTree<E> rightNode;
public Binar... |
I wrote a 2-opt algorithm to be used in a program and noticed (using profile) that the 2-opt is eating up a lot of time. I have tried a few things to make it run faster, but I am out of ideas. Any tips on making it run faster, or a better way to write a 2-opt algo?
def twoOpt(self):
'''Peforms 2-opt search to impro... |
I have a list of Parcel objects and am trying to write a closure that picks the parcel object with highest count:
class Parcel {
int id,
int count,
String sender,
String recipient
Parcel(int _id, int _count) {
id = _id
count = _count
}
}
def parcels = [new parcel(1,5), new parcel(2,1), new parcel(3,3), new par... |
The code below is intended to provide SQL's GROUPING SETS functionality in Python with the aid of Pandas.
Background on SQL GROUPING SETS
There are at least two advantages to doing this in Python:
it is less verbose than SQL, and
it provides a non-redundant set of aggregations without the need to manually specify th... |
I have this tap event in an iOS app that I'm developing with PhoneGap. When I click on the left arrow, it finds the desired content and retrieves it from a JSON file. It then displays those results on the screen.
How can I improve this? There's a bit of lag... I know that some of the lag is attributed to the 300ms dela... |
I have a list of authors, where seeking duplicity. The indexes of these duplicates are stored in a list of lists named duplicity. For example, at index 0 in the list duplicity is nested list, which refer to indexes of authors list with duplicates author A, index 1 author duplicity B, etc.
I also have list edge, where i... |
As a beginning Ruby programmer I implemented a solution for Project Euler, Problem #11. (The problem is described in the comment below.) I'll be grateful for any suggestions for improvement (especially regarding code readability).
# Largest product in a grid
# Problem 11
#
# In the 20×20 grid below, four numbers along ... |
I am trying to create a class which implements the Comparator class.
The thing is that I have a list with some objects. This object is composed of 3 fields (Strings). My purpose is to sort the list based first on the first field: if the first field is the same on the two objects that I am comparing at the moment, then ... |
I posted this on Stack Overflow, but it was suggested that I move it over to Code Review.
I would like some feedback on the way I decided to clean up code from the in a .NET project that had Page_Load functions that had been added to over many years to the point that they were a complete mess.
While the code cleanup is... |
I'm developing a program for users from a VBulletin's forum. This forum has a lot of people interested in write good articles but some of them don't know how to use the formatting bar in his favor. Sometimes, the others members don't read this threads/articles because it doesn't have a interesting formatting (crazy wor... |
I have a working code (below) to convert a number to Excel-like (A...Z AA...AZ BA...BZ ...ZA-ZZ) column codes (headers).
For simplicity I limited it to 1 or 2 character codes.
Can the algorithm be streamlined by using a bit more of elementary math or using it differently?
Please note that I just happened to need it in ... |
I was fooling around with the Collatz sequence a bit and found out that long is only sufficient for starting values below 8528817511L. As I wanted to optimize my code from this answer for computations up to \$10^{10}\$, I needed either BigInteger or to run my own. As the range is limited and just few operations are nee... |
Work continues on the Rubberduck VBA Editor Add-in. I have a need to call some VBA code from the add-in with Application.Run. Unfortunately, the Application part of that refers to the particular Office Application that is hosting the VBA editor. So, if I'm working in Excel, Application refers to the instance of Excel (... |
I'm writing a program for magic square and I'm a relative beginner to C++ and programming. I was hoping someone could help me find alternate or better ways to implement my code. This is the main function. I also entered a function to check if the input is odd, max 19, and to quit.
Is there a way to not have back-to-bac... |
This is my final post for my CS1 saga. Mostly all I had to do was just "class-ify" my past project in this post. Here are the requirements:
Make all data members private and use constructors, accessors and
mutators. Enhancement: Build data verification into the member functions.
I'm mostly concerned with me doing... |
I have implemented a stack using simple array, dynamic array and linked list. I am requesting a review of this code.
Interface for stack:
/**
* Interface for stack
*/
public interface Stack<T> {
public void push(final T data);
public T pop();
public boolean isStackEmpty();
public boolean isStackFull();
public T peek... |
I'm trying to put together a little tutorial to demonstrate the benefits of using a sentry node when creating a linked list. Target audience is novices that already tried to make a linked list. Any kind of feedback, regarding best practices, readability etc appreciated.
// 2014 donated to Public Domain
#include <stdli... |
EDIT: Added refactored version 2.0 to the end!
I have a parser that is supposed to take a string similar to a math expression and return a Tuple of:
An array of strings where each string corresponds to one 'element' (number, operator, func name).
An array of custom enum indicating whether corresponding string in arra... |
I made a simple program for my study that calculates words in a text files and prints every word and its repeated times in the files.
How can I improve this code?
#include <future>
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <string>
#include <vector>
#include <algorithm>
#include <exceptio... |
I am using the following code which recursively executes function findWpisInZone(), code works fine, I just wondering if there is any better way to do it in JS,
DomBuilder.prototype = {
domTree: '',
findWpis: function () {
var dataState = dojo.global.xxx.state.data,
... |
I'm starting coding with Python (only able to use & create easy code!) and just created a word-counter. It reads a .txt file and enters the words in a dictionary with dict[word]="number of appearances in the text". As far as I can see, the code works well.
Nevertheless, I'm not satisfied with the fact that I needed to... |
I've been using Perl for the last two years and never really had any code to compare it to.
Sometimes I hear people say things like "your code is awful" or "you just write C code with bad performance". I'm willing to improve myself as a Perl programmer. What should I do in order to reach this goal?
This Perl script is ... |
I need to simplify this code as well as a Linq query:
var data = from linq_row in trend_data.AsEnumerable()
group linq_row by linq_row["questionnaire_uniquename"] into g
select new
{
questionnaire_uniquename = g.First<Data... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.