Skip to content

Instantly share code, notes, and snippets.

View iamnoah's full-sized avatar

Noah Perks Sloan iamnoah

  • Tulsa, OK
  • 12:45 (UTC -06:00)
View GitHub Profile
@iamnoah
iamnoah / index.js
Created December 1, 2009 23:56
Simple node.js webserver with logging. Serves whatever files are reachable from the directory where node is running.
/*
* Copyright (c) 2010 Noah Sloan <http://noahsloan.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@iamnoah
iamnoah / DwrGormConverter.java
Created December 8, 2009 20:42
DWR converter for Grails ORM classes. Uses the hasMany map to determine the type of collections so we can convert them inbound.
package com.noahsloan.grails.dwr;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Map;
import org.directwebremoting.convert.BeanConverter;
import org.directwebremoting.convert.CollectionConverter;
import org.directwebremoting.extend.InboundContext;
// Church Encoding in Groovy
// Translated from http://meta-meta.blogspot.com/2007/06/church-code.html
def partial(c) {
return { a -> { b -> c(a,b) } }
}
T = partial { a,b -> a }
F = partial { a,b -> b }
def toBool(f) {
// wait until the user pauses at least 500ms before doing validation
var timer;
$('.whatever').keypress(function() {
if(timer) clearTimeout(timer);
timer = setTimeout(validate,500);
});
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
/**
* Dear Android, why do I have to write this class myself? Is this to discourage SQL use?
*/
public class QueryBuilder {
private String[] columns;
private boolean distinct;
private String table;
<activity android:name=".MyAppRegisterAccount"
android:label="@string/addAccount" >
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="myApp" />
</intent-filter>
</activity>
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(
"http://gowalla.com/api/oauth/new?redirect_uri=myApp://register&client_id=12345"));
startActivity(intent);
<div id="results">
<forEach in="${results}">
<div class="result">${result}</div>
</forEach>
</div>
$('#results').load('/renderResults?page=2');
<div class="product" >
<g:link action="show" id="${productInstance.id}">
<h3>
${productInstance.name}
(${productInstance.id})
</h3>
</g:link>
<div class="image">