Skip to content

Instantly share code, notes, and snippets.

View stevehenderson's full-sized avatar

Steve Henderson stevehenderson

View GitHub Profile
@stevehenderson
stevehenderson / readParse.R
Created March 21, 2014 15:02
R Code to Access Parse.com
library('RCurl')
library('XML')
library('rjson')
clist<-c('X-Parse-Application-Id' = "abcdefghijklmnopqrstuvwxyz",
'X-Parse-REST-API-Key' = "hgjhfghjergbfnrebghjreghjtghjrebnerb" )
opts = list(httpheader = clist,ssl.verifypeer = FALSE)
#Note the limit is set to 1000 (100 is the default; 1000 is max)
results<-getURL("https://api.parse.com/1/classes/TestObject?limit=1000", .opts = opts)
@stevehenderson
stevehenderson / splitDataframeByDate.R
Last active August 29, 2015 13:57
Split R Dataframe by Date #split #dataframe #R #date
df <- data.frame(date=rep(seq.POSIXt(as.POSIXct("2011-11-01 11:23"), by="day", length.out=4), each=4), var=rnorm(4))
df <- rbind(df,data.frame(date=rep(seq.POSIXt(as.POSIXct("2011-11-02 01:20"), by="day", length.out=4), each=4), var=rnorm(4)))
df <- rbind(df,data.frame(date=rep(seq.POSIXt(as.POSIXct("2011-11-02 05:13"), by="day", length.out=4), each=4), var=rnorm(4)))
df <- rbind(df,data.frame(date=rep(seq.POSIXt(as.POSIXct("2011-11-03 18:22"), by="day", length.out=4), each=4), var=rnorm(4)))
df <- rbind(df,data.frame(date=rep(seq.POSIXt(as.POSIXct("2011-11-11 16:44"), by="day", length.out=4), each=4), var=rnorm(4)))
df <- rbind(df, data.frame(date=rep(seq.POSIXt(as.POSIXct("2011-11-11 02:26"), by="day", length.out=4), each=4), var=rnorm(4)))
df <- rbind(df,data.frame(date=rep(seq.POSIXt(as.POSIXct("2011-11-12 13:13"), by="day", length.out=4), each=4), var=rnorm(4)))
df <- rbind(df,data.frame(date=rep(seq.POSIXt(as.POSIXct("2011-11-13 19:33"), by="day", length.o
@stevehenderson
stevehenderson / disruptSeq.R
Created March 21, 2014 20:38
Spoofing R sequence operator #R #spoof
(function(x) as.vector(t(cbind(x,x+5)))) (1:5)
@stevehenderson
stevehenderson / gist:8f76e9b9cc8896e4fa2f
Last active August 29, 2015 14:05
Simple java guessing game
//I MADE A CHANGE!! HI EVA
package hendo;
//We need two packages for reading and handling IO errors
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class JavaGame {
import st.Prompt;
public class Lift
{
public static void printShaft(String [] a){
for (int i=0; i < 10; i++){
System.out.println(a[i]+(10 - i));
}
import st.Prompt;
public class Lift {
public static void printShaft(String[] a) {
for (int i = 0; i < 10; i++) {
System.out.println(a[i] + (10 - i));
}
System.out.println();
}
@stevehenderson
stevehenderson / lm_program
Created September 23, 2014 02:42
doe lm programatically build linear model
#This line creates a linear model with all variables and 2 way interaction
LinearModel.1 <- lm(result~(.)^2,data=Design.2)
#add interaction columns -- TODO: Programticcaly do this later
#c12
dd<-cbind(binary.factors.matrix[,5]*binary.factors.matrix[,4],binary.factors.matrix)
#c13
dd<-cbind(binary.factors.matrix[,5]*binary.factors.matrix[,3],dd)
#c14
dd<-cbind(binary.factors.matrix[,5]*binary.factors.matrix[,2],dd)
#c15
dd<-cbind(binary.factors.matrix[,5]*binary.factors.matrix[,1],dd)
#c23
@stevehenderson
stevehenderson / countDecimals.vb
Last active August 29, 2015 14:14
A VBA function to count decimal points in text
Function countDecimals(incomingStr) As Integer
Dim stringParts() As String
stringParts() = Split(incomingStr, ".")
Dim i As Integer
i = UBound(stringParts)
countDecimals = i
End Function
@stevehenderson
stevehenderson / wrapString.vb
Created January 27, 2015 00:26
A VBA function to wrap a long string with newline characters
Function wrapString(incomingStr) As String
Dim pParts() As String
pParts = Split(incomingStr, " ")
Dim result As String
Dim k As Integer
For k = LBound(pParts) To UBound(pParts)
result = result & pParts(k)