instruction stringlengths 71 39k |
|---|
Nothing too special here, just a bunch of stuff. Please tell me if you would've done something different.
<?php
/**
* SQL_Helper are functions which help with... SQL... :)
*
* @package SQL_Helper
* @author Itai Sagi
* @version 1.0
* SQL Helper functions
* Assumption: a... |
I have a need to represent a finite set of discrete string values:
When these strings are used in code, they must belong to the valid set, or serious errors (or worse) can occur.
As "magic strings" are a terrible code smell, I want to encapsulate the strings within a non-string type, so that I can require the use of... |
Here is a simple plugin I have written for a jQuery dropdown effect. Simple show / hide (although open classes may be better).
When you click the HTML the event searches the whole DOM for a specific class and then hides it (or removes the open class), even if the dropdown is already close.
Is there a way to only apply ... |
Is this the way PHP developers write PHP or is echoing the html the preferred method?
<html>
<head>
</head>
<body>
<?php
require_once 'db_connect.php';
session_start();
$result = mysql_query("SELECT * FROM products");
?>
<table border=1>
<th>
Product ID
</th>
<th>
Name
</th>
<th>
Desc... |
public class BuscaDiretaBusiness
{
PortalIOEntities portalIO = new PortalIOEntities();
public IQueryable CarregaAlias(out int ItemsCount)
{
var query = from a in portalIO.DO_CadernoBuscaDiretaAlias
select new
{
a.CDP_ID,
... |
I'm trying to reflect a ray of a triangle using Processing and not sure I got the code right. I'm using two bits of pseudo code from two locations:
Intersection of a Line with a Plane from Paul Bourke's site.
Reflecting a vector from 3DKingdoms site.
Here's my code so far:
PVector[] face = new PVector[3];
float ai = ... |
I am a moderately new Scala developer working mostly by myself, so I don't have anyone to tell me what I'm doing wrong (except that the system mostly does work, so it can't be too awful). I would appreciate some feedback on how to make better use of Scala as well as any comments about obvious performance issues.
The cl... |
This is supposed to be strict ANSI C89 pedantic code. It should extract word1, word2 and word3 from a string formatted [ word1 ] word2 [ word3 ] and return failure in any other format.
It seems to work, but it seems so ugly. No need to comment about the fact GetTokenBetweenSquareBraces and GetTokenBtweenOpositeSquareBr... |
I have a type that receives serial data over a pipe:
struct Packet : Base { // Base is POD, too
int foo;
char data[];
};
In the context, where I instantiate Packet, I already know how large this particular packet will be, so I write:
size_t const size = sizeof(Packet) + dataLength;
std::auto_ptr<Base> p(new((void*... |
This is a personal project of mine. I am currently in the research phase of developing my own bootloader that will be used to load a single task operating system. I am far away from the final goal, but have been trying to document my process as a reference. The content of my code documentation and code can be found at... |
This is a ( single file ) library I wrote as an helper to check arguments validity.Here below a sample usage:
public class Demo
{
/// <summary>
/// Classical not null verification
/// </summary>
/// <param name="arg1"></param>
public void DoSomething(string arg1)
{
... |
Is it possible to make this code more efficient & elegant?
int HexToDecimal(char ch)
{
ch = tolower(ch);
if ('a' <= ch && ch <= 'f')
{
return ch - 'a' + 10;
}
else if ('0' <= ch && ch <= '9')
{
return ch - '0';
}
printf("Error\n");
return 0;
}
Update: Printing error... |
I use this class for scheduling bits of work on a single thread. Work can be scheduled to be executed immediately or at a future time with the use of timers. It has many producers (the work adders) and a single consumer (the thread which executes the work).
This class works well but I'm under no illusion that it's perf... |
Is there a better way to format this code, to make it more readable?
footnotes_paragraph.xpath('./small').children.slice_before do |element|
element.name == 'br'
end.map do |element|
Footnote.new element
end.reject(:empty?)
|
I wrote a non-blocking MySQL interface for java (wrapped around the standard mysql java connector).
I think the code to use it looks a bit ugly however...
db.rawQuery(queries.someAlreadyPreparedStatement, (new Callback(){
public void result(ResultSet result){
while (result.next()) {
//Handle eac... |
I have created an NBT format reader (NBT is a binary serialization format that Minecraft uses to store its data). I made a node-like class that can be a data entry or the root of a subtree (that's how NBT is defined). The public interface of it currently looks like this:
class Tag
{
Tag();
void read(std::istre... |
This is just a big HTML file that can be setup to test any RESTful API. The only change that needs to be made is updating the config array for any specific API you are developing.
<html>
<head>
<title>RESTful API Debugger</title>
<style>
label{ display:inline-block; width: 80px; }
</style>
<script t... |
My goal with vervPHP was to create a framework I could create applications in very quickly, without any excessive configuration or over the top framework.
Here's a link to the github, to see more: https://github.com/verv/vervPHP
And now, for some code examples to show how awesome (I think) it is:
index.php:
// Start th... |
I have a blob whose format is something like:
(id1,key1,value1)(id2,key2,value2)....
where id is a uint32_t, and key and value are null-terminated strings. I am looking for an iterator-like interface that will extract records from the blob.
This is what I have come up with:
typedef struct blob_ {
uint32_t size;... |
I am using jQuery datepicker on 2 forms on the same page.
I currently am using the following code (below), but as you can see, I am using the same parameters over again (showOn, buttonImage, buttonImageOnly, dateFormat, & constrainInput)
Is there a more efficient way to do this rather then repeating myself over and ove... |
I've created a set of classes thatwork together to create the html needed to display social plugins like Facebook like, google plus and twitter.
At firsti defined an abstract class SocialButtonAbstract that is the base class that will be extended by the various plugins
abstract class SocialButtonAbstract {
protect... |
I'm trying to teach myself a new pattern, the command pattern, and came up with the following example. Looking for feedback.
public class BaseTool
{
private List<ICommand> CommandHistory = new List<ICommand>();
public string State = string.Empty;
public BaseTool()
{
}
public virtual void Exe... |
I have a class that produces a key based on the two objects passed. The key for the items passed is simply the string of the ID (a GUID) for each object. There is also a subclass that makes sure any to items are only represented once (sets).
The classes looked like the first code block below. But then I ran into a perf... |
I'd like this reviewed.
public sealed class FibonacciHeap<TKey, TValue>
{
readonly List<Node> _root = new List<Node>();
int _count;
Node _min;
public void Push(TKey key, TValue value)
{
Insert(new Node {
Key = key,
Value = value
});
}
public K... |
I am trying to implement a shared cache for arrays. It must support two operations: set(owner, idx, value) and fetch(owner, idx) where idx is the index into the array and owner is an opaque handle to an owning object -- fetch(owner_1, idx) should return the value stored by set(owner_1, idx) only if the owner argument ... |
public sealed class SinglyLinkedList<T> : IEnumerable<T>
{
readonly static SinglyLinkedList<T> _empty = new SinglyLinkedList<T>();
readonly bool _isEmpty;
readonly T _head;
readonly SinglyLinkedList<T> _tail;
private SinglyLinkedList()
{
_isEmpty = true;
}
private SinglyLinkedL... |
I'm writing an if with nested conditions and end up with this ugly if:
if( !arg ||
(typeof arg.search != 'undefined' && typeof arg.done == 'undefined' &&
item.attributes.text.toLowerCase().indexOf(arg.search.toLowerCase()) != -1) ||
typeof arg.search != 'undefined' && typ... |
I've created a functional A* implementation in C#/XNA for a game I'm working on. However, I am using rather large paths, and of course, the larger the paths are, the longer it takes to trace them. There is no way to shorten the paths (Thin Maze - Style) and I assume this is a horrid way to implement it. I followed a tu... |
The "Causes" puzzle is to recursively find, starting with the word "causes", the number of words that can be formed by substituting one letter.
sub addMember {
my ( $self, $newMember ) = @_;
my $len = length($newMember->{'_data'});
my $newMemberIndex = push(@{$self->{'_MemberList'}}, $newMember) - 1;
$self->{'_... |
After my question on StackOverflow, I've written code that should create a Config class from an XML file. XML loading is mixed with structures declaration and break in a lot of small pieces.
However, I'm not sure if this is bad or good. How would you refactor this? Probably some simple design pattern can be used, but a... |
int *getUserInput(FILE *fpin, int *elementCount) {
int *userInput;
// Load file into buffer
int length = fileLength(fpin);
char *buffer = (char *) malloc(length * sizeof(char));
int written = fread(buffer, sizeof(char), length, fpin);
// Number of int's allocated in userInput
int allocated = 10;
*elemen... |
At the moments the requirements do not need me to change this code, however I think there is something wrong with it in the fact that it seems to know too much. The code takes a memory stream which is essentially a file and uploads this to a post URL supplying the necessary credentials. It may also need to pass other... |
How can I optimize checking a value in recursion before operating on it? I'm using Array.indexOf (this is Javascript)
var nums = [], lengths = [];
function findNumLength(n) {
//preliminary check to see if
//we've done this number before
var indexOf = nums.indexOf(n);
if(indexOf !== -1) {
return... |
For anyone familiar with the UVa Programming Challenges website, I have started experimenting with some of the basic challenges. I was hoping to get critique for the code I wrote for "The 3n+1 Problem" (Problem ID 100).
The run-time for this submission was 0.040 and my best submission was only 0.036. Looking at the s... |
Inspired by a Stack Overflow question, I decided to practice my Haskell by taking a crack at the Google Code Jam's Minimum Scalar Product problem:
Given two vectors \$\mathbf{v_1}=(x_1,x_2,\ldots,x_n)\$ and \$\mathbf{v_2}=(y_1,y_2,\ldots,y_n)\$. If you could permute the coordinates of each vector, what is the minimum ... |
Source XML (since I haven't bothered with a schema):
<?xml version="1.0"?>
<ContactDetails>
<Names>
<FullName>
Nicholas Example
</FullName>
<AltName context="Nickname">
Nick
</AltName>
<AltName context="Online">
oxinabox
</AltName>
</Names>
<Phones>
<Phone context="Mobile">04 1234 1234... |
This is my first Clojure script (simple word translator based on Wikipedia), and I guess there are things which could be simplified / done more idiomatic way. Specifically, I wonder if get-translations couldn't be done better (it produces map lang code => term form regexp sequence).
(ns wiki-translate
(:require [clo... |
After programming a lot in high level languages such as Python and R, I started working with C++ recently. To get my C++ skills up, I of course read a lot of books. In addition, I try and replicate some functionality from high level languages in C++. My first attempt at this (after Hello World :)) was to create a C++ c... |
#include <cassert>
#include <string>
#include <vector>
using namespace std;
inline size_t min(size_t x, size_t y, size_t z)
{
if (x < y)
return x < z ? x : z;
else
return y < z ? y : z;
}
size_t edit_distance(const string& A, const string& B)
{
size_t NA = A.size();
size_t NB = B.size(... |
Here is my code:
hasAttr = new function(tag, attrName) {
return (tag.attrName)
}
Will this code work? I can't test it now because I cannot acces jsfiddle and jsbin but Down For Everyone or Just Me? says something else.
jsFiddle Down For Everyone or Just Me
jsBin Down For Everyone or Just Me
Example usage:
JavaSc... |
Here is some code that I put together for an app I am working on that loads 2 XML files and a large CVS file to a dataset at startup. It runs fairly fast, but I would like a second opinion on what I could do to either make it more consise or faster. I'm newer to .NET as well, so if you see anything that isn't very ."... |
The game of life is often implemented by representing the board as a 2D boolean array. This doesn't scale very well to larger boards -- it starts to consume lots of memory, and without some separate mechanism to keep track of a list of live cells, you have to visit each board cell on each iteration. This implementati... |
public interface ICacheable<TK,TV>
{
TV Get(TK key);
void Add(TK key, TV val);
}
public abstract class BaseCache<TK, TV>
{
protected static Dictionary<Guid, Dictionary<TK, TV>> data = new Dictionary<Guid, Dictionary<TK, TV>>();
private Guid StorageNameSpage;
protected BaseCache(Guid storageNameSpage... |
I use ruby 1.8.7. I have method wich select records and fill hash. In my opinion the code is not dry. Could somebody help me to refactor it and make it shorter and more elegant?
def fill_attributes()
if (!$array[:status_id])
$array[:status_id] = @customer.status_id
@status_name=Status.find($a... |
I've defined a Client class to connect to an external API. The Client class will return XML responses for various resources. Here's what it looks like now:
require 'nokogiri'
class Client
include Exceptions
CONFIG = YAML.load_file(File.join(Rails.root, 'config', 'mark.yml'))
def self.get_leagues_xml(league, ... |
I'm pretty new to OCaml, so any feedback is appreciated. The goal is to implement a trie that efficiently stores and sorts strings.
module CharMap = Map.Make(Char)
(* count of members of the set that end at this node * mapping from
next char => children *)
type trie = Node of int * trie CharMap.t
let empty = Node ... |
I would like some eyes on this:
/* Little XHR
* by: rlemon http://github.com/rlemon/
* see README for useage.
* */
var xhr = {
xmlhttp: (function() {
var xmlhttp;
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp = new ActiveX... |
Is this the easiest way to delete everything between and including the two first quotes (if present) in an std::wstring?
unsigned int firstQuotePos = logFileName.find_first_of(L"\"");
unsigned int secondQuotePos = logFileName.find_first_of(L"\"", firstQuotePos + 1);
if (firstQuotePos != std::wstring::npos && secondQuo... |
I successfully created an expression evaluator in C#, and I would like to know if it works well, and what I can do to improve it.
class ExpressionEvaluator2
{
public enum Token
{
None,
Literal,
Variable,
Operator,
Function,
FunctionArgumentSeparator,
L... |
string Format(string format_string, T1 p1, T2 p2, ..., TN pn)
The Format() function takes a copy of format_string and replace occurrences of "___" with the remaining parameters to the function (p1, p2,...). The first occurrence of "___" will be replaced by p1, the next by p2, and so on. If there are no occurrences o... |
I am stuck with some old API that involves COM and ODBC, and I cannot switch to cool things like MEF or entity framework. So, I am working on some wrappers that will help me write less code and also bring some of the type safety back (as you know, COM and SQL do not have type safety, at least not in the same way as C# ... |
Just wondering if there was someone out there that could offer help in optimizing my script which "derpifies" images.
<?php
/**
* If you don't understand what this does
* you have no hope as a programmer.
*
*/
function usage ( )
{
// Ahhh the marvels of echo, such a wonderful tool
// yet so advanced that a begi... |
This is a very simple nested property extractor. I wonder if it can be optimised further?
/**
* Extract nested property from object. If nested property cannot be reached, return value of rescue
* @param obj Object
* @param path Can be dot-separated string or array
* @param rescue (optional) default value. Defaults... |
This is intended to be part of a generalised solution to the problem of converting any (with some minor restrictions) CSV content into XML. The restrictions on the CSV, and the purpose of the schema should be apparent from the annotations.
The main review criteria I request are:
Is it suitable for non-destructive roun... |
I have an application which is used for displaying and modifying huge volumes of point cloud data from lidar files (up to few gigabytes each, sometimes loaded in simultaneously). In the app the user is able to view a 2D image of loaded points (from the top) and select a profile to view in another window (from the side)... |
Ok I have a method:
//_seen is defined as a HashSet earlier
public boolean isTerminal(Node node)
{
if (_seen.contains(node.getState()))
{
return true;
}
else
{
_seen.add(node.getState());
return false;
}
}
What is the nicest way of doing this? It could use a variable to ... |
This is for a college assignment, it has been submitted but I'd like some general feedback on how to improve it or whether I should be using more functions or less functions.
Also, is my commenting too extreme?
/**
* This program takes two binary integers and performs one of three operations
* on them.
*
* It will... |
This script fetches a list of "end-positions" from a MySQL database. The positions are array positions that are the same in both MySQL and R.
Next, the script takes the previous 34 elements for each metric and calculates their correlation with a query series.
The top X highest correlated (in total for each metric) and ... |
I have black and white SDL_Surface and I'm trying to change colors, such as from black to white and from white to red. I did it, but it is taking too long to work.
SDL_Surface* tempSurface = SDL_DisplayFormat(textSurface);
for(int i=0;i<256;i++){
SDL_SetColorKey(textSurface,SDL_SRCCOLORKEY,SDL_MapRGB(textSurface->... |
I have about 5 of these but I can't figure out how to consolidate them.
$('#togglemass').toggle(function () {
$("#plusmass").attr("src", "minus.png");
},
function () {
$(".plusmass").attr("src", "plus.png");
});
$('#togglestar').toggle(function () {
$(".plusstar").attr("src", "minus.png");
},
... |
I have three tables
class User < AR::Base
has_many :lexemes, :dependent => :destroy
end
class Lexeme < AR::Base
belongs_to :user
belongs_to :word
end
class Word < AR::Base
has_many :lexemes
end
This code is storing the word to Words table and assign it to the user.
word = Word.where(:word=>token).first_or_cr... |
This class is used to draw an old school flame on a canvas element. I'm wondering if there is any way to speed up the fire method. The class is based on old C code.
LayerFire = {
init : function(options, elem) {
this.options = $.extend({
width : '320',
height : '240'
... |
I've come up with a simple Datasource design which allows me to quickly create Datasources and even abstract it behind Interfaces. Of course I ask myself if I can do something better.
The goal of these classes is to have a simple and easily exchangeable layer which just returns Objects. By easily exchangeable I mean th... |
I've written a small function which displays a div related to an anchor element using data attributes.
The data attribute is used to match the class of the relevant div which is then displayed whilst the others are hidden.
All very basic, however I'm wondering if there is anyway to improve it? Is there a better solutio... |
I just wrote some code that is very representative of a recurring theme (in my coding world lately): repeated logic leads to an instinct to eliminate duplication which results in something that is more complex the tradeoff seems wrong to me (the examples of the negative side aren't worth posting - but this is probably ... |
I just began to study Scala (coming from Python I had quite a few problems with types) and I want to know if my first code to solve a real problem is nicely done or if there is some points that need to be redone.
The problem I had to solve is for an homework but my code is already working, I just want to know if it be ... |
I have an API that takes a class as a configuration parameter, but I don't want to load the class (I'm using Rails) at the time that I'm setting up the API. I figured I could get around this by passing it an object that acts like the class in every way (by delegating to it) but doesn't actually reference the class, and... |
Prompted by this question on Stack Overflow, I wrote an implementation in Python of the longest increasing subsequence problem. In a nutshell, the problem is: given a sequence of numbers, remove the fewest possible to obtain an increasing subsequence (the answer is not unique).
Perhaps it is best illustrated by exampl... |
I think this code cannot be shortened much, especially because I only consider two cases. But maybe there's a language construct that I don't know that would help.
if (subControl.inverted) {
newValue = subControl.value+(float)(1.0f/(float)subControl.decorator.ticks);
if (newValue > 1)
newValue = 0;
} el... |
I have a ASP.NET Web Forms project, and I want to build calls to .aspx pages in a strongly-typed fashion. I ended up rolling my own serializer that takes simple structs and saves them to/loads them from the query string. What do you think? Is my approach sane? Is there an accepted alternative I don't know about? Any fe... |
I've written this brief function for calculating which calendar year a student would be in Year 1 based on their DOB (date of birth). In 1998 there was a change in the DOB cut points for starting Year 1, hence the need for a function.
year1 <- function(x){
if(x <= as.Date("1996-12-31")) {out <- as.numeric(format(x... |
This is a pagination program that works perfectly fine. I want to be able to save this code and reuse it whenever I need it as a method in jQuery (read: $(myData).pagination()).
jQuery:
$(document).ready(function(){
var post = $(".note > li")
var page= 1;
var postsPerPage = 5;
var numPages = Math.ceil(p... |
I'm trying to implement a custom made 2D geometry library. Originally I was looking at the problem of intersections of many circles but wanted to widen the scope of the code to deal with many future geometry based problems.
I already have a vector (2D) class defined. I wish to derive all my other geometrical entities f... |
I'm working with some strange APIs that requires the dates to be sent in the YYYYMMDD format.
I was thinking of doing something like this:
string date = string.Concat(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
Is there a better practice?
|
I started out with a function having code duplication like this:
private static void GetAndSaveResources(string url)
{
...
if (url.Contains("[" + "access_id" + "]"))
{
RestCall.UriVariables.Add("access_id", 1);
}
if (url.Contains("[" ... |
I am new at facebook development using their PHP-SDK and Graph API. I am at the stage that I need to find which road should I take for a better/faster and efficient results.
I display the pages a user administrates in both ways. My question is which one should I choose?
Thank you community.
Using Facebook PHP-SDK
requi... |
I am working on an app where I have to calculate the age of a person. Inside of my age class I have a function that is designed to account for leap year. Is there anything I am missing or could improve upon? I would have though this would have been more complicated so I am not confident in my method or my test case.... |
Right now I am working on an install and uninstall script for my vim configuration files. The install script links files and directories and the uninstall script deletes those links. I just want to make sure that this code is somewhat safe, are there better ways of doing the same thing? Here is the code I have right no... |
I recently had an interview for a programming job and after the interview I was then asked to create a function with the following brief:
The Task:
Relating to pagination links: given a page number, a total number of pages, and an amount of 'context' pages, generate the appropriate pagination links. For example, with ... |
How to minimize the following code using java's features ... looking for some workaround with the switch-case statement
I've seen several question regarding switch-case design pattern / best practices but because I am new to java, I am having difficulties in implementing them.
Here is the code:
protected void readTree(... |
This is a specific case in merge sort. I'm trying to do a merge sort on an array that's created using the Java Integer class. My implementation is slow and therefore needs some modifications for better performance. I believe the process where I copy the original items to two new arrays over and over again is slowing... |
I would greatly appreciate the input of any gurus out there. I have recently begun learning JavaScript and then jQuery and jQuery-UI and have thought I would take a stab at writing my own jQuery-UI plugin, the result of which you can see here:
http://jsfiddle.net/ben1729/djA6G/ .
It's basically a pie chart into which y... |
I would like to know if there is a better/shorter/cleaner/resource saving method for this snippet of php code with codeigniter? Thanks.
$code = $this->uri->segment(3);
if (!$code) {
// validation
$this->form_validation->set_rules('code', 'PassCode', 'required|trim|max_length[100]|xss_clean');
// run valid... |
Got the following piece of code:
If boolFlag Then
With offer.Person1
entity.Birthdate = .BirthDate
entity.FirstName = .FirstGivenName
entity.LastName = .FamilyName
entity.Street = .StreetName
entity.HousNr = .House... |
I've written this little countdown script to count until the end of our school days.
Now, that was written quickly, badly remembering modulo from a few years ago, and I don't think that's very optimized.
I thought about updating only the seconds and check if it needs to update the minute too, etc. But it wouldn't be ac... |
I've built a JavaScript function returning the index of the nth occurrence of a substring in a string.
$(document).ready(function() {
var containingString = '.this.that.';
subString = '.';
var index = GetIndexOfSubstring(containingString, subString, 2);
});
function GetIndexOfSubstri... |
In order to create fast map/reduce processor for hadoop, I'm evaluating many languages. I'm learning python so I would like my python processor to go as fast as my perl processor.
So, for this question, the point is to increase the performance of simpleprocessor.py. To measure improvement, there is a benchmarking suite... |
Well, the questions is a little bit broader, so I'll assume that the basics is already defined:
Controller
FrontController
Controllers (plugin hooks, request/response object, view handler)
View
View (template, scripts, partials, helpers)
Model
Domain model objects
Domain model repository
Database abstraction layer... |
Do you see any unneccessary code, or code that can be deleted in here? Its not finished...
import random
import os
# Shortcut to clear the screen
c = 'clear'
# Info about the program
info = 'This game was developed in xCode, by Solomon Wise. He used Python 3.0.1 to build this awesome game'
os.s... |
I cannot understand how I can make two classes work together by passing variables between them.
During the last 5 days, I learned the basics of inheritance, singleton methods and eval methods. I even read about template methods, but since I have no programming background, I'm in no position to learn from other language... |
This behaves to an outside observer mostly like @property (copy), except it has the very nice property of automatically performing any side effects that may exist in remove<Key>AtIndexes: and insert<Key>:atIndexes:. If I'm going to have such side effects, this seems really handy (DRY!)--is there anything wrong with thi... |
As a little helper I recently had to write a code that solves the 1-D Euler equations. As it serves my purpose well I though others could make use of it as well. The homepage of the code can be found here, including a download containing the Makefile.
This version of the code is in this Github repository.
File gees.f90... |
There is some little program (using a Last.FM API wrapper) which gets the play count of 2 specific users every 5 minutes and appends the difference between these 2 numbers to log file.
Can you review that part of the code?
I think that using the <- operator so many times decreases the readability and simplicity of the ... |
I am learning Scala and FP (Functional Programming), coming from Java, OO and a strong imperative pardigm. I am now trying to implement a small puzzle solving project so I can get some deeper hands on experience with both Scala and FP.
So, I have the following Scala class:
class Bitmap2d(rowsByColumns: List[List[Int]])... |
I have some kind of high thoughput message handler receiving ordered messages. Now the task is - adding monitoring stuff in it in order to recognize wrong input messages, more exactly: it must notify about missed messages and just ignore the stale ones (with smaller order).
Due to high thoughput - it mustn't block.
So ... |
I have two columns representing a date and a time.
{dateproc: '2012-03-23', horproc: '2000-01-01 16:15:23 UTC'}
Both are read as a TimeWithZone by Rails. I need to combine them.
This is what I've done. It works, but it doesn't feel elegant, and it just doesn't seem readable.
date_time_combined = dateproc + horproc.se... |
Ever since I was a kid I wanted to understand how brute force programs work. I have not been able to make sense of any of the examples throughout the internet, so it became a personal challenge to make my own. Now that I have a couple Java classes under my belt, I realized I could tackle this problem with a linked list... |
I'm trying to learn how to structure my jQuery code better. I'm only about a week into jQuery so if something looks way off please tell me. I'm attempting to use object literals and it appears to work ok, but I am wondering if there is possibly a better way to structure my code.
var application = {
wrapper: $('#wra... |
I have written a web crawler. I hope anyone can help me make this code be more better.
This is the task to implement a web crawler in Python.
# Task:
# Write a crawler code by python
# for example:
# myspider.py -u www.google.com -d 3 -t 10 -l logfile -v log_level
# -d --- the depth of crawl
# -t --- the thread's... |
While I'm aware of various different means of checking if a variable is a Window object in JavaScript, I'm interested in writing a function that is more accurate and resilient.
For example, jQuery uses:
isWindow: function( obj ) {
return obj != null && obj == obj.window;
}
which will return an incorrect result for... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.