Skip to content

Instantly share code, notes, and snippets.

View meefen's full-sized avatar

Bodong Chen meefen

View GitHub Profile
@mjbommar
mjbommar / archiveTwitter.py
Created February 26, 2011 19:49
Archive tweets from a search term going backwards through search.
'''
@author Michael J Bommarito II
@date Feb 26, 2011
@license Simplified BSD, (C) 2011.
This script demonstrates how to use Python to archive historical tweets.
'''
import codecs
import csv
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@ramnathv
ramnathv / upgrade_R.R
Created April 5, 2012 22:27
Upgrade R on Mac OS 10.5.8
# GET LIST OF INSTALLED PACKAGES
pkgs <- installed.packages(priority='NA')[,'Package']
save(pkgs, file="installed_pkgs.rda")
# Install the most recent version of R:
# Download the most recent version of R from The Comprehensive R Archive Network (CRAN)
# To wipe the old R version
rm -rf /Library/Frameworks/R.framework /Applications/R.app
rm -rf /Library/Receipts/R-*
@schmurfy
schmurfy / gist:3199254
Created July 29, 2012 14:33
Install pandoc Mac OS X 10.8
# Install MacTex: http://mirror.ctan.org/systems/mac/mactex/mactex-basic.pkg
$ sudo chown -R `whoami` /usr/local/texlive
$ tlmgr update --self
$ tlmgr install ucs
$ tlmgr install etoolbox
# Install pandoc view homebrew
@lmullen
lmullen / gist:3767386
Created September 22, 2012 18:50
Make all markdown files in directory into PDFs
# Produce PDFs from all Markdown files in a directory
# Lincoln Mullen | http://lincolnmullen.com | lincoln@lincolnmullen.com
# List files to be made by finding all *.md files and appending .pdf
PDFS := $(patsubst %.md,%.md.pdf,$(wildcard *.md))
# The all rule makes all the PDF files listed
all : $(PDFS)
# This generic rule accepts PDF targets with corresponding Markdown
@pssguy
pssguy / server.R
Created November 29, 2012 20:37
Shiny App allowing online selection of subjects for graphical and tabular presentation of daily Wikipedia search rates
# libraries used. install as necessary
library(shiny)
library(RJSONIO) # acquiring and parsing data
library(ggplot2) # graphs
library(plyr) # manipulating data
library(lubridate) #dates
library(stringr)
trim.leading <- function (x) sub("^\\s+", "", x)
@dsparks
dsparks / tapered-intensity-curved_edges.R
Last active December 8, 2021 12:23
Beautiful tapered-intensity-curved edge network graph with ggplot2
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("sna", "ggplot2", "Hmisc", "reshape2")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Empty ggplot2 theme
new_theme_empty <- theme_bw()
new_theme_empty$line <- element_blank()
new_theme_empty$rect <- element_blank()
new_theme_empty$strip.text <- element_blank()
@alexbbrown
alexbbrown / d3widget.js
Last active October 18, 2016 20:58 — forked from anonymous/d3widget.js
Simple Shiny Example of Javascript Input and Output
<script src="http://d3js.org/d3.v3.js"></script>
<script type="text/javascript">
(function(){
// Probably not idiomatic javascript.
this.countValue=0;
updateView = function(message) {
var svg = d3.select(".d3io").select("svg")
@mhawksey
mhawksey / gist:5048249
Last active March 31, 2020 15:48
Extracting an edge list from Canvas Discussion Topics API using Google Apps Script
function getCanvasDiscussionEdges() {
var canvas = "learn.canvas.net";
var type = "courses";
var id = "33";
var output = [["vert1_name","vert2_name","vert1_id","vert2_id","vert1_image_url","vert2_image_url","topic_id","topic_title","topic_url","created_at", "message_id", "message_text"]];
var doc = SpreadsheetApp.getActiveSpreadsheet();
var sheet = doc.getSheetByName("Sheet1");
var db = ScriptDb.getMyDb();
var topicList = callCanvasAPI(canvas, type, id, "discussion_topics", 50);
var participants = {}
@pssguy
pssguy / global.R
Last active January 21, 2018 01:25
Motion Chart of Premier League Positions by game for past 20+ seasons. Shiny app using googleVis package The data is not currently provided but to-date charts can be viewed at glimmer.rstudio.com/pssguy/eplTableMotion/
# load requisite libraries
library(shiny)
library(googleVis)
# load raw data (NB not provided)
tableByGame <- read.csv("../tableByGame.csv",stringsAsFactors=FALSE)
# to create chart need to repeat one column and get negative of league position as hack
tableByGame$game <- tableByGame$seasonGame
tableByGame$lgPos <- -tableByGame$lgPos