Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View joshuaulrich's full-sized avatar

Joshua Ulrich joshuaulrich

View GitHub Profile
@joshuaulrich
joshuaulrich / squash-and-merge-cli.md
Created November 21, 2019 13:23 — forked from aortbals/squash-and-merge-cli.md
Squash and Merge on the Command line

With the introduction of GitHub's Squash and Merge feature, this has become less prevelant, however it's still useful in scenarios where GitHub's interface is unavailable.

Let's talk through two ways to do a squash and merge on the command line.

Take 1: Interactive Rebase

When to use it

  • When you have not merged master into your feature branch
  • There are no merge conflicts
@joshuaulrich
joshuaulrich / bcrypt-password.pl
Last active February 16, 2019 19:27 — forked from evandrix/gist:1076041
Check password against known hashed password and salt
#!/usr/bin/perl
# Usage: read -s PASSWORD && ./bcrypt-password.pl
use Crypt::Eksblowfish::Bcrypt;
# Read password and salt from environment variables
$password = $ENV{PASSWORD};
$salt = "lfVQ/T2N3dhFVvvPro2Hfu"
$encrypted = encrypt_password($password, $salt);
# Extract bcrypt version, cost, salt, and hashed password
@joshuaulrich
joshuaulrich / bench.R
Last active March 29, 2018 14:50 — forked from jimhester/bench.R
getOption benchmark
getOptionOld <- function(x, default = NULL) {
if(missing(default) || x %in% names(options()))
.Internal(getOption(x))
else
default
}
getOptionNew <- function(x, default = NULL) {
ans <- .Internal(getOption(x))
if(is.null(ans)) default else ans
@joshuaulrich
joshuaulrich / 10y-oscillator.R
Last active August 27, 2017 15:15 — forked from mbusigin/10y-oscillator.R
Generate chart with 10y yield oscillator (10y yield minus 260d moving average), +/- 1 stdev dashed lines
recplot <- function(var, rec.ind, maintitle = "", ylab = "", ylim = NULL)
{
# Give each recession a separate number, so we can split data by recession
# and calculate the necessary values to pass to addPolygon() for shading
r <- rle(as.integer(rec.ind))
r$values[r$values > 0] <- seq_len(sum(r$values))
rec <- xts(inverse.rle(r), index(rec.ind))
# Merge variable and recession data, as a left-join so we do not have
# observations that only exist in the recession indicator data
@joshuaulrich
joshuaulrich / output.txt
Created May 28, 2017 16:02 — forked from romainfrancois/output.txt
Extract promises and their environments from ...
> f <- function(...) {
+ promises(environment())
+ }
> g <- function(x = 3, ...) {
+ z <- 4
+ f(z = z, ..., x = x)
+ }
> h <- function(..., a = 2) {
@joshuaulrich
joshuaulrich / CBOE_csv_to_xts
Created October 19, 2012 02:15 — forked from jaredwoodard/CBOE_csv_to_xts
pulls csv files from the CBOE and converts them to xts
library(quantmod)
# we're pulling the Google VIX index (VXGOG) but this also works for VXAPL, VXGS etc.
# see http://www.cboe.com/micro/equityvix/introduction.aspx
url <- "http://www.cboe.com/publish/ScheduledTask/mktdata/datahouse/VXGOGDailyPrices.csv"
# use read.zoo to read the data directly into a zoo object
z <- read.zoo(url, header=TRUE, sep=",", skip=1, FUN=as.Date, format="%m/%d/%Y")
# convert to xts
require(quantmod)
#get index tickers without the ^ which we will add in the getSymbols
tckrs=c("GSPC","TNX","DJUBS","W3DOW","W5DOW")
#name the indexes
names(tckrs) <- c("S&P 500","US 10y Yld","DJ Commodity","Developed","Developing")
#use paste to add the ^ to the index tickers
getSymbols(paste("^",tckrs,sep=""), from="1986-01-01", to=Sys.Date())