This file contains 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
""" | |
DESCRIPTION: | |
Using SublimeREPL, this plugin allows one to easily transfer AND | |
evaluate blocks of python code. The code automatically detect python | |
blocks and executes only code lines, omitting empty space and comments. | |
One can skips space, comment blocks and comment lines by executing on | |
empty lines, comments etc. | |
REQUIRES: | |
working with only 2 groups in the window. the main group (group 0) |
This file contains 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
from pandas import Series, DataFrame | |
import pandas as pd | |
import numpy as np | |
# SET UP FILES ----------------------------------------------------------------------- | |
## create a main directory link and a subpath to file | |
## NOTE: anything in quotes `" "` is a data type called a 'string'. You should | |
## ALWAYS make file paths into strings to avoid parsing errors. | |
main_dir = "/Users/dnoriega/GitHub/Duke_PUBPOL590/" | |
csv_file = "02_data_structures_and_importing_data/data/sample_data_clean.csv" |
This file contains 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/local/bin/bash | |
# Original Applescript by Andrew Heiss (https://gist.github.com/andrewheiss/5bb905b1cfb244ebab40) | |
# SCRIPT MUST BE IN SAME DIRECTORY AS HTML FILES | |
# use: ~$ zsh ./html2docx.sh | |
# OR ~$ bash ./html2docx.sh | |
echo | |
html2docx () { | |
echo "Converting $2.html to $2.docx..." | |
osascript <<EOD | |
set base_folder to "$1/" |
This file contains 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
assignCount <- function(obj, kind, new=FALSE) { | |
# fromi https://rmflight.github.io/posts/2012/10/papersinRmd.html | |
incCount <- function(inObj, useName) { | |
nObj <- length(inObj) | |
useNum <- max(inObj) + 1 | |
inObj <- c(inObj, useNum) | |
names(inObj)[nObj + 1] <- useName | |
inObj | |
} |
This file contains 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/local/bin/ruby | |
# SOURCE: scrivwatch.rb by Brett Terpstra, 2011, https://gist.github.com/ttscoff/1676667 | |
# REPURPOSED AND RENAMED BY: Danton Noriega, April 2016 | |
# Instructions: | |
# 1. place 'scriv2md.rd' in same directory as .scriv project | |
# 2. give permissions to 'scriv2md.rd': | |
# chmod u+x ./scriv2md.rd | |
# 3. use! | |
# ./scriv2md.rd /path/to/document.scriv |
This file contains 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
Show hidden characters
// Send current chunk to R | |
{ | |
"keys": ["super+alt+enter"], | |
"command": "knitr_send_chunk", | |
"context": [ | |
{ "operand": "text.tex.latex.knitr source.r.embedded.knitr, text.html.markdown.knitr source.r.embedded.knitr, text.html.markdown.rmarkdown source.r", "operator": "equal", "match_all":true, "key": "selector" } | |
] | |
}, | |
// Move between chunks |
This file contains 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(gtfsr) | |
library(magrittr) | |
library(dplyr) | |
set_api_key('2ec1ae29-b8c2-4a03-b96e-126d585233f9') # input your API key here | |
chi_feeds <- get_feedlist() %>% | |
filter(grepl('chicago', loc_t, ignore.case=TRUE)) | |
cta_url <- chi_feeds$url_d[8] # get the GTFS feed url for CTA |
This file contains 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
import sublime, sublime_plugin | |
class SendMagrittrPipe(sublime_plugin.TextCommand): | |
def move_cursor(self, line_num): | |
"""move cursor to the left of line""" | |
v = self.view | |
v.sel().clear() | |
region = v.line(v.text_point(line_num, 0)) | |
v.sel().add(region.begin()) |
This file contains 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
[ | |
// search forward and backwards for pipes | |
{ | |
"keys": ["super+enter"], "command": "send_magrittr_pipe", | |
"context": | |
[ | |
{ "key": "following_text", "operator": "regex_contains", "operand": "%<>%|<>%|%>%|>%|%", "match_all": false }, | |
{ "key": "selector", "operator": "equal", "operand": "source.r" } | |
] | |
}, |
This file contains 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
# highcharter example: creating "scatter columns" with medians | |
# goal: scatter plot mpg by cyl, highlight medians | |
library(highcharter) | |
library(dplyr) | |
library(tibble) | |
library(purrr) | |
# BUILD HC DATA ------------------------------------------------ | |
# convert to tibble |
OlderNewer