Skip to content

Instantly share code, notes, and snippets.

View agibsonccc's full-sized avatar

Adam Gibson agibsonccc

View GitHub Profile
@agibsonccc
agibsonccc / index.html
Created December 20, 2011 19:36 — forked from abeppu/index.html
candlestick charts using d3
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.25.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.time.js?1.25.0"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
</head>
<body>
<div id="chart"></div>
@agibsonccc
agibsonccc / index.html
Created January 12, 2012 04:57 — forked from abeppu/index.html
candlestick charts using d3
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.25.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.time.js?1.25.0"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
</head>
<body>
<div id="chart"></div>
@agibsonccc
agibsonccc / GenericManager.java
Created August 12, 2012 01:07
Generic Manager Hibernate 4
package org.agibsonccc.genericdao;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@agibsonccc
agibsonccc / appconfig-hibernate.xml
Created August 12, 2012 01:46
A sample spring hibernate 4 configuration
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sec="http://www.springframework.org/schema/security" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
<!-- Component scanning -->
@agibsonccc
agibsonccc / index.html
Created February 10, 2013 23:31 — forked from wrr/index.html
<!DOCTYPE html>
<!-- By Jan Wrobel (http://mixedbit.org) -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Random walk</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
from fabric.api import env, run, sudo, local, put
def production():
"""Defines production environment"""
env.user = "deploy"
env.hosts = ['example.com',]
env.base_dir = "/var/www"
env.app_name = "app"
env.domain_name = "app.example.com"
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name }
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.AutoDetectParser;
import org.apache.tika.parser.ParseContext;
package com.example.cache;
import net.sf.ehcache.CacheException;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import net.sf.ehcache.event.CacheEventListener;
final class NotNullCacheEventListener implements CacheEventListener {
public static final CacheEventListener INSTANCE = new NotNullCacheEventListener();
@agibsonccc
agibsonccc / gist:8230583
Created January 3, 2014 01:03
Netflix genres
Array.prototype.pick = function () {
return this[Math.floor(Math.random() * this.length)]
};
function randInt(a, b) {
return Math.floor(Math.random() * (b - a + 1)) + a
}
function chance(a) {
return randInt(0, 100) < a ? !0 : !1
@agibsonccc
agibsonccc / user_dataset_profit_curve.py
Created April 26, 2014 22:45
Convert data frame for profit curve
def transform_column(df,column_name,fn):
"""
Transforms a column with the given function
"""
df[column_name] = df[column_name].apply(fn)
def vectorize_feature_index(df,label_column):
feature_names = []