Skip to content

Instantly share code, notes, and snippets.

View jenglert's full-sized avatar

James Englert jenglert

View GitHub Profile
#Custom SQL
execute "create or replace view vw_feed_parse_stats as (select feed_id, dayofyear(parse_start) dayofyear, feed_items_added from feed_parse_logs group by dayofyear(parse_start), feed_id);"
execute "alter table feed_item_categories add constraint category_fk foreign key (category_id) references categories(id);"
change_column :feed_item_categories, :feed_item_id, :integer
execute "alter table feed_item_categories add constraint feed_item_fk foreign key (feed_item_id) references feed_items(id);"
execute "alter table feed_items add constraint feed_fk foreign key (feed_id) references feeds(id);"
execute "alter table feed_parse_logs add constraint fpl_feed_fk foreign key (feed_id) references feeds(id);"
protected RedirectManager createRedirectManager(final boolean captureOutput) {
final String productServiceUrl = "http://localhost:7501/product_service/1.0";
final String captureDir = "./src/test/resources/json/" + getClass().getSimpleName() + "/product_service";
Sales salesClient = SalesFactory.instance(new MapConfig(new HashMap<String, Object>() {{
if (captureOutput) {
put(SalesFactory.PRODUCT_SERVICE_URI(), productServiceUrl);
put(SalesFactory.CAPTURE_DIR(), captureDir);
}
else {
@jenglert
jenglert / gist:5960901
Created July 9, 2013 20:19
Scala handwriting analysis
import scala.actors.Future
import scala.actors.Futures
import java.util.concurrent.atomic.AtomicInteger
object Main extends App {
val start = System.currentTimeMillis()
val sample = scala.io.Source.fromFile("src/main/scala/digitssample.csv")
private[bulk]
def prepareEmailRequestBody(to: String, from: String, subject: String, body: String) = {
List(
"To: " + to,
"From: " + from,
"Subject: " + subject
).mkString("\r\n") + "\r\n\r\n" + body + "\r\n\r\n-----ET-----386a7a00-8f73-11e3-a781-775966473e19"
}
craftybeaver@craftybeaver-All-Series:~/Code/node-gtfs$ cd jims-downloads/ && rm -rf * && cd ..
craftybeaver@craftybeaver-All-Series:~/Code/node-gtfs$ node scripts/jimTest.js
Download successful
craftybeaver@craftybeaver-All-Series:~/Code/node-gtfs$ ls -lsah jims-downloads/
total 88K
4.0K drwxrwxr-x 4 craftybeaver craftybeaver 4.0K May 31 13:49 .
4.0K drwxrwxr-x 10 craftybeaver craftybeaver 4.0K May 30 22:31 ..
72K -rw-rw-r-- 1 craftybeaver craftybeaver 69K May 31 13:49 latest.zip
4.0K drwxrwxr-x 3 craftybeaver craftybeaver 4.0K May 31 13:49 __MACOSX
4.0K drwxrwxr-x 2 craftybeaver craftybeaver 4.0K May 31 13:49 PATH_GTFS_20111109
"trip-step":{
"description":"A step in a trip",
"fields":[
{
"name":"departure",
"type":[
{
"name":"stop",
"type":"stop"
},
import java.util.Date
/**
* Usage:
*
* val someFun: String = SimpleCache({ () => somethingExpensive }, 15.minutes).cachedFun
*
* val theValue = someFun()
*/
class SimpleCache[T](
scala> import scala.concurrent._
import scala.concurrent._
scala> import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.ExecutionContext.Implicits.global
scala> import scala.concurrent.duration._
import scala.concurrent.duration._
scala> val f1 = future { Thread.sleep(10000000000l); "a" }