Skip to content

Instantly share code, notes, and snippets.

Marc Esher marcesher

View GitHub Profile
package edu.gmu.mut;
import java.util.ArrayList;
import java.util.Calendar;
* Class Account represents an immutable customer account.
public class Account {
marcesher / BadObject.cfc
Created Jan 12, 2012
cfc with no var scoping
View BadObject.cfc
component output="false"{
function loop1(){
x = 1;
for( x = 1; x LTE 100; x++ ){
writeLog("x is #x#");
return x;
marcesher / gist:1662639
Created Jan 23, 2012
Synthesizing functions in javascript... practical applications?
View gist:1662639
From David Laing & Greg Malcolm's excellent javascript koans. I'm wondering: What are practical uses cases for this function synthesizing in javascript, where this approach would be preferable to all other possible approaches:
it("should use lexical scoping to synthesise functions", function () {
function makeIncreaseByFunction(increaseByAmount)
var increaseByFunction = function increaseBy(numberToIncrease)
return numberToIncrease + increaseByAmount;
marcesher / eff_you_var_scope
Created Feb 25, 2012
How many concurrent requests does it take to get into the throw?
View eff_you_var_scope
<cffunction name="getArtist" output="false" access="public" returntype="any" hint="">
<cfargument name="id" type="numeric" required="true"/>
<cfquery datasource="cfartgallery" name="artist">
select *
from artists
where artistid = <cfqueryparam value="" cfsqltype="cf_sql_integer"/>
marcesher / ChatService.groovy
Created Aug 20, 2012
websocket chat example
View ChatService.groovy
class ChatService {
static transactional = false
static atmosphere = [mapping: '/atmosphere/chatty']
marcesher / ChatService.groovy
Created Sep 4, 2012
websocket broadcaster example
View ChatService.groovy
class ChatService {
static transactional = false
static atmosphere = [mapping: '/atmosphere/chat']
View ZipCodeService_method.groovy
def populationByState(){
return zipcodes().aggregate(
[ $group :
[ _id : [ state : '$state', city : '$city' ], pop : [ $sum : '$pop' ] ]
[ $group :
[ _id : '$_id.state', avgCityPop : [ $avg : '$pop' ] ]
[ $sort: ['avgCityPop' : -1] ]
View famine.sql
During the great alphabet famine of two thousand aught six, column names were abbreviated to near-non-readability. In order to automate tests of [newsystem] reports against [oldsystem] reports, we're retaining those column names here. You're welcome.
marcesher / state_is_a_bug.txt
Created Nov 9, 2012
State Is a Bug : Questions
View state_is_a_bug.txt
Joe, thanks for responding.
I'm most interested in what are perhaps pedestrian issues, but they're issues (for me) nonetheless. You mentioned "outsourcing" session management... where can I read more on that?
Take the simple case of: I'm a user on your system. I'm logged in. I'm doing things. The server I'm on disappears while the screen I'm reading is currently loading.
What happens? Do I see an error? Am I sent to a new machine, with all my session state in tact, and the screen I was reading simply reloads?
Or take perhaps a different architecture where a machine isn't brought down until all its users have been successfully moved to other servers. For example, perhaps our configuration is such that we have N instances, and we do a rolling code push to those instances. User A is on Server 5, which has the old code. We need to get that user to Server 2, which has the new code, along with all of his state. Once all users are off of Server 5, the deploy then moves to Server 5 as well and then Server 5 is b
marcesher / classpath.xml
Created Nov 29, 2012
database migration automation example
View classpath.xml
<!-- jtds.jar, used to connect to SQL Server, is in 'lib' -->
<path id="project.classpath">
<fileset dir="lib">
<include name="*.jar" />
You can’t perform that action at this time.