instruction
stringlengths
71
71.9k
I have the following markup, and I'm wondering how best to locate the nearest previous dpicker input element and give it focus with jQuery when a.dpicon is clicked. <div class="eight mobile-two columns"> <input autocomplete="off" class="dpicker" type="text" name="mdpdate" id="mdpdate"> </div> <div class="one mobile-o...
I am very new to JavaScript and was wondering what kind of process or design pattern is most common among JavaScript developers. So far I have following code index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>Interactive Guide</title> <!----------------------...
A large .csv file I was given has a large table of flight data. A function I wrote to help parse it iterates over the column of Flight IDs, and then returns a dictionary containing the index and value of every unique Flight ID in order of first appearance. Dictionary = { Index: FID, ... } This comes as a quick adjustm...
I'm trying to solve a graph traversal problem I found, and was wondering how I could improve my implementation. Currently it seems a little convoluted and long. The problem is as follows: I have a matrix of size (rows x cols). This matrix has some cells that are empty (designated by a 0) and some cells that are blocke...
As a Java programmer, I'm new to the OOP-Approach of JavaScript and it's hard for me to find the best way to write code based on objects. I read a lot MDN and across the web to find a good way to code with JavaScript. Just to see how can it look like, I realized the following functions: Add two INPUT-Elements to a vide...
I have a pipeline with loops of filters and one input filter. The rest are splitters, transform and output. I would like my code to go over the filters and push them into a queue (order is important). However, if I have a loop, I only want to count the end of the loop once. Here is my working code. Please review it....
I need to map from one enum type to another. Here is the enum I am given: enum CfgFruitType { CFGNoFruit, CFGApple, CFGApricot, CFGBanana, CFGMango, CFGKiwi, CFGFig, CFGGrape, CFGMelon, CFGLemon, CFGNectarine, CFGPineapple, CFGWatermelon, CFGCherry, CFGPear, CFGStrawberry }; and I need to map this to a secon...
How can I simplify this .less code to require less repetition (i.e., so that I can have many buttons with normal, rollover, and pressed states without using 3 lines for each button): .SBtnM(@urlprefix, @width, @height, @urlsuffix) { width: @width; height: @height; background-image: url(%("%s_%s....
Can I combine this two classes and have one fake db class? public class FakeDb : Dictionary<string, List<string>> { public const string Table1 = "Table1"; public void AddToTable(string tableName, string line) { if(!ContainsKey(tableName)) Add(tableName, new List<string>()); Lis...
I wrote a Python program that performs an integration of data using Simpson's rule. The program takes the areas to be integrated from a foo.ref file, with the following syntax: # peak m/z charge window LAG_H4N4F1S1 4244.829467 1+ 0.06 LAG_H4N4F1S1 4245.832508 1+ 0.06 LAG_H...
How many tests could you write for the enum class below. I am looking for the following output given the following command: java fileName HORIZON_BOX, HORIZON_BOX_WITH_CC, HORIZON_BOX_WITH_CC 1 HORIZON_BOX: 20.00 2 HORIZON_BOX_WITH_CC @ 30.00 : 60.00 GRAND TOTAL : 80.00 What is the best solution approach that you wou...
I have a model class Product that gets populated from a service DTO object (using AutoMapper). The service is used to power many different applications and for each one the Product Model might need to behave a bit differently. After a bit of research I decided the 'Decorator' pattern might be a good choice to accompa...
I'm writing a pong game in Python and I created classes for the game objects. The top level class is Object, and Ball and Paddle inherit from it. And ComputerPaddle is a child class of Paddle. # classes.py # 3/19/2013 import pygame import random # Paddle properties PADDLE_WIDTH = 25 PADDLE_HEIGHT = 100 PADDLE_COLOR...
I need a function to get the value of the name attribute of each element with class="class". I was wondering what is the best way to do this, performance-wise. Currently I'm using jQuery and doing it like this: $("#Button").click(function() { var myElements = $(".class"); for (var i=0;i<myElements.length;i++) {...
I have began doing the problems found on Project Euler and have just solved problem 3. However, I feel as if my code is very long and too brute-force. I was hoping somebody could give it a look and give me some guidelines for this problem and for future programming in general. This would help me with cleaning it up or...
Background The following code (part of a natural language processor) was written to eliminate duplicate code by using isLeft as a conditional throughout the method: private void doInsideChartBinaryRules( boolean isLeft, int state, int start, int end, int[] narrowLExtent_end, ...
Part 1 of 4 is complete. I would like to know if what I have done could be improved. Please don't worry about output - that is a work in progress. #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <time.h> #include <conio.h> struct Accounts { int...
I am just learning how to do some multiprocessing with Python, and I would like to create a non-blocking chat application that can add/retrieve messages to/from a database. This is my somewhat primitive attempt (note: It is simplified for the purposes of this post); however, I would like to know how close/far off off t...
I'm trying to write efficient code for calculating the chain-length of each number. For example, 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1. It took 13 iterations to get 13 down to 1, so collatz(13) = 10. Here is my implementation: def collatz(n, d={1:1}): if not n in d: d[n] = collatz(n * 3 + 1 if...
I've created a CSV parser that tries to build a string table out of a CSV file. The goal is to handle CSV files as well as Excel. Input CSV file: First field of first row,"This field is multiline but that's OK because it's enclosed in double qoutes, and this is an escaped "" double qoute" but this one "" is not "T...
Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. ListNode *removeNthFromEnd(ListNode *head, int n) { // Start typing your C/C++ solution bel...
In my VBA code, I am trying to generate a specific list of cell row positions. Basically, I first fill a collection with the entire list of row positions pertaining to a specific column: Dim arrPos As New Collection .... For i = 3 To bottomRow arrPos.Add i Next i Then I try to remove remove values from this collection...
I'm working on my first large CodeIgniter project (and one of my first MVC projects), and I want to get some feedback on the techniques I've used so far in one of my models: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Model_programs extends SOA_Model{ function __construct(){ ...
Some background This functions does some business logic before submitting a "add to cart" form HTML <form class="atcLoginRequired" method="get" action="/somePage"> <input type="hidden" value="someVal" name="nextpage"> <input name="ISODSCTX66WA_qty" type="text" value="1"> <input name="ISODSCTX77WA_qty" type=...
I'm new to jQuery and I've been messing about with this code, It works but I want to learn how to shorten the code by the eliminating unnecessary repeated code. Here is a link to JSFiddle HTML <div id="div1" style="display:none;">one<div id="divb" class="upper">close</div></div> <div id="div2" style="display:none;">two...
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not. The following is my code, which has already been tested on a onlinejudge. Can someone h...
First, I want to say that this code works, but I want to make sure this is the right way of doing it. I am writing this for a SMS text API that loops through each phone number. I sometimes gets hung up on 1 number or just takes time. It roughly takes 6-8 sec per number. So I thought I would write something that would m...
The code allows you to select an area from the left column and another area from the right column followed by clicking on the Choose button which sends the chosen areas to the server: <html> <head> <style> body { overflow: hidden; } article.left { overflow: hidden; float: left; ...
I discovered that the existing menu in a web app I'm working on has an issue in Chrome, where the "Logged in as" section would jump off the menu bar down below. After looking through the code, I'm trying to rewrite it a bit so that it works more consistently. <div style="z-index: 22000; height: 25px; position: fixed; l...
I had an assignment some weeks ago that consisted of making a simple McCulloch-Pitts neural network. I ended up coding it in a pretty OO style (or the OO style I've been taught), and I felt that my implementation might have been a bit excessive for being a one-off assignment: could this perhaps been implemented in a si...
I just failed in a JavaScript test and I would really appreciate some comments of how I can improve so I can keep learning. The test was about making a form interactive, where the code should do things like changing to the next tab while showing not visible content, validate email, etc. I have received the following fe...
I'm sure code indentation is a basic requirement for correct development. I have checked out may pages to learn more and results of my coding are below. I like to share that here to receive opinions and suggestions. <?php include_once "../../config.php"; // Start if (!isset($_SESSION)) session_start(); $level = 2; if...
I needed to get the minimum and maximum date values from a query using the Sequel ORM in Ruby from my database. Sequel has a range method that returns a Range value. I'm having it return values from a timestamp field, so they're coming back as a range of Time objects. In order to split it into two variables using paral...
Here's a simple Python Flask app. It uses the Wikidot API to transfer pages between two wikis. I'd like to hear your input on the best way to refactor this code. Here are a couple of questions I have in addition to any criticisms you may have: get_lines(): there are two places in here where exceptions can be thrown....
I am currently trying to teach myself some programming. I have started to work with Python by doing this challenge. For each test case, I need to find the sum of the self-similarities of a string with each of its suffixes. For example, given the string ababaa, the self-similarity scores are 6 (because ababaa = ababaa...
As a free-time activity in order to learn some Lisp I had to implement depth first directed graph search. Due to large graph size (800K nodes, 5M arcs) recursion-based approach I could devise didn't work. Below is my stack-based implementation that I would like to improve in terms of readability if nothing else. Any c...
Is this a good approach for a BayeuxClient class? Reading cometd reference book, Chapter 6 Java Libraries, I created this BayeuxClient class. As a newbie to cometd, I would like to know if this class has any flaws: import java.util.*; import java.net.URL; import org.cometd.client.BayeuxClient; import org.eclipse.jetty....
I've recently re-written a Python script I use to run a couple of lightweight blogs. Looking over the horrible code I'd written before, I decided to rewrite it using object-oriented concepts. I wanted to submit it to get feedback, best practices, and other areas I should look at. This is my first script that uses any o...
I'm a PHP novice and so looking for some advice on a PHP function I have created to use within a WordPress installation. As you can see from the code below, it runs when one of the admin's press 'Publish' on a pending post. It takes a Zip file that has been uploaded by a user via Gravity Forms, then unzips ONLY .mp3 ex...
I wrote a simple Python snake game which is about 250 lines of code. Can someone give me some advice on how I can refactor/make it better? game.py # game.py - 3/22/2013 import pygame, sys, os from pygame.locals import * from classes import * def main(): pygame.init() pygame.display.set_caption('PyGame Snake'...
I'm making a GUI system in Python for game development with PyGame. Right now I have a button that changes colors when you hover and click on it. My question is, is this code well designed or can it be improved? game.py import sys, pygame from pygame.locals import * from gui import * def input(events): for e in e...
function dep_tree(graph,node,prev_deps){ return uniq(flatten(graph[node].map(function(child_node){ if (contains(prev_deps,child_node)) throw "Circular reference between "+child_node+" and "+node; return dep_tree(graph,child_node,prev_deps ? prev_deps.concat(node) : [node]) })).conc...
I've written a circular buffer with multithreaded write and single read ability: public class RingBuffer<E> extends AbstractList<E> implements RandomAccess { class Pointer { int p = 0; public int getPointer(){ return this.p; } public void increasePointer(int p) { ...
I read about how markov-chains were handy at creating text-generators and wanted to give it a try in python. I'm not sure if this is the proper way to make a markov-chain. I've left comments in the code. Any feedback would be appreciated. import random def Markov(text_file): with open(text_file) as f: # pr...
This is a simple attempt by me to test whether two words are anagrams or not: #include <stdio.h> #include <ctype.h> #define CH_LEN 15 #define N 26 int main(void) { char track_letters[N] = {0}; char first_word[CH_LEN]; char sec_word[CH_LEN]; printf("Enter first word: "); int i; for(i = 0; i < C...
I am working on this website currently. If you resize the window to less than 650px then the main menu is replaced by a button which when pressed triggers a left fly-out menu similar to the Facebook uses on the mobile website. When viewed on a computer the menu works very well, but on mobile devices the performance is ...
I've started with developing BMP format reader in C#. This tool might read all data from binary BMP file and represents all data from it (from the header, the pixel data etc). I have started and have done only first 14 bytes reading (header) and getting the pixel data from 24 bit BMP file. Of course there would be a lo...
After creating a similar program in C++, I've decided to try to write it in x86 assembly language (the type of assembly I was taught in college). I'd like to receive feedback regarding syntax and clarity. The macros used here were provided by my college, so I don't think that's a concern. %include "macros.s" .DATA n...
Here's some code... please, be brutal function twisty (elem, container) { elem = $('.some-elem'); container = $('.container').hide(); var spots = elem.text().replace(' ', '').split(''); for(var i = 0; i < 300; i++) { $('<span/>', { 'class': 'spot '+ i, text: spots[Math.ceil(Math.rand...
I have created a jQuery slider for my personal website and I wanted to get some feedback on how it looks and if there are things I can do to make it better. You can see the live demo here: http://www.nickmeagher.com And here is the code: var sliderWidth = 0, marginLeft = 0, containerWidth = 1040...
I believe with everyone's help on Stack Overflow, I got my code safe guarded from SQL injection. I'm trying to confirm that is correct, just in case I misinterpreted the help and advice I received. <?php $username = "xxxx"; $password = "xxxx"; ?> <font size="+3" face="Verdana">xxxx</font> <br><br> <form name="form" a...
I need to remove the fractional part of a BigDecimal value when its scale has a value of zero. For example, BigDecimal value = new BigDecimal("12.00").setScale(2, RoundingMode.HALF_UP); It would assign 12.00. I want it to assign only 12 to value in such cases. BigDecimal value = new BigDecimal("12.000000").setScale(2...
Can you please try my algorithm and give comments or feedback about it? package md52; import java.io.*; //input outputs import static java.lang.Math.*; //for math purposes /** * * JesseePogi */ public class Md52 { public static String input; public static void main(String[] args) { //start tim...
This is my first program written in C++. I chose to make this public in order to receive suggestions on further improvements and to know if I'm using any "forbidden" code. I'm asking because I initially put a lot of gotos in the program, but later found out that using goto was "evil." Therefore, after a lot of trial ...
I am making a Python program with what I learned so far where the user enters two IPs that represents the start and end of the range of IPs to be scanned, then saves the wanted IP in a text file. #ip range and scanning import socket import sys ok=[] def ipscan(start2,port): s=socket.socket(socket.AF_INET, socket...
Is it possible to reduce this long nested for loops and if conditions to increase its readability and to optimize it for future reference. While writing code for my scheduling app, I ended up with a method as shown below. Really, I have a data structure like this. Here, I checks - Is there any stages (Inside LCycle) w...
I've been teaching myself a bit of web design and development over the past month or so, coming from an CG/VFX background with no prior experience so it's been a bit alien to me to say the least. I found the excellent Javascript is Sexy guide and have been going through it, but today was project time. I must admit I fe...
This page (full source & demo) displays a 2-channel horizontal d3.js Streamgraph that takes realtime mouse coordinates as data inputs for the graph. However, it tends to gradually use up an increasing amount of memory until there's none left, both on Chrome and Firefox (on Ubuntu 12.04 x64). Data is being collected bu...
How well does this code limit security problems when uploading images to the server? <?php $filename = $_FILE['inputfile']['name']; $upload_path = 'images/'; //extract extension $ext = strtolower(substr($filename, strrpos($filename, '.') + 1)); // return mime type ala mimetype extension $finfo = finfo_open(FILEINFO_M...
My postfix program essentially allows the user two input options to calculate a postfix equation: Confirmations after each input (after an input, the user is ask for another number, operator, or final result) No confirmation after each input (user is only asked for a number of inputs (values and operators), and the fi...
Im trying to get better at writing jQuery plugins. Was hoping to get some feedback on my notes, but also just about the general architechture and implenmentation of this pattern (dont even know this one is called :P) jsFiddle: http://jsfiddle.net/gajwp/4/ Click the input fields! (No need to comment on positioning or st...
According to instructions and sample code from MSDN Magazine and comments from post here determinant of n x n... I changed code to be like this: using System; internal class MatrixDecompositionProgram { private static void Main(string[] args) { float[,] m = MatrixCreate(4, 4); m[0, 0] = 3.0f; m...
I am trying to write an efficient loop for rendering a jQuery Mobile listview. Is this the most efficient loop? I append elements 100 at a time to try and allow the user to see progress without blocking the UI. This currently still needs work. I also use a blend of html strings and jQuery DOM objects. I'm not sure ...
I am new to Haskell and, coming from a OO/procedural programming background, I want to make sure my code follows the functional way of doing things. I built this short module to test if a given string is a palindrome (same backwards and forwards, case-sensitive) and I am simply wondering if this is the most "Haskell" w...
I am trying to design a class that will log errors to a text file, the application is using threads heavily so it may be that 2 errors that need to be written at the same time. I know there are 3rd party solutions available but for this particular case I would like to roll my own. What I have at the moment seems to wor...
I wrote a custom server control. The data in it can be manipulated on the client and the changes will be written into the hidden field. The data represents a property of the control and should be retrieved on a postback. I achieved this by using the value changed event to set the property and all its dependencies. Is ...
I wrote a python module that needs to load a file parser to work. Initially it was just one text parsing module but I need to add more parsers for different cases. parser_class1.py parser_class2.py parser_class3.py Only one is required for every running instance. I'm thinking load it by command line: mmain.py -p p...
I've been trying to create a tree module in JavaScript for implementing a "family tree" style structure. I'm not very experienced in newer JavaScript design styles and want to make sure I am going along the right path with the code I have written so far. Can someone let me know if I am on the right track with how this ...
I was given a homework assignment in Java to create classes that find Prime number and etc (you will see in code better). class Primes { public static boolean IsPrime(long num) { if (num%2==0){ return false; } for (int i=3; i*i<=num;i+=2) { if (num%i==0) { ...
I am working on a site that themes itself based on images / logos. I have made a utility class that gets the colors from an image, shown below. I am fairly new to OOP with PHP, and I'm looking for feedback on what I could improve with the following. It is still in beta, so image-handling is a little sketchy and could u...
This is my first program in C. I'd rather not form any bad habits now. Is there anything that looks like bad practice, or something just looks wrong? #include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { srand(time(NULL)); int r = rand() % 10 + 1; int correct = 0; int guess; i...
I was working through another question here and have hacked up an answer: def get_rows(): """ Get height of triangle from user""" while True: rows = input('Enter the number of rows: ') if 3 <= rows <= 33: return rows def triangle(rows, invert=True): """ Print the outline of a triangle...
I write abstract repository using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Linq.Expressions; namespace Framework.DataLayer { public class Context<T> : IContext<T> where T : class { private readonly DbContext _dbContext; ...
I have to run an external program from Python. The external program makes many temporary files (which conflict with other instance of same program). My strategy is: get current directory (native) path change to temp directory run external command copy output to native directory change back to native directory Here i...
How can I refactor this code to be more clean? $scope.unreserve = function () { var params = { 'wishlist_product_id' : product.wishlist_product_id }; WishlistService.unreserve(params, function (data) { if (data.success) { $rootScope.$broadcast('NotificationController.create', {type: '...
Could you have a quick look over my code to see if it's safe from SQL injection etc.. and suggest any amendments? <html> <head><title>Retrieve Your Login Code</title> </head> <body bgcolor=#ffffff> <?php echo "<h2>Search Results:</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") ...
I always wanted to ask this but couldn't for some reason. I had written this chunk of code about 3 months ago when one of my teacher explained what selection sort was using flow chart. I had a basic understanding of what arrays were. So I sat down and wrote this: #include <stdio.h> #define MAX_NUMBER 10 void selecti...
I have to set up a new JavaScript library for a big project, which isn't Object Oriented yet. So I built a small file to test some needs. The result is the following: var Module = { Config: (function() { //- private members var _systemName = 'mySystem', _version = '1.1.4'; ...
My first algorithm for finding the factors of a number was pretty slow and horrible (it started at \$O(n^2)\$, where n was not even the inputted number), but I eventually came up with this new code. I just want the first factors of a number (not the duplicates), so I used sqrt(n) instead of n for the loop. As for the...
I'm learning F#, and even though I'm able to do whatever I want, parts of my code looks really bad. I would love to get some suggestions on how to improve a couple of functions involving some conditional logic. let stripLast (punct : char) (word : string) = if word.Length > 0 && word.LastIndexOf(punct) = word.Lengt...
This is for regenerating some things in a game a made. The code is very big and I think it can be compressed but I don't know how to do it. Private Sub regen() 'regen coins z = coin1 z.Location = zloc z.Hide() zloc = New Point(RandomNumber(playspace.Width), RandomNumber(playspace.Height)) I...
While upgrading our code base to take advantage of new features in .Net 4.5, I'm trying to refactor our take of the classic Producer/Consumer algorithm, but I'm concerned my refactoring is going to increase the CPU usage. Each instance of my WorkItemConsumer class is basically a System.Threading.Thread that is able to ...
I would like to hear the opinion of more experienced AngularJS developers on whether the following directive is best practice... I was trying to make to make a directive that will include HTML that: Can include compiled elements (other directives, like ng-src in the example below) Interpolated values ({{ value }}) C...
I'm trying to get to grips with the DateTime class in PHP. Previously I've used date() and mktime() when playing with dates. Here's the head of a calendar table, and I'm pretty sure I'm doing this in a stupid way! That fact that I'm setting the format each time, and modifying the original date with each Interval, seems...
I'm currently working on a project where I have a punch of raw data and multiple components that use that data for various tasks. I would like to separate the raw data from the components as much as possible and keep the raw data as only data (So no logic or functionality) but the components should be able to read and ...
I created a class EmailParser and check if a supplied string is an email or not with the help of the standard librarie's email module. If the supplied string is not an email I raise an exception. Is this a pythonic way to deal with inappropiate input values an assertation error? How do you generally check input valu...
I am implementing a program that takes commands from a user and based on those commands, drives a Robot on a grid. To implement this program I have used the Command pattern. I have used this pattern because, most importantly, I want to be able to add to the list of possible commands in the future. The program takes a s...
My quick searching did not reveal anyone sharing their solution to this exercise, so am not sure if there are other (and better) approaches to mine: package main import ( "code.google.com/p/go-tour/wc" "strings" ) func WordCount(s string) map[string]int { foo := strings.Fields(s) m := make(map[string]...
I am writing an email parser and cannot decide how much logic should be included in the __init__ function. I know that a constructor should make the object ready for use, but are there best practices? I've added several statements to my constructor: def __init__(self, message): assert isinstance(message, basestring...
I have a meta-search engine system, i implemented mainly using static classes. The query pre processing module consists of the following static methods function queryPreprocessing() { } queryPreProcessing.removeStopWords = function (query){ // code here} queryPreProcessing.stemmer = function (w) { //code here } queryP...
Requirements: Given a long section of text, where the only indication that a paragraph has ended is a shorter line, make a guess about the first paragraph. The lines are hardwrapped, and the wrapping is consistent for the entire text. The code below assumes that a paragraph ends with a line that is shorter than the a...
I just coded this formatter to format timestamps in javascript (I tied it to underscore for convenience), any remark? _.toDate = function(epoch, format, locale) { var date = new Date(epoch), format = format || 'dd/mm/YY', locale = locale || 'en' dow = {}; dow.en = [ 'Sunday'...
After watching Raymond Hettinger, I decided to go through my code and make it faster and more beautiful. The example given on the slides is, unfortunately, not good enough to get me going (ref. https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger) Here's my code. Do...
I've just implemented a cache for my server, and I'd like your thoughts about performance improvements and maybe some possible bug fixes: public class Cache<CacheKey, CacheValue> { private Dictionary<CacheKey, KeyValuePair<CacheValue, DateTime>> _map; /// <summary> /// The first element is the least recent...
I've recently written a program for Python 3 that I'm using to practice my newly-acquired object-oriented knowledge. It's a simple text game that is really easy to play and can be run straight out of IDLE with no modules (except the Random module). I realize that beginner code can sometimes be sloppy and difficult to r...
I was wondering about the best way to return the most common items in a list. So far the best way I could do it was: //@param string $this->matched_ids_list = 1,11,12,11,12, $this->matched_ids_list = "," . $this->matched_ids_list; $this->ids_count = explode(",", $this->matched_ids_list); $this->ids_count = array_uniqu...
I'm open to any advice to help improve this code for general use. /** * * This code was created by Joshua Getner. * @license http://opensource.org/licenses/bsd-license.php BSD * * */ namespace Blacksmith; class Autoloader { // an array that maps classnames to there filepaths protected static $classes = ...
I'm trying to merge counts for items (URLs) in the list: [['foo',1], ['bar',3],['foo',4]] I came up with a function, but it's slow when I run it with 50k entries. I'd appreciate if somebody could please review and suggest improvements. def dedupe(data): ''' Finds duplicates in data and merges the counts ''' re...
I'm (very) new to Scala, and decided I'd try to get a handle on some of the syntax and general language constructs. This currently doesn't implement any backtracking and will only solve things if they can be derived exactly from the values given in the initial board. That being said, I don't particularly care about a...
The following piece of code executes 20 million times each time the program is called, so I need a way to make this code as optimized as possible. int WilcoxinRST::work(GeneSet originalGeneSet, vector<string> randomGenes) { vector<string> geneIDs; vector<bool> isOriginal; vector<int> rank; vector<double> value; vector<...