This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://stackoverflow.com/questions/6491532/how-to-subset-a-file-select-a-numbers-of-rows-or-columns | |
| cat largefile | awk 'NR >= 10000 && NR <= 100000 { print }' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(foreign) | |
| library(dplyr) | |
| library(ggplot2) | |
| success <- read.dta("ALP_MS118_2016_03_13_06_51_42.dta") | |
| scpc2010 <- read.dta("SCPC2010.dta") | |
| scpc2010.adopt <- scpc2010[ , c("prim_key", "cc_adopt", "cc_sh")] | |
| success.locus <- success[ , c("ms118_prim_key", "ms118_lc1")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(rvest) | |
| library(ggvis) | |
| wiki.prison <- html("http://en.wikipedia.org/wiki/List_of_countries_by_incarceration_rate") | |
| wiki.prison.data <- wiki.prison %>% | |
| html_nodes("table") %>% | |
| html_nodes("table") %>% | |
| .[[2]] %>% | |
| html_table(fill = TRUE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(rvest) | |
| library(ggplot2) | |
| library(ggthemes) | |
| library(MASS) | |
| library(splines) | |
| treas.html <- html("http://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=yield") | |
| yield.data <- treas.html %>% | |
| html_nodes("table") %>% | |
| .[[67]] %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from lxml import html | |
| import requests | |
| import nltk | |
| page = requests.get('http://nytimes.com') | |
| tree = html.fromstring(page.text) | |
| top_stories = tree.xpath('//*[@id="top-news"]/*//h2/a/text()') | |
| more_stories = tree.xpath('//*[@id="main"]/div[10]/*//article/h2/a/text()') | |
| all_stories = top_stories + more_stories |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dir.glob('*.mp3') do | the_filename | | |
| track = the_filename[0..2].strip() | |
| File.rename(the_filename, "05-#{track}.mp3") | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using JuMP, Ipopt | |
| A = 1; δ = 0.1; θ = 0.3; β = 0.96; ɛ = 0.5; χ = 0.5; | |
| r = (1 / β) - (1 - δ); | |
| m = Model(solver = IpoptSolver()) | |
| @variable(m, 0 <= k <= Inf) | |
| @variable(m, 0 <= n <= Inf) | |
| @variable(m, 0 <= w <= Inf) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| brew tap caskroom/cask | |
| brew install brew-cask | |
| brew install Caskroom/cask/xquartz | |
| brew cask install java | |
| brew tap homebrew/science | |
| brew install R | |
| brew install Caskroom/cask/rstudio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'mini_exiftool' | |
| photo = MiniExiftool.new('new.jpg') | |
| photo.tags.sort.each do |tag| | |
| photo.copy_tags_from('original.jpg', tag) | |
| end | |
| photo.save |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Wrong mean: 5.84333333333333 | |
| Right mean: 5.936 | |
| The wrong mean didn't filter: 5.84333333333333 |