Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View abeburnett's full-sized avatar

Abe Burnett abeburnett

  • Ogden, UT
View GitHub Profile
@dwayne
dwayne / 1-introduction.md
Last active August 22, 2016 04:37
My notes from the book "Riding Rails with AngularJS by Ari Lerner".
@fractastical
fractastical / client.js
Created June 3, 2012 15:21 — forked from matteoagosti/client.js
Twitter OAUTH using Meteorjs
var ClientRouter = Backbone.Router.extend({
routes: {
'404': 'notfound',
'500': 'error',
'auth': 'auth',
'authCallback?oauth_token=:oauth_token&oauth_verifier=:oauth_verifier': 'authCallback',
'': 'defaultRoute'
},
defaultRoute: function() {
anonymous
anonymous / dbWriteTable.fast.R
Created May 12, 2011 13:00
Function to get problematic data into PostgreSQL from R (uses RPostgreSQL)
# Function to get data over to PostgreSQL quickly and with minimal loss
# of information due to data type conversions.
# Note that I have had cases where the pipe() call returned an error due
# to lack of memory. So care should be taken with this function
dbWriteTable.fast <- function (conn,name,value,row.names=FALSE,
overwrite=TRUE,fix.names=TRUE) {
# Conform names to PostgreSQL requirements
pg.names <- make.db.names(conn,names(value))
@tomasgreif
tomasgreif / RPostgreSQL_sqldf
Last active April 6, 2017 18:42
RPostgreSQL and sqldf basic usage
# www.analytikdat.cz
# www.analytikdat.cz/index.php/blog/entry/r-and-postgresql-using-rpostgresql-and-sqldf
# Load required libraries
library("RPostgreSQL")
library("sqldf")
# Establish connection
drv <- dbDriver("PostgreSQL")
# Simple version (localhost as default)
@swiftsam
swiftsam / r_cache.R
Created May 6, 2016 15:57
function caching function for R
####~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
### Cache (memoization) utilities
###
### Purpose
### * Functions to save the output of time consuming functions to memory and
### return results quickly if we already have the answers
###
### Notes: Standard usage would go like this
### FunctionName <- function(){
### args <- c(as.list(environment()), list())
@benmarwick
benmarwick / colocates.r
Last active October 24, 2017 10:18
Analysis of collocation of words in a text with R. Extracts LHS and RHS collocates of a word of interest over a user-defined span. Calculates frequency of collocates and mean distances. Inspired by http://www.antlab.sci.waseda.ac.jp/software.html
# R code for basic collocation statistics on a text corpus.
# Extracts LHS and RHS collocates of a word of interest
# over a user-defined span. Calculates frequency of
# collocates and mean distances.
examp1 <- "When discussing performance with colleagues, teaching, sending a bug report or
searching for guidance on mailing lists and here on SO, a reproducible example is often
asked and always helpful. What are your tips for creating an excellent example? How do
you paste data structures from r in a text format? What other information should you
include? Are there other tricks in addition to using dput(), dump() or structure()?
@cybrox
cybrox / EmberChartComponent.js
Created June 5, 2014 12:39
Use Chart.js as a simple Ember.js component
/**
* This is a very simple example of an ember component to integrate
* nnick/chart.js in an ember.js application. Basically, it is simply
* using the components hook to create a ChartJS canvas element.
* Additionally, it supports an update property that allows you to
* let the chart re-rendet if your data or options change. Chart.js
* doesn't support updating its data so this will just create a new
* chart on the given canvas.
*
* Example usage in a handlebars template:
@vtslab
vtslab / RGremlin.java
Last active February 20, 2019 22:22
Connecting to TinkerPop's gremlin server from R Studio with a java wrapper
package rgremlin;
import org.apache.tinkerpop.gremlin.driver.*;
import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry;
import org.json.simple.JSONObject;
@carlganz
carlganz / installOldPackages.R
Last active April 8, 2019 17:23
If you are upgrading from R 3.2 to R 3.3 you have to go to the hassle of redownloading all your packages. This code will try to download all your old packages.
# get library path
lib <- .libPaths()[1]
# does it end in 3.3?
if (grepl("*3.3",lib)) {
# if yes then assume old library is same place with 3.2 instead
oldlib <- gsub("*3.3","3.2",lib)
}
# check that old library exists
@tomtung
tomtung / saas-class-homework-ruby-basics.rb
Created March 4, 2012 15:30
SaaS Class Homework: Ruby Basics
# Homework 1 - Part 1
def palindrome?(string)
string = string.downcase.gsub(/\W/, '')
string == string.reverse
end
def count_words(string)
Hash[
string.downcase.scan(/\w+/).
group_by{|s| s}.