Skip to content

Instantly share code, notes, and snippets.

Andrew Nguyen andrewnguyen42

Block or report user

Report or block andrewnguyen42

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andrewnguyen42
andrewnguyen42 / pi_viz.R
Created Feb 24, 2019
Visualize the first million digits of pi as a phone background
View pi_viz.R
library(dplyr)
library(ggplot2)
library(httr)
library(stringr)
my_pi <- GET(url = 'https://www.angio.net/pi/digits/pi1000000.txt') %>%
content(as="text")
n <- 1000000
View Bayes HLM
library(lme4)
library(blme)
library(arm)
cps <- read.csv('cps.csv')
cps <- subset(cps,wageworkerlastyear==1 & !is.na(lhourlywage))
cps$state<-as.integer(cps$statefip)
cps$nchildnum<-as.integer(cps$nchild)-1
cps$statefip<-as.factor(cps$statefip)
View RushingViz.R
dataframe <- read.csv('rushing.csv', header = TRUE,sep = ",")
#filter for 16 game seasons and running backs
sixteenGamesdf <- dataframe %.% filter(Pos == 'TB' | Pos =='rb' | Pos == 'RB' , Year >= 1978)
sixteenGamesdf$Tm[sixteenGamesdf$Tm=="RAM"]<-"STL"
sixteenGamesdf$Tm[sixteenGamesdf$Tm=="PHO"]<-"ARI"
sixteenGamesdf$Tm[sixteenGamesdf$Tm=="RAI"]<-"OAK"
View waterFill
public static int waterFill(int[] arr){
int rainCount=0;
int max=arr[0];
for(int i=0;i<arr.length;i++){
max=(arr[i]>max)?arr[i]:max;
}
//fill it up
@andrewnguyen42
andrewnguyen42 / Java post
Last active Dec 16, 2015
Send an xml string to a url Requires 5 jars: commons-httpclient-3.0.1.jar , httpclient-4.0-alpha2.jar , httpcore-4.0-alpha6.jar , commons-codec-1.7.jar , commons-logging-1.1.2.jar
View Java post
/**
* Actually takes care of posting data to a service
* @param xml The xml data in the form of a Java String
* @param url The address to post data to
*/
private static boolean postData(String xml, String url){
//PostMethod post=new PostMethod();
HttpPost pst=null;
@andrewnguyen42
andrewnguyen42 / FileLister
Created Apr 11, 2013
Quick example of file traversal
View FileLister
import java.io.File;
public class FileLister {
public static void main(String[] args) {
list(new File("/"));
}
/**
* Display a list of the specified file and all its descendants.
*/
You can’t perform that action at this time.