instruction stringlengths 71 71.9k |
|---|
This is a short program meant to give me an Erlang hook into the ImageMagick FFI for performance reasons.
All comments welcome, but specifically
my C experience is minimal, bordering on nonexistent, so I would particularly appreciate hints in that area.
the setup here is one of a long-running process that will be a... |
The reason I want to do this is that the JavaScript objects are created from XML elements and if the element has changed I want to be able to detect that change in the JavaScript objects. So I wrote a function which maps out the differences between the first and second object. Can you improve on this function? (mapObje... |
How can I make these methods better?
Range.class_eval do
def addto_begin(x)
return self.begin + x..self.end
end
def addto_end(x)
return self.begin..self.end+x
end
end
Right now, I have to type:
x = 1..10
x = x.addto_begin(3)
to change the begin of the range. What I want to be able to d... |
I wanted to download a webpage. I confirmed that this code works. But I'm not sure whether I'm doing it neatly. Would you review my (full) code?
import java.io.IOException;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.net.URL;
public class GetHTML {
private InputStream in;
private F... |
So far, this is just a class that tracks the state of a baseball game. Unfortunately, I can't tell you for sure what the next step is. It might be a an interactive playable baseball game, or a game simulator, or some combination.
I am hoping this class is sufficient to do either of those things. The test class would... |
I just made this responsive image solution, but I'm not sure if it's the best way to do what I'm trying to achieve. Use cases can be found at http://responsimage.com/.
/* responsimage.com v0.2.3 */
(function ($, window, Date) {
'use strict';
$(function() {
var rPrefs = $('meta[name="responsimage"]'),... |
I am developing code for a problem posted on StackOverflow.
I have written my solution in Java but it is taking too much time to execute for numbers such as 21432154197846387216432. How could I improve the performance of the following code?
import java.util.Scanner;
public class Main {
// private static final d... |
Right now I am working on an AJAX call that grabs a random photo that a Facebook user is tagged in and then grabs the large source for it. Is there any way to speed this up or at least distill the call into one query?
var query1 = encodeURI("SELECT pid,xcoord,ycoord FROM photo_tag WHERE subject={{mystery.uid}} order by... |
I'm new to using PDO and am trying to create a secure class to handle MySQL statements. Here is what I have so far:
class SQL {
private static $dbh = null;
private function __construct($host, $user, $pass, $data, $table) {
$this->host = (!empty($host)) ? $host: 'localhost';
$this->user = $user;
$this->pass... |
I have an application coded in VB.NET that has a bunch of servers in a DataGridView and does a continuous asynchronous ping. If all the servers are up it refreshes great, but if one goes down and starts to time out it takes about 5-10 seconds before the program starts responding again. This program needs to ping all ... |
Questions:
Is this code secure? (I think that it is, but I'm a newbie so I want to be sure.)
Is the get_pass function correct with passing the arguments to the free_memory function?
Do I have to delete the pass' buffer with memset?
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#inclu... |
I've programmed a minimal parallel workers queue in Ruby, and I wanted to know if it's correct, and if there are simpler ways of implementing it.
I'm aware of the existence of MonitorMixin, but it won't save any code, I think.
The design is kept intentionally trivial (e.g. it uses Thread.abort_on_exception).
# Usage:
#... |
I'm doing some homework and am just curious if everything I've done looks good and/or if you'd suggest I modify something to keep with "javaese."
import java.util.Scanner;
import java.util.Random;
public class rockpaperscissors
{
public static void main (String[] args)
{
int cChoice; // variable f... |
This is the simplest possible implementation.
The two lists will contain at max, 3-5 elements, so the size of lists is not a matter of concern.
Any recommendation on how can I make this pretty?
private ListsHolder findDiffOfLists(List<MyObject> objsFromDB, List<MyObjRequest> objsFromRequest) {
ListsHolder holder = ... |
Just wondering if my
else {return false;}
statements are superfluous... do I just need one return true; here?
function has_access() {
if ( is_user_logged_in() ) {
$role = get_current_user_role();
$admins = array(
'Administrator',
'Agent',
'Contributor',
... |
can someone read through this script really quick and verify that I didn't miss anything... I'm not getting any errors in my IDE so just have to make sure the structure is correct
<?php
require_once '/usr/local/cpanel/3rdparty/lib/php/Mail.php';
$db_server = 'localhost';
$db_user = '-----';
$db_pass = '-----';
$dbc =... |
This is a custom effect for jQuery tools that enable caching for ajaxed tabs.
Please advice on anything that I can improve. Note that I'm not sure where to put the loading indicator, so, at least have a look at that.
$.tools.tabs.addEffect("ajax_cache", function(tabIndex, done) {
//check if content already loaded
... |
I'm writing a form that contains 2 ListViews with a set of 4 buttons. 2 move all the items from one to the other in each direction, the other move only selected items in each direction.
Nothing fancy or complicated.
However I'm feeling like I could write the MoveItem method in a more elegant way and was wondering if an... |
I'd like to know if this is the right syntax for using cookies. I haven't yet tested this code with cookies being used.
I'm using a jQuery Plugin called jPages to display pages on my (one page) website, it has a lot of options and it's very flexible.
The jPages plugin has an option to start from a different page per s... |
Description
I'm writing a program that makes changes to a few Python source files--creating some, and appending content to others. Since some changes depend on others, I check frequently to make sure everything is going smoothly (try importing the modified file, etc). I would like to revert any and all changes my progr... |
I have many-to-many mapping with extra columns in the join table. The table structure looks like this:
table vendor{vendor_id, vendor_name, vendor_password, etc...}
table student{student_id, student_name, student_password, etc..}
table test{test_id, test_subject, test_price,test_level, etc..}
Relations as follows:
ve... |
The following method is designed to display what we owe to a vendor based on 5 buckets. Basically, an aged trial balance (totals only). It also needs to be able to display the data based on any date. It shows me what the trial balance would have looked like on April 1st. By default it displays based on the date that it... |
Looking to optimize this method so it will run quicker, but can't seem to find anything. WOrking in .NET 3.5. ExcludedWords and NewCodes are both HashSet of strings.
private bool isValid(String code)
{
String pattern = "[a-zA-Z]{3}";
if (chkLessThan2Letters.Checked && Regex.IsMatch(code, patt... |
The common FizzBuzz implementation I saw is using a check for % 15 for printing "FizzBuzz"
Would you let me know if there is anything wrong / better with this approach?
public class FizzBuzz {
public static void main(String[] args) {
for (int i = 1; i <= 100; i++) {
boolean fizzOrBuzz = false;
... |
Is there a better way to do this?
function Person(name)
{
this._type='Person';
this.name=name;
this.hello = function(){
alert('Hello '+this.name);
};
}
function object_to_instance(key, value)
{
if (!value.hasOwnProperty('_type'))
return value;
var obj= eval('new '+value._type+... |
In a Mako template partial I accept an argument (step) that can be an instance of Step class, a dict or None. Can I in some way avoid repetition or do the check in other more 'pythonic' way? Or how could I gracefully avoid checking types at all?
<%include file="_step.mako" args="step=step" />
and then in _step.mako:
<... |
I created this as part of an interview process of graduate programming job. Submitted the code to them, and I was called for an interview.
This is the assignment brief: http://knight-path.sourceforge.net/puzzle.html, however I was told I can accept the input and produce the output in whatever form I think is most effe... |
I recently wrote my first C# app that's goal it to take a drive letter and output a CSV list of some basic information. TOTALSPACE,FREESPACE,STATUS.
I've been wondering If it would be possible to make this application even faster. Got any good suggestions?
using System;
using System.Collections.Generic;
using System.Te... |
This program downloads a Code Review HTML file and parses it.
Could you review my program?
Main.java
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception {
final String site1 = "http://codereview.stackexchange.com/questions/";
String site2;
String... |
A little while ago I wrote some jQuery code to make a div flip (similar to the Apple Dashboard). I know there is already code that has this idea from Jon Raasch, but this code positioned divs absolutely, which I did not need for my cause.
I just wondered if anyone could give me some advice as to how to tidy this up and... |
I only recently started coding so I know my code is not very good, but i would really appreciate any help on improving my code.
my database table looks like this
game_id |title |developer |publisher |genre |release_date |platform
rating |image_location |description
the first page
this page is pretty straightf... |
I've an IEnumerable<T> source which takes time to generate each item. Once an item is generated, I want to cache it to avoid recomputing the same thing. I want to separate out caching logic from original source.
A few things that bother me are:
Where should I have _cache? In CachedEnumerable or CacheEnumerator?
Thread... |
This is my solution to the exercise 48 of Learn Python the hard way by Zed Shaw. Please visit the link for testing suite and requirements.
I'm worried about my the word banks I have created (COMPASS, VERBS, etc...) as this seems a duplication from the testing code.
I'm also afraid my handling might have gone overboard ... |
I'm trying to improve my code. I've some doubts about db_index, primary_key and unique parameters.
# -*- coding: UTF-8 -*-
from django.db import models
from django.contrib.auth.models import User
#=================================================================================#
class Country(mod... |
I am looking to make the below code a bit more efficient / OOP based. As can be seen by the X, Y & Z variables, there is a bit of duplication here. Any suggestions on how to make this code more pythonic?
The code functions as I wish and the end result is to import the dictionary values into a MySQL database with the ke... |
The goal is to display all posts with their categories underneath them. The code below accomplishes this, however I'm thinking it's bad and was hoping someone could review and offer some feedback.
Because each post can have many categories and because each category can belong to many posts, I used a many-to-many table... |
I just finished my working code, but still want to improve it.
I want to transform this input:
<item>asdf</item>
<item>asdf</item>
<item>asdf</item>
to this output:
<string name="x1">asdf</string>
<string name="x2">asdf</string>
<string name="x3">asdf</string>
My current code:
static void Main(string[] args)
... |
I want to write an example for a language similar to Haskell called Frege. While the interpreter is conceptually easy, it is lengthy and looks still quite messy. Note that I don't want to use Parsec etc, as it isn't available yet in Frege. Please help me to improve the Haskell version.
import Data.Char
data Tape = Tap... |
I wrote a little function to compact long text. I am relatively new to JavaScript so I am not sure I wrote it as elegantly as possible. I wrote it to be runnable on the server side (Node.js) as well, so can't use jQuery or such. Can the code be improved?
// change a long text into "bla bla bla... (more)" where (more) ... |
Having spent years writing procedural PHP (albeit with a moderate understanding of OOP from Java) I took the plunge and have attempted to write an autoload class for my PHP applications.
abstract class AutoloadClass {
protected $_observers = array();
protected $structure;
protected $extension;
/**
... |
I need to generate a sequence of int values: { 0, 1, 2, ... }, but there's a twist: I need to access them from different threads.
So I wrote this code:
class Counter
{
private static Counter instance = new Counter();
private static int i = 0;
public static Counter Instance
{
get
{
... |
Commenting omitted to give you the idea. I've been toying with this recently as a variant of the Builder pattern. I've recently fallen in love with immutable objects for the benefits they give in larger concurrent systems.
Questions:
Is there a way to do this without having to instantiate two Objects? (ie. Something... |
The output result is perfect to what I wanted, but takes a tad bit too long to pull data then render into a graph. Is there a better way to rewrite this code to speed up the process?
CASE "TestGrid":
$SnapArrayResult = array();
$PlayArrayResult = array('A','B','C','D');
echo "<table id='tb' style='width:20... |
Here is my template code
<?php
namespace classes;
/**
* Description of Template
*
* @author Aamir
*/
class Template {
private
$templateVars,
$templateFile
;
protected static
$templateFolder,
$masterTemplate,
$masterInstance,
$placeholder,
$path_dir,... |
I'm writing a method to save an input stream to an output stream. What's the optimal size for the buffer? Here's my method:
/**
* Saves the given InputStream to a file at the destination. Does not check whether the destination exists.
*
* @param inputStream
* @param destination
* @throws FileNotFoundException
* @throw... |
I'm making a method to save a byte[] to a file. It's for a Java Helper I'm writing, so it needs to be able to handle any kind of system. I saw on this example the method of FileOutputStream called write which accepts a byte[]. But I already have a method which will save an input stream to a file.
Which is best?
Alterna... |
I am writing a program which automatically crawls codes from this site!
Would you please review my code?
The required .jars: jsoup, org.apache.commons.io.
Main.java:
public class Main {
public static void main(String[] args) throws Exception {
final String site1 = "http://codereview.stackexchange.com/ques... |
I'm working on adding checkbox functionality that controls adding new checkboxes to a div element as well a tracking checkbox behavior. My goal is to make this dirt simple. I've noticed that there is some JavaScript function prototypes for creating objects such as checkboxes and also controlling basic behavior such a... |
From my original question on Stack Overflow: Is my implementation of reversing a linked list correct?
I'm a beginner at C and I'd like to know about style, and correctness of the reverse algorithms. What about memory management?
#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
int val;
struct Node ... |
I'm uploading videos to Vimeo using the VimeoAPI. I want to show a progress bar to the user. The only way to do this with the VimeoAPI is to call a method to the server which verifies the chunk you've just sent. I can send a video up in chunks of 8 bytes or 2 gigabytes. For the progress bar, the smaller the better, but... |
I use the following code to store user passwords.
string password = "...";
string user_salt = System.Web.Security.Membership.GeneratePassword(20, 5);
string common_salt = "...";
byte[] hash_target = Encoding.UTF8.GetBytes(password + user_salt + common_salt);
string password_hash = BitConverter.
ToString(new SHA512C... |
This linq query works, and it does what I want it to do, but is there any other way I could improve the query so I'm not repeating a.AnswerRevisions.OrderByDescending(r => r.DateCreated).FirstOrDefault()?
IQueryable<Article> query = from a in _db.Articles
orderby a.DateCreated descending
... |
I'm novice in C++, I've recently read some simple books and now I'm reading Scott Meyers "Effective C++" book, but I understand that I can't apply new knowledge.
I have to realize a simple C++ class that (with help of openCV) generates bitmap kernels consist of n circles.
Here is my code:
Link to source on gist.github.... |
In an effort to learn as much as possible about best development practices and software architecture, I created my own MVC framework using PHP (github: https://github.com/alemmedia/miniMVC).
I've found that this has resulted in phenomenal improvements in my programming skills, but I'm still limited by my own limited ex... |
I have written a program to find all the possible permutations of a given list of items. This precisely means that my program prints all possible P(n,r) values for r=0 to n.
package com.algorithm;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashSet;
import java.... |
Suppose I have this code:
public interface BaseType {
public void doSomething();
}
public class ExtendedTypeA implements BaseType {
//No Instance Variables
@Override
public void doSomething() {
//really do something
}
}
public class ExtendedTypeB implements BaseType {
//No instance v... |
I was wondering if there was any way I would be able to improve my HTML/CSS. Would you mind reviewing the following and telling me what I should do?
CSS:
<style type="text/css">
body {
font-family:Georgia, Palatino, Times, 'Times New Roman', serif;
color:#333333;
font-size:10px;}
h1 {
... |
I am a 3rd-year computer science undergraduate. One of my university lecturers has developed his own page for students to submit work. It came up that one student was accused of hacking (sic) by the system. The problem was the characters used in the comment field.
The lecturer claimed that he needed to filter out certa... |
I'm using Selenium to test a PHP site that goes through the following process:
Register user
Log in
Fill out Form 1 and submit
Fill out Form 2 and submit
Fill out Form 3 and submit
(tear down) Delete user
A real user would go through these steps in this order.
I've read in places that tests should be bite-sized, and ... |
I am using PHP to get data from a MySQL database, and use the data to drop multiple markers into Google Maps. Please give me some suggestions for my code.
<?php
require_once 'Common/system_start.php';
$sql="select * from tab_mem order by sn desc ";
$result= mysql_query($sql);
$data=mysql_fetch_assoc($result);
$row=mys... |
I am looking for ways to enhance this function in C++.
The function gets a date and returns the total number of seconds since the epoch (01/01/1970).
Do you have any suggestion regarding the algorithm, the code style, etc ?
Note: I use this function instead of the standard library functions because it can handle negat... |
So I got this query from another analyst here and I'm a little stumped as to why a cursor was used instead of just joins. Could I please have some help trying to refactor it? I am using MSSQL 2008.
SET NOCOUNT ON;
DECLARE @myCur AS CURSOR;
DECLARE @totalCdes AS INT;
DECLARE @SysOjb AS SMALLINT;
DECLARE @prinOjb AS SMA... |
I have created the value type below to represent the desired size for an image. The Size.Default is used in situations where the image is required in the size it was supplied in, i.e. the image shouldn't be resized.
Is this a good implementation of a value type, especially regarding the IEquatable<T> implementation?
Wh... |
I am creating a step-by-step form (it only shows in step-by-step and is not a multi state form) and the parts slide in and out (similar to GitHub but without the browser's back buttons). I have written the following code to implement this. Could you please review my code and suggest flaws:
$(document).ready(function(... |
I'm wondering if it is possible or if it is correct to proceed in such a way:
var initiate_shop = function(shop_navigation, shop_container_id, items_per_page) {
return $(shop_navigation).jPages({
containerID : shop_container_id,
first : false,
previous : false,
... |
I have some simple tests written, however, the names are not good...I think, any suggestions on better names? I'm not really sure how these tests should be named.
I'm looking for a format or pattern I can follow.
[TestClass]
public class DoorTests
{
[TestMethod]
public void DoorIsNotVirtualIfNameStartsWithLett... |
I have a getValue function which just grabs some numbers from an HTML page.
How can I access those variables in later functions without passing them down the entire chain of functions? As they sit within a function they are not global?
When I call the addition function, it will need to access the variables in the getVa... |
Do you have any suggestions to improve or extend this script? Any ideas for removing or adding comments/docstrings?
import dbm
import subprocess
import time
subprocess.call("clear")
try:
# Tries to import cPickle, a faster implementation of pickle.
import cPickle as pickle
except ImportError:
import pickle
... |
Here is my window tiling script for rio window manager in Plan 9. It fetches the current screen size and calculates the locations based on the layout given. How can I improve this program? Am I missing any idioms in rc?
#!/bin/rc
# Usage:
# First save the current windows
# ./tile.rc save >saved.s
# Next switch to tall
... |
I have to write a comparison logic.
Following is the code to refactor (as it is looking bad).
// 1. item has filter criteria
// 2. return true if current matches filter criteria
// 3. Criteria -> 3 fields should be matched ( Security, OrderType, CounterType)
// 4. Criteria -> User can specify All (*), If any ma... |
After reading this Stack Overflow question I decided to write a backup utility for local git repositories.
The result is on GitHub.
I would like this application to be well-behaved with an installer, manpages and no bugs.
It is my first time writing Ruby, so there might well be better, safer, more correct or simply mor... |
I am building a library and I need suggestions on how to improve it (security, performance, etc).
<?php
/**
* Authentication Library
*
* @author John Svensson
*/
class Auth
{
public $captchaCount;
protected $db;
protected $PasswordLib;
private $message;
public function __construct(PDO $db, Pa... |
I Needed a method to randomly sample an IEnumerable collection without replacement. I'm using this for writing behavioral acceptance tests.
For example, in the test code, I write:
GetElements("#SearchResults > li").Sample(3);
Here's the how I implemented it:
I welcome any feedback or optimizations!
/// <summary>
... |
I'm not too used to working with arrays in javascript, so was wondering if there is a good way to condense this down.
Any pointers much appreciated!
you can see it in action @ http://www.productionlocations.com/locations
if($('.filters').length) {
if(url === 'http://www.productionlocations.com/locations' || url ===... |
I'm writing a Java-Helper library. I want to include a method to zip files together, and this is what I've come up with. I'm using the java.util.zip.* library (ZipOutputStream and ZipEntry specifically).
/**
* This uses the java.util.zip library to zip the given files to the given destination.
*
* @param destination
* ... |
I am programing in C language and have created the below functions to read files. There are two functions that I can use to read files. I wanted to know how I can further improve these two in terms of efficiency and out of these two which one would be better to use for reading files.
First is:
char *read_data_... |
One day I realised that my Android project utilizes AlertDialogs here and there in very ineffective way. The heavily duplicated portion of code looked like this (actually, copied and pasted from some documentation):
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage("Are you sure you wan... |
The Qt documentation recommend an iterator-based solution to iterate over an associative container like QMap and QHash, and I always wondered if there really isn't a (nice) solution using a foreach loop like in PHP:
foreach($container as $key => $value)
I looked into the source code of the foreach macro and extended i... |
I am trying to have a ReentrantLock with another way to determinate which thread will have the lock in the waiting queue. ReentrantLock implementation manages a Fair/Unfair policy, that's not what I want.
I would like to give a priority when I call the .lock() method, and this priority will determinate the order of cur... |
I have this function which is pretty easy to read and works just fine. I'm looking to advance my coding abilities by writing more concise code, though.
Does anyone know of an elegant way to condense this down? Any pointers very much appreciated! Thank you!
var $_GET = {};
document.location.search.replace(/... |
The c# newbie is back :) I have another problem with my threads. Here is what i am trying to achieve:
I am starting 5 threads which are performing the same task but on different URLs. So i am keeping a "masterLogFile.txt" to keep track of what URLs have already been visited.
Each thread compares its own "thread1LogFil... |
How can I improve the performance of this method or is it already good?
private static void LoadAssembliesWithInjectorModule(IEnumerable<FileInfo> files)
{
var moduleType = typeof (InjectorModule);
foreach (var file in files)
{
try
{
var assembly = Assembly.LoadFrom(file.FullNam... |
I feel like I can vastly improve this. Any ideas?
// get orientation of device
getOrientation();
// animate
var num = 400;
if( $('body').hasClass("landscape") ) {
$('.example').animate({'bottom', 0});
} else {
$('.example').animate({'bottom', num});
}
function getOrientation(){
switch(window.orientatio... |
I have various strings that contain codes, e.g. like this:
"file = new JarFile(new File()" + "\nSystem.out.println(file"
but also
"args"
Now I want to find the substring that is in the beginning and in the end of the string. E.g. in the first case the result would be file. In the second example the result has to be a... |
A Java desktop application exposes the class/containment hierarchy of its Swing GUI through RPC. I'm building a Haskell client that connects to the application. The objective is to be able to perform queries like "find all the buttons of width less than w, located within screen rectangle r" over a data structure on the... |
I need to pass an array of values in Url.Action.
Currently I'm doing:
var redirectUrl = Url.Action("search", new {
q = criteria.Q,
advanced = criteria.Advanced,
salaryfrom = criteria.SalaryFrom,
salaryto = criteria.SalaryTo,
});
if (criteria.JobTypes != null)
redirectUrl += c... |
I have a program where it takes the students name and last name and score and saves it. When checking to see if a textbox has information in it, I use a lot of if statements. Is there a cleaner way to do this?
public void CheckData()
{
if (first1.Text != empty & score1.Text != empty & last1.Text != empty &
... |
I have the following script that I'm part way through and I'm not happy with it at all, it feels messy:
<?php
class Process {
public $search = 'http://api.themoviedb.org/2.1/Person.search/en/json/xxx/';
public $info = 'http://api.themoviedb.org/2.1/Person.getInfo/en/json/xxx/';
public function returnId($na... |
This falls straight into the same category with the recent "Is it better practice to return if false or execute an if statement if true?" question.
Often, while writing code, I find myself presented with two options. Either I can do this:
public void myMethod() throws Exception {
// Some code
validate(some_obje... |
I created a small Android project with an AsyncTask. It simulates a time consuming task.
Please review my code and tell me what you would do on a different way and why. Comments not specific to Android but general software development are welcome.
CounterTask.java:
package my.tasks;
import java.util.Random;
import a... |
I have a list of resources which can be voted on. There are 3 voting states: upvoted, downvoted and no vote.
In a fashion identical to Stack Exchange voting, it follows these rules:
If you upvote a post you've already upvoted, it will set it to 'no vote'
If you upvote a post set to 'no vote' it will set it to upvote
i... |
The goal is to
make an object that persists upon page reloads,
have an interface as close as possible to the Object class.
function PersistentObject(key,initial_value)
//use for(..in data.keys()) instead of for(..in data)
{
var ret;
if(localStorage[key]) ret=JSON.parse(localStorage[key]);
if(!ret) ret = initial... |
This is a fairly trivial example of a question I come up to often. In the example below I tend to think that allowing duplication sometimes results in clearer code.
Does anyone agree/disagree on this point?
First way: an additional local variable is used so method.Invoke is called just once on the last line. I think t... |
I have 12 games that I need to sort through that each have a date and img string. I'm fairly new to jQuery and was wondering what is the best way to accomplish this. Is there a way that I can run this through a loop of some sort rather than having 12 else-if statements like I currently have (code condensed to 3 for re... |
In my Backbone.Collection I need to parse the response before to render it in Backbone.View. The following code works, but it will be great to have some suggestions:
// response is array of object
// [{id:1, prop: null },{id:2, prop: "bar" }]
// the output parsed_response can be
//[{id:1, prop: null, isProp: true }... |
I have written this code which precisely calculates the nth power of x by a recursive method.
I compared my program with Java's pow(double, double) function, and most of the time I get comparable results, although sometimes pow is slow and the other times this program is slow.
Can anyone suggest any improvements or the... |
I'm attempting to implement various data structures and algorithms to better learn C. I would appreciate comments on style, correctness of the implementation, memory management, etc.
One specific question is how to address an error case where either the table or key is null in the hash function. In get or rm I can us... |
I'm attempting to implement driver-layer (shared library) from top-level app to hardware.
In the first, I extracted interface functions, which further will be called from "extern "C" SHARED" wrappers to separate class IDriverInterface.
In the second, I want to hot-test some functions before the correct implementation a... |
I am currently writing an embedded application for audio streaming purposes. The embedded app will receive audio packets being sent over WiFi, buffer the packets, then send the audio data over to a decoder chip. I have a ring buffer implementation written, but am getting some weird behavior sometimes. In terms of audio... |
I have an app that does a fair bit of text-parsing based on free-form user inputs. In this, I run searches on the whole string, and then on the last value of the string separate from the rest of the string. Here is a pair of functions I wrote to getLast and getSubString.
<cffunction name="getLast" output="no" returnT... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.