instruction
stringlengths
71
95.1k
Let's keep this simple. Input: - abc - def - ghi Desired output (whitespace optional): <ul> <li>abc</li> <li>def</li> <li>ghi</li> </ul> Current code: $output = preg_replace_callback( "((^- (.*)$\r*\n*)+)m", function($m) { return "<ul><li>". implode( "</li><li>"...
I guess I made the mistake of creating UIImage *image1 to UIImage *image11. Can an one advise me on how to improve it? +(NSArray *)stampImages{ UIImage *image1 = [UIImage imageNamed:@"abcd.png"]; UIImage *image2 = [UIImage imageNamed:@"fron.png"]; UIImage *image3 = [UIImage imageNamed:@"amule.pn...
I've made a method, which inserts a new query parameter, when the value of a select changes, then reloads the page. I've had enough of URL jQuery hax, so I figured it would be a great idea to put the query parameters in an array, and manipulate it that way. I'm a little unsure whether or not this is the best way of doi...
I need to draw tabulated data given a header as list and rows as list of lists This is what I came up with. I wouldn't say that I like it much. Could you please have a look if it can be done better (I am sure it can) and generally point to any error and possible optimization. Maybe someone has done exact same thing bef...
I am implementing a list structure in C. My current function I am working on is a destructive append function that takes two lists and appends the second one onto the end of the first. Right now, it appears to be working without runtime errors and memory leaks and I think I have all my cases covered, but when I submit ...
It's very popular to see code like this: bool DoSomething([some arguments]); You can't understand the result of this method by looking at its name (it could actually be a void). What's the best approach to refactor such kind of methods? What I have in mind is something like this: void DoSomething([some argumens],out ...
I tried to implement a naive brute-force Sudoku solver in Haskell (I know there are loads of good solutions already) and I'd like some reviews from you experts. The solver is very simple and it uses the List monad to try all the possible combinations. It's not optimized at all, but it takes an awful lot of time to solv...
I would like to optimise this code. It seems a bit verbose, particularly with the 'elseif' that doesn't do anything. This code either: takes a plain text password, generates a salt, and returns them both OR takes a plain text password and a salt with which to encrypt the password, and returns them both (even though th...
K&R 1.9 exercise: Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank. Is this correct and proper code? Could I have put c and inspace on a single line? #include <stdio.h> int main(void) { /*initializes c and inspace. */ int c; int inspace; ...
I came up with this question. Let A and B be two N bit numbers. You are given initial values for A and B, and you should write a program which processes three kinds of queries: set_a idx x: Set A[idx] to x, where 0 <= idx < N (where A[idx] is idx'th least significant bit of A.) set_b idx x: Set B[idx] to x, where ...
This is a solution I wrote for a programming puzzle which I believe and I'm sure is correct, but for two of their test cases the online judge gives me 'Time Limit Exceeded' only by a few 100ms! I've tried a lot to knock those few ms out, but no luck. For a time limit of 3s I've submitted solutions which ran in 3.13127s...
I am working on a fluent interface for exception handling. Here's how it looks : On<NullReferenceException>() .First.LogTo("errors") .Then.TranslateTo("null object"); On<FileNotFoundException>() .First.Translate(excpetion => excpetion.Message) ...
I have got code here which I have tried to refactor on my own - but do any of you experts feel that it needs to be refactored more? What are the points should I cover? I would appreciate it if some one gives me some points on this code review. package com.vilant.app.outbound; import java.util.ArrayList; import java.ut...
I'd like to know if I'm doing this properly. Basically, I have 3 models: Student, Course, StudentCourse. I'm running into problems when I'm trying to sign a student up for a course (I've removed a lot of the non-important code - auth component, view, etc). // Courses Controller (ie: /courses/signup/6) class CoursesCon...
There are many problems on the Internet that require you to find prime numbers, so I decided to write a set of functions to find them. I used the Sieve of Eratosthenes for generating the primes as it was fast and easy to implement compared to other algorithms. However, I'm wondering if my code, rather than my method, i...
I've decided to write a small function for rounding decimals because it'll most likely be useful later on. However, my current attempt seems pretty inefficient. How would one best optimize such a function? #include <cmath> double getRemainder(double a, double b) { int quotient = (int)(a/b); double remainder = a...
I have a couple of nested objects, where A is always a part of B. May I use the following code to access owner's properties and methods? function A( owner ) { this.value = function () { return owner.value() + 1 }; } function B() { this.value = function () { return 1; }; this.a = new A( this ); } var b = new B()...
Is there any simpler way to find all elements in a list that are equal to the max element. List v = [ 1,2,3,4,5,5 ] def max = v.max() def maxs = v.findAll { it == max } Thanks!
I'm building a rails app which uses a has many through relationship between three models. I have a Recipes model and an Ingredients model. The join table is called rec_items and it contains a few additional data fields. So, recipes have_many ingredients through rec_items, and ingredients have_many recipes through rec_i...
We have a Debian Squeeze server where we upload files through SFTP, and I wrote this script to automatically compress uploaded files. The script is scheduled through a cron job in an unprivileged user's crontab. As of now, the script works and does its job. But I'm pretty novice to Bash scripting, and I'm wondering if ...
Everything works, i just want to know if i can change the way the xml tags are retreived. This way seems a bit bulky - but i could be wrong. Thoughts? var d = 0 $(".timeline").children().eq(d).addClass("active") // default traverse function to buttons, inject node prev.data("node", array.length-1) ...
Is there any chance to make this script run faster?The script goes through each number from a to b, and checks if it holds 1, if it holds 2, if it holds 3, if it holds 1 and 2, if it holds 1 and 3 and if it holds 1, 2 and 3. Then it saves all results. unsigned long long a, b, f; a = 1; b = 100000000; int f...
I am trying to solve the puzzle RINGING IN THE NEW YEAR. Start at 2011. By moving through the maze and doing any arithmetic operations you encounter, exit the maze with a result of 2012. You may pass through an operation several times, but not twice in a row. 2011 2012 My solution is to construct an breadth first s...
I've been learning Python and in order to put my skills to the test, I created a simple program that returns the sum of all of the multiples of number num up to 1000. def get_multiple_sum(num): sum = 0 i = 0 for i in range(0, 1001): if i % num == 0: sum += i else: con...
public sealed class LinkXPathRepository : ILinkXPathRepository { private static readonly ILog _log = LogManager.GetLogger(typeof(LinkXPathRepository)); internal ILink Parse(Uri endpoint) { if (endpoint == null) { throw new ArgumentNullException("endpoint"); } str...
I am creating an application which needs to validated user input to ensure the words being entered are real words. What improvements if any can I make? class MyDictionary { Vector<String> words = new Vector<>(); public MyDictionary() { URL url; try { url = new URL("http://www.examp...
public class Item { /*...*/ } public class Model { /*...*/ } public interface IConventionInstanceSelector { IConventionInstance Select(Item item); } public interface IConventionInstance { void ApplyTo(Model model); } public interface IConvention { bool IsMatchedBy(Item item); IConventionInstance CreateInstan...
As you can see I have to populate the ViewModel with the List of Tags so that the dropdown can have all the options for the user to select. And I have to do this 2 times for the Create Action and 2 times for the Edit action. [Authorize] public ActionResult Create() { var tags = from i in _articleService.GetAllT...
I've re-written my old pagination class into something a little cleaner, and also added PDO support (The prev version was mysqli only). I'd like to clean it up even more if it's possible, does anyone have any pointers? Here's the class: <? class paginate { /** * Array of options for the class * * ...
My disgusting list comprehension in the return statement is quite a headful. """Hopefully this function will save you the trip to oocalc/excel. """ def rangeth(start, stop=None, skip=1): """rangeth([start,] stop[, skip]) returns a list of strings as places in a list (1st, 2nd, etc) >>> rangeth(4) ['0th', '1st',...
I have this code: lengths = [] lengths.append(len(self.download_links)) lengths.append(len(self.case_names)) lengths.append(len(self.case_dates)) lengths.append(len(self.docket_numbers)) lengths.append(len(self.neutral_citations)) lengths.append(len(self.precedential_statuses)) Unfortunatel...
For a while now, our team has been doing peer code reviews of all submissions. As we've learned, everyone has different styles and going forward, all of us see a need to converge at some kind of tribal/team style so that the code looks consistent and we don't spend time in code reviews arguing one style vs. another. Fo...
I am diving deeper into JavaScript and starting to learn more about prototypes and simulating classes etc. I am used to working with the Module pattern and would like to try and combine this pattern along with working with prototyping into an own little framework (purely for learning purposes). I have devised a little ...
I'm trying to get rid of some of the horrible nested loops in the following code. Essentially is moving TDs to top rows based on whether the current row has the current cell. You can see the execution here: http://jsfiddle.net/Jq8sk/ How can I clean it up and avoid this level of depth. Any help is appreciated. var trs...
I want to refactor this code into js object, but not sure how. How should I do it? I initialize an object for every item in the DS.data_per_folder array. how can I define it in a higher level? Where should I init it then? .. DS.data_per_folder[CurrentContextMgr.current.folder.attr('id')] = { a...
We have a large number of defined constants that are used as enum values when storing records. We convert the int values into language for our web portals. This was very straightforward when only dealing with one language, but now are tasked with making the portals support multiple languages. The functions doing the va...
This code is the basic structure I use for coding plugins. It's pretty standard with the settings extended and the each loop. However, now I'm working on the best way to provide setters/getters. For example, I may want to do something like: var sp = $("#container").wScratchPad(); alert(sp.wScratchPad('size')); sp.wS...
I am working on a log in form. Basically, my code searches for a user name, then retrieves the hashed password that is related to that account. It then converts that string hashed password then converts it to its real value. But my issue here is that it is messy. private void userVerification() { //Instan...
I'm newly working with CodeIgniter and PHP. I wrote a category structured 'pages' code with listing pages as multilevel list or indented select box. page page_lang ------------------------------------- ---------------------------- id_page | id_menu | id_parent | level ...
I have a text file in a specific format that I pass as the input of my program. I then want to write the output back to that same file. The format is as follows: Input1: 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 ----------------------------------------- Input2: 1 2 3 8 5 6 7 1 2 3 9 5 6 7 1 2 3 10 5 6 7 ---------...
I'm shooting blind when it comes to coding I'm reading and coding a lot but no one ever looks at my code so it wold be good if someone could look over the project at github and see if I have any major design issues or other bad practice issues that I must work on. The Github project is here: https://github.com/glennwiz...
I've made a little function to eliminate continuous duplicate from a std::vector. I have to use C++03. For example, if a vector of ints is composed of: 1,1,2,3,,3,1,1,2 my function should return 1,2,3,1,2. I've tried to use templates (I've just began to use c++) and made it as fast as possible! template<class T> vector...
The puzzle is: The deck contains 21 unique numbers The numbers should be laid up in rows of 7 (3 rows in total) ask the player to memorize a number to start the game once the game starts, rearrange the numbers in random in all rows. ask the player to select the row the number is in. once the player selects, rearrange...
This is a function that reads until EOF and reallocs as it goes. char * read_to_end(int fd, int *bread) { ssize_t size, nread, rc; char *buf, *tmp; nread = 0; size = MINLEN; buf = malloc(size); while ((rc = read(fd, buf + nread, size - nread))) { if (rc < 0) { if (errno == ...
Subject I have to iterate through a collection of objects (in this case IGrouping<string, SupplyDemand>). So I could do this easyly using a query with LINQ. Code public IEnumerable<string> getParentPegs(IGrouping<string, SupplyDemand> data) { IEnumerable<string> query = from d in data ...
boost::thread_group doesn't automatically clean up contained threads when they end, so I needed something like that described in this boost-users list post. However, in my opinion that code is not safe, because there's no guarantee that tp will be .reset before the thread reaches its th_ptr.get() call. After an initial...
How could I improve the following code that runs a simple linear regression using matrix algebra? I import a .csv file (link here) called 'cdd.ny.csv', and perform the matrix calculations that solve for the coefficients (intercept and regressor) of Y = XB (i.e., $(X'X)^{-1}X'Y$): import numpy from numpy import * impo...
I am nearly done developing my pong game (made in HTML5 / JavaScript), and I would like some constructive criticism on my code. Full code Initialization: var play2 = false; function init() { //setup canvas canvas = document.getElementById("canvas"); ctx = canvas.getContext("2d"); ctx.canvas.width = window.innerWidth; ...
I'm attempting to make a nice-looking UI where a user views current items in a list and can add/edit/delete. For each item, i've included an edit and delete link, but I'm trying to do so in such a way as to gracefully degrade/progressively enhance: <li>My Course Name <div class="tools"> <a class="tool" href="/e...
This is the program I was given, it searches a large array for a max value: import java.util.Date; import java.util.Random; class FindMax { private static final int N = 256 * 1024 * 1024; public static void main(String args[]) { assert(N > 0); int array[] = new int [N]; assert(array ...
Q: Please comment on the usage of structures and structure assignment operations in C I am working on converting a MATLAB program to C using BLAS and LAPACK for linear algebra support. The MATLAB code uses cell arrays. I created a Matrix datatype and a Cell data-type. A section of the header file/implementation: #defin...
I have the following C++ function which I'd like to speed up, if possible. This program will have many different users, so parallelization is not really an option. The C++ function is wrapped by C code and then called from R, using: R CMD SHLIB -o jonckterp.so wrapper.cpp inside.cpp from the command line, then: dyn.lo...
I tried extending ForwardingMap because I wanted to intercept all calls to put/putAll/remove/clear and also intercept calls on Iterators of KeySet/EntrySet/Values such as remove/Map.Entry.setValue() etc. It took me a while to figure out what methods to override and how - especially the entrySet() method. Some of the Ja...
I wrote up the following script for the realtime synchronization service, MobWrite, to be used with the browser-based editor, CodeMirror: // Based on MobWrite's code for TextBoxes /*Instructions for use: Set an 'id' property for your codeMirror obj import this code after you import MobWrite. */ //Licence: http://creat...
Context I have a project which has an importation module to import content of Excel files. Originally, importation was possible only for .xls file (< 2003) through Interop assemblies through a pretty ugly non-modular architecture. But there was a need to support importation of .xlsx files. I have refactored the mod...
I use 3 lists to store field name, its value and score. If field name is already added to according list, then I just need to update other 2 lists. If it is not there, then I need to add it. I do the following: user = User.get_by_key_name(user_key_name) if user: field_names = user.field_names field_values = use...
I am trying to make a page background for my website. Is this a good way to do it? This is my HTML: <div id="page-background"> <img src="images/website/background.jpg" width="100%" height="100%" alt="Wallpaper" /> </div> And this is my CSS: #page-background { position: fixed; top: 0; left: 0; width...
I use this method to extract table name and field name from formula. public List<string> ExtractFieldsFromFormula(string formula) { List<string> formulas = new List<string>(); formulas.AddRange(formula.Split(new char[] {'{', '}'}).Where(f=>!f.Contains("+") && !f.Contains("-")&&!f.Contains("/")&&!f.Contains("*")...
I'm coding a jQuery plugin that basically checks if a set of checkboxes groups have at least x options checked. A checkbox group is named as name=group[]. You'd call the plugin like: $(':checkbox').checkpass({min: 1}) // Make sure at least one checkbox per group is checked I've been working on this piece of code for a...
I've got this MVC pager helper and it's working exactly as expected. Is there a prettier or more performant way to build this out? Also, I know that the StringBuilder might not be the best way. Would a TagBuilder be a better approach? <Extension()> Public Function Pager(helper As HtmlHelper, urlPr...
Just after a bit of feed back or peoples ideas on which practice is best. I currently have a method but am unsure of the best way to approach it from a readability point of view or even from best practices point of view. Or perhaps it doesn't really matter at all and they are all fine? My three options I explored we...
Are there alternative (better) ways to factor out the common parts other than my use of abstract base class? I find myself following this pattern lately and it makes sense when I code it but sometimes leads to code that is particularly susceptible to obfuscation as time goes by (i.e. I come back to it later and have a...
I am trying to figure out how to DRY up this code: nino = "QQ" 3.times { nino += Random.rand(10..99).to_s} nino += ("A".."D").to_a.sample I am trying to generate a sample National Insurance number starting with QQ, six digits and then ending with A, B, C or D.
I instantiate GtkInfobars a lot in my GTK+ application in order to communicate with the user. There are various types of infobars, depending on the message. Basically, any infobar could be a combination of the 4 different infobar message types and 5 different icons (which are painted on the left side of the infobar). I...
I have a function that works with a database. If something wrong happens I want to throw an exception, and I also want that all resources have to be closed. Is this a good way to do it? There is a better way to do it? public Strint getStuff(Integer id) throws Exception { String result = ""; Connection connec...
My rating controller: def rate @ip = request.remote_ip @konkurrencer = Rating.where(:IP => @ip, :konkurrencer_id => params[:id]) if @konkurrencer.empty? params[:kon][:IP] = request.remote_ip params[:kon][:konkurrencer_id] = params[:id] @konkurrencer = Rating.new(params[:kon]) @konk...
I am still a newbie at coding in general. Over the years the amount of programming that I have done in PHP has always been procedural. I am now working on a project for my course, and was hoping to use it as an opportunity to learn OOP since I come across it everywhere. I am still trying to really get my head around OO...
I am using Python 2.6.5 and am trying to find the fastest way to print out the contents of a .gz file. It's my understanding that prior to v2.5, zcat was much faster than gzip (see here)....I guess that has changed (at least according to a comment in that post)? I have unzipped a 2.4MB .gz file 3 ways and they all seem...
I am still learning to develop my skills in OOP. It uses a combination of the factory and its real singletons? As I did more research, I have realized this design pattern is bad because of global state and it is hard to test. I can't figure how how to convert this OOP to Dependency injection? Section Class class Sect...
class Submission < ActiveRecord::Base def get_status_css() if self.status == IN_PROGRESS "info" elsif self.status == FAILED "error" elsif self.status == COMPLETED "success" else "warning" end end end Submission is a model class and it has a method that returns css var...
I wrote this code in Python/ Scrapy for data extraction. It works fine for me, but I am a newbie in Python, so any suggestions for code optimization would be welcome. def parse(self, response): hxs = HtmlXPathSelector(response) item = GenesishcsItem() item['graduate_education']=[] item['medical_school'...
I have created a simple palindrome function that works only on single words. It is working as intended, but I feel that it definitely needs improvement. def is_palindrome(w): if not isinstance(w, str): return "ERROR: input is not a string." elif len(w) > 2: if w[0] == w[-1]: while ...
I've been searching for a suitable plugin for an input mask for a time field. There are some inherent difficulties with masking a time input, while giving the user the most flexibility. I have tried to recreate what Google Calendar uses for their time inputs, minus the drop down select. What I've made seems to work, b...
Working through Day 2 of Ruby in "7 Languages in 7 Weeks" - the answer to the second question seems acceptable, the first one feels quite wrong. Any suggestions? Print the contents of an array of sixteen numbers, four numbers at a time, using just each. group = 0 (1..16).each do |x| print x group = group + 1...
One hassle with working with mobile websites is inconsistency between how the device reports the screen's width and height. James Pearce wrote a fantastic article about the headaches that come with detecting screen width and height from JavaScript. Furthermore, not all mobile devices support window.onOrientationChang...
I have a tv show I created a MySQL database for. I am trying to get my code to group and order correctly the seasons and episodes within their respective season. Current Code if (!($result = mysql_query("SELECT season_num, sub_season_num, esp_num, title, descrip FROM season ORDER BY season_num, sub_season_num", $link))...
I'm very new to jQuery and JavaScript in general but decided to develop my own code rather than use 3rd party plugins as I really need to learn the language. Would anyone be so kind as to review my code? I wanted a relatively simple project to start with and decided to build the jQuery front end to a PHP shopping cart ...
I've been helping out a student with an exercice, typed this up rapidly and thought it would be the ideal opportunity to improve my own programming style and approach to problem solving. In this exercice a grid represents one of those slide puzzles. The patterns have been replaced by numbers. The zero represents the mi...
I have a unit test method that looks like this: ... 113 CPPUNIT_ASSERT( !m_pInputFilter[0]->SendPacket() ); 114 115 CppUnitUtil::CUnitTestTimeline::GetInstance().Advance( 1, CppUnitUtil::Seconds ); 116 CPPUNIT_ASSERT_NO_THROW( m_pTimer->Fire() ); 117 118 CPPUNIT_ASSERT_EQUALS( 1, m_pOutputFilter[0]->RecievedPackets() ...
I have spent all night whipping up this recipe. It's my first Python decorator. I feel like I have a full understanding of how decorators work now and I think I came up with a good object-oriented algorithm to automatically provide memoization. Please let me know what you think. I made a few quick changes after pasting...
How would you refactor this method to make it more performant? If you have refactored the code you need to prove the performance gain in numbers to get the solution :) public static T Find<T>( this IEnumerable<T> source, Func<T, IEnumerable<T>> childrenSelector, Predicate<T> condition) { T t = default(T...
struct iovec is defined in <uio.h> by the following way: /* Structure for scatter/gather I/O. */ struct iovec { void *iov_base; /* Pointer to data. */ size_t iov_len; /* Length of data. */ }; Now I do ugly casting from const void* to void*: int send_frame_once( int fd, const struct iovec* iov, size_t io...
I'm sure this is wrong, but I can't think of a cleaner way to do this. I'm looping through a set of column to identify which column identifies the company name, the test is true if one of a large number of tests are true. if (heading.ToLower().Contains("organisation") || heading.ToLower().Contains("business...
I'm trying to learn C++ with Eigen. Here's my attempt at computing Mahalanobis distances of a set of points x with respect to a sub-matrix xs. The aim of the project is to turn an R code describing a statistical procedure in C++ (and in the process to learn a bit about numerical computing in c++). Some of these funct...
For flexing my newly acquired Django & Python muscles, I have set up a mobile content delivery system via Wap Push (Ringtones, wallpapers, etc). The idea is that a keyword comes in from an sms via an URL, let's say the keyword is "LOVE1" and the program should search if this keyboard points to a Ringtone or an Image. ...
I have been wondering this for a while. Take this example: <?= Zend_Registry::get('translate')->_('translate me!'); I have my views cluttured with such code. My coworkers also complain often that its a lot to type juste to get translation and since it is repeated all over the place it gets tedious. Some of them would ...
This project is based on trivia (question/answer quiz). The scenario is simple but I have to improve/optimize my query using these tables: $query=$this->db->query("SELECT q.`id`, q.`topic_id`, t.`topic`, q.`question`, GROUP_CONCAT(a.`answer`) AS `answer`, GROUP_CONCAT(a.`is_correct`) AS `is_correct`, GROUP_CONCAT(a.`i...
I'm new to Java and this is my first program. I'm trying to verify that my thought processes are good. Let me know of any improvements infor the code, whether it's too few/too many comments, poorly structured code, etc. import javax.swing.*; import java.math.*; import java.util.*; class Root { public static void main(...
I came across this thread and I am working on the same problem. My best algorithm passes 6/11 cases while the algorithm in the other thread does indeed pass 8/11 cases. Running time trials with random input my algorithm is significantly quicker (8 to 12 times depending on input) then the one in the other thread. So I a...
My code will, from a web-gui, generate Vash images. This currently involves making a call to a local binary, java. I'm wondering, if I've taken reasonable measures against this being exploited by a malicious user, or not. The code will be used in several different places, by several different administrators, meaning bo...
I want to design API which could handle XPATH input from a user. I currently model the XPATH input in the following way: public interface ICondition { String getConditionString(); } public class XPathCondition implements ICondition { private Class<? extends XPATHFunction> clazz = null; private Operator o...
This code is very simple, but it is intended as an experiment in the relative performance of mutexes/CAS on different platforms. The latest version can always be found at: https://github.com/alexdowad/showcase/blob/master/ruby-threads/concurrent_stack.rb It comes with a built-in benchmarking script. Please try running ...
I have the following solution structure. This is a business domain (for an amount transfer operation in bank account) which will be called by a WCF service. Is the solution structuring correct? Data Acess Layer does not create domain objects. It just pass database record wrapped in another simple object (DataEntities...
This is the first piece of code I wrote on my own. I tried to use everything I know, like functions, loops and variables. Is it good or could it be simpler? Please be hard as you can be with me because I feel my programming knowledge is quite poor and I end up using Google for solving my problems. // RPS.cpp : De...
I'm working on some code that deals with mangled C++ function names. I'm displaying these to the user, so to help with readability of some of the really long C++ template class/function names, I'm removing some of the template arguments based on how deeply nested the template argument is. The code below works fine, but...
I have two more methods the same as this except that they query a different table. Is there another way to know if the result of the query is null? The hasher.CompareStringToHash() method is not allowed to have a null value. If it's not null, it proceeds to an else condition, and inside that it checks if the encrypted ...
I'd like to get input on a F# actor that coordinates receives around a blocking message buffer. The actor is a piece of code that continuously tries to fetch messages from Azure Service Bus. (* Copyright 2012 Henrik Feldt Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except i...
As I thought about this question on SO, I realized that I wanted to implement either a string trimmer or a trimmed string inputter. This is what I came up with, but I have a nagging feeling I could have done better. Would you critique this, please? #include <string> #include <iostream> #include <sstream> #include <cas...
I'm building a GWT application for GAE, using JDO for Datastore access. I use and Entity class for data mapping, so it contains lots of Persistence annotations: @PersistenceCapable(identityType = IdentityType.APPLICATION) public class AppointmentEntity implements Serializable { private static final long serialVers...
My goal in the method is to write a simple clustering program that determines if a clustering document is valid based on these rules: All clusterings start with < and end with >. Every start clustering <something> must be followed (eventually) by an end clustering </something>. Clusterings must be properly nested as f...