Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env node
var util = require( "util" );
// Create a linked-list and reverse it.
// This is just a rough bit of code to solve the problem.
// If I had more time I would maybe try a different algorithm
// where I switch the pointer as I walk to the end.
// Also I may change the members to be private.
util.puts( "Make a list and print it out!" );
#!/usr/bin/env node
var fs = require('fs');
var _ = require('underscore');
fs.readFile('area.json',function(err,data) {
var a = JSON.parse(data);
console.log(a.length);
var b = _.map(a,function(row) {
var o = new Object();
o.area = row.at4;
#!/usr/bin/env node
var a = require( "./tree" );
/*
* 1A
* 2A 2B 2C
* 3A 3B 3C
* 4A 4B 4C
* 5A
#!/usr/bin/env node
var util = require('util');
util.puts("Convert tree to query!");
var tree = {
type : "and",
left : {
type : "eq",
left : {
type : "property",
name : "City"
#!/usr/bin/env node
/*=========================================================
Break up a string of words with no spaces into a string of words with appropriate spaces.
=========================================================*/
var dictionary = {
'the' : 0,
'a' : 0,
'may' : 0,
@jesslilly
jesslilly / search-array.js
Last active August 29, 2015 13:56
Search a sorted array in js. O(log n)
#!/usr/bin/env node
var util = require("util");
util.puts("Search Array for value N.");
// This only took me 12 minutes to do on a white board.
// This has a complexity of O(log n).
// 0 1 2 3 4 5 6 7 8 9 10 11
var a = [ 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16 ];
var _indexOf = function(pos1, pos2, n) {
@jesslilly
jesslilly / stack.js
Created March 16, 2014 02:28
Stack with push, pop, and min all of complexity O(1). With unit tests.
#!/usr/bin/env node
/*
* Design a stack with a push, pop, and min method.
* Min returns the smallest element.
* All methods must operate in O(1) time.
* I implemented this with simple numbers, but I could enhance it
* to use objects with a comparator function.
*/
@jesslilly
jesslilly / Hello.groovy
Last active August 29, 2015 13:57
Just a little groovy exploration
#!/usr/bin/env groovy
// GROOVY STYLE!!!!!!!!!!!!!!!!
def a = new ArrayList<String>()
a.add("Hello")
a.add("my")
a.add("name")
a.add("is")
a.add("Jess")
@jesslilly
jesslilly / Cake.java
Last active August 29, 2015 13:57
Jetty, Jersey, Guice, JAXB Sample
// See http://blog.bdoughan.com/2011/06/using-jaxbs-xmlaccessortype-to.html
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
@XmlRootElement
public class Cake implements PlainTextBean {
private String type;
// The getter is up here since the order of fields affects the order in the
// xml.
public String getType() {
return type;
@jesslilly
jesslilly / wordRepeater.cs
Created March 28, 2014 14:48
Just a little C# for a sample problem we white board-ed yesterday
using System;
public class Program
{
public static void Main()
{
Console.WriteLine(wordRepeater("Hi! ",10));
Console.WriteLine(wordRepeater2("Hello! ",10));
}
public static String wordRepeater(String name, int n) {