Skip to content

Instantly share code, notes, and snippets.

View dantonnoriega's full-sized avatar

Danton Noriega-Goodwin dantonnoriega

View GitHub Profile
@dantonnoriega
dantonnoriega / sublime-r-section-move.py
Created December 20, 2017 22:36
sublime text plugin to move forward or backward to a given pattern. in this case, i search for "headers" defined as strings "####" or "# TEXT ---------". mostly designed for R.
import sublime, sublime_plugin
class MoveForwardToSectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
v = self.view
s = v.sel()
pattern = "^[ ]*# [#]{4,}|^[ ]*[#]{4,}|^[ ]*#+ [\w]+.+[-]+$|^`{3}"
# get current point and then look forward
@dantonnoriega
dantonnoriega / tmux-vim-repl.md
Last active October 28, 2021 06:58
Step by step instruction to set up a VIM REPL with TMUX on a linux box. I found most instruction onlin convoluted and confusing.

Set up tmux with a vim REPL on a linux box

  1. install https://github.com/tpope/vim-pathogen into ~/.vim/
  2. install https://github.com/jpalardy/vim-slime into ~/.vim/bundle
  3. copied default vimrc to a user copy: cp /etc/vimrc ~/.vim/vimrc
  4. added the following to the end of ~/.vim/vimrc
" vim slime
let g:slime_python_ipython = 1

@dantonnoriega
dantonnoriega / Main.sublime-menu
Last active November 15, 2017 21:35
SublimeREPL ipy_repl.py hack to work with Anaconda + IPython 6.1.0 + Python 3.6 for macOS
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
@dantonnoriega
dantonnoriega / us-state-ansi-fips.csv
Last active April 14, 2025 19:49
csv file of us state ansi fips codes that follows the us census variable names
stname st stusps
Alabama 01 AL
Alaska 02 AK
Arizona 04 AZ
Arkansas 05 AR
California 06 CA
Colorado 08 CO
Connecticut 09 CT
Delaware 10 DE
District of Columbia 11 DC
@dantonnoriega
dantonnoriega / zsh-regex-file-rename-example.sh
Created September 24, 2017 02:49
quick example that downloads some videos from youtube (CS106B Programming Abstraction) then renames the files using regex in zsh for file names ($match). Really cool and useful!
# $match example for zsh
# inspiration:
# https://stackoverflow.com/questions/13043344/search-and-replace-in-bash-using-regular-expressions
# reprex
mkdir CS106B
cd CS106B
# download mp4s of programmming abstraction
@dantonnoriega
dantonnoriega / parse-utm-script.R
Last active September 6, 2017 03:21
Parse UTM CSV export
# script UTM
# functions
get_utm <- function(x) {
# empty frame
ef <- structure(list(cf_affiliate_id = character(1), utm_source = character(1),
utm_medium = character(1), utm_campaign = character(1), utm_term = character(1),
utm_content = character(1), webinar_delay = character(1),
purchase_product_ids = character(1), purchase_taxamo_transaction_key = character(1),
@dantonnoriega
dantonnoriega / highcharter-htmlwidget-webshot-example.R
Last active October 25, 2022 12:56
htmlwidget-webshot-example.R
# Creating html plots with highcharter and generating high resolution PNGs of plots with webshot
library(highcharter)
# set up directories
OUTPUT_HTML <- '~/Downloads/hc-webshot-example/html'
OUTPUT_PNG <- '~/Downloads/hc-webshot-example/png'
if(!dir.exists(OUTPUT_HTML)) dir.create(OUTPUT_HTML, recursive = TRUE)
if(!dir.exists(OUTPUT_PNG)) dir.create(OUTPUT_PNG, recursive = TRUE)
@dantonnoriega
dantonnoriega / percent_sign_latex_html.rmd
Created May 24, 2017 03:31
how to get a percent sign when spinning with latex or html
---
title: TEST
output:
pdf_document:
latex_engine: xelatex
html_document:
fig_caption: true
---
```{r, echo = FALSE}
@dantonnoriega
dantonnoriega / durham-county-inmate-data.R
Last active May 18, 2017 02:55
extract data from durham county jail records
library(httr)
library(tidyverse)
library(xml2)
library(rvest)
devtools::install_github('dantonnoriega/xmltools')
# SET UP VARIABLES
# record_type:
# "0" (all incarcerated)
# "1" (last 24 hours)
@dantonnoriega
dantonnoriega / wake-forest-inmate-data.R
Last active June 23, 2017 19:58
get inmate data for wake county, nc
# variables
OUTPUT_DIR = "~/Dropbox/Jails/data")
DATE <- format(Sys.time(), '%Y-%m-%d')
FILENAME <- sprintf("%s-wake-county-records.csv", DATE)
url <- 'http://p2c.wakeso.net/jqHandler.ashx?op=s'
# set up form request
# query found using Chrome developer tools.
# Ran Query > Go to "Network" tab > find "jqHandler.ashx?op=s"