Skip to content

Instantly share code, notes, and snippets.

View alittlesliceoftom's full-sized avatar

Tom O'Neill alittlesliceoftom

  • London
View GitHub Profile
@alittlesliceoftom
alittlesliceoftom / .gitconfig
Created December 6, 2024 10:39
Prefferred Additions to git config file (mostly only use the first 5 aliases.
[alias]
st = status
com = commit
co = checkout
br = branch
di = diff
unstage = reset HEAD --
last = log -1 HEAD
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
ld = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph
@alittlesliceoftom
alittlesliceoftom / git_aliases
Created December 6, 2024 10:31
Preferred set of git alias's in my cli. Various ones to turn typos to be interpreted as "git" plus a few shorter helps to automate regular commiting.
g=git $*
gap=git add -u $T git com -m tweak $T git push
gapm=git add -u $T git com -m $* $T git push
gbranch=git for-each-ref --sort=-committerdate refs/heads/ --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))" --count 10
gcp=git commit -m "$*"
gdel=git branch -d $*
gi=git
gl=git log --oneline --all --graph --decorate $*
gti=git $*
gut=git

1. Generate an SSH key-pair

First up, generate yourself an SSH key pair - unless you already have one you can reuse, in which case skip this step.

Notes on this step:

  • Replace anything in block caps below with something meaningful - it's just a comment that gets stored with the key to help you tell what it's used for in the future.
  • It will ask you if you want to password-protect (i.e. encrypt) the private half of the key pair. If you're using a Mac, I recommend you set a password as Git integrates with the MacOS keychain really nicely. I'm not familiar with how to setup 'transparent' password-protected private keys on other operating systems, so best to just set no password unless you know what you're doing.
ssh-keygen -t rsa -b 4096 -C "YOUR_NAME github key [email protected]" -f ~/.ssh/id_rsa_github
@alittlesliceoftom
alittlesliceoftom / formula
Created April 9, 2018 16:29
Logarithmic histogram with variable axis in tableau
STR([Base]^FLOOR(LOG(ABS([Daily Slippage]),[Base]))) + "-" + STR([Base]^(FLOOR(LOG(ABS([Daily Slippage]),[Base]))+1) )
@alittlesliceoftom
alittlesliceoftom / DataframeJoinTest
Created November 15, 2016 16:41
Test DataFrames and Joining Them, Good for testing
import pandas as pd
def test_join(how,a,b,c):
x = pd.merge(a,b,on = 'data',how = how)
y = pd.merge(a,c,on = 'data',how = how)
z = pd.merge(b,c,on = 'data',how = how)
import pandas as pd
import sqlalchemy as sa
import configparser
from os import path
configfile = 'config.ini'
config = configparser.ConfigParser()
config.read(path.dirname(__file__) + '/' + configfile)
from dateutil.parser import parse
from datetime import timedelta
#
firstdate= parse('2010-04-01')
lastdate = parse('2016-04-02')
start = firstdate
end = min(firstdate+timedelta(months = 1),lastdate)
main(start, end)
@alittlesliceoftom
alittlesliceoftom / demandByWeekday.sql
Created September 13, 2016 16:13
returns final and customer demand split by weekday
--%of demand by weekday (2015)
SELECT DATEPART(dw,SettlementDate) datepart,
DateName(dw,SettlementDate) datename
,SUM(CustomerDemandAggregate)/COUNT(CustomerDemandAggregate) as CdperDay
,SUM(FinalDemandAggregate)/COUNT(FinalDemandAggregate) as fdperDay