Skip to content

Instantly share code, notes, and snippets.

View rednebmas's full-sized avatar

Sam Bender rednebmas

View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.keyremap</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
local function pressFn(mods, key)
if key == nil then
key = mods
mods = {}
end
return function() hs.eventtap.keyStroke(mods, key, 10) end
end
local function remap(mods, key, pressFn)
@rednebmas
rednebmas / .gitconfig
Last active August 8, 2021 18:23
.gitconfig
[alias]
co = checkout
br = branch
pl = pull
ph = push
A = add -A
amend = commit --amend
ammend = commit --amend
rebase = rebase --no-ff
uncommit = reset HEAD~1
@rednebmas
rednebmas / sql-param-replace.ts
Last active March 19, 2022 02:34
Replace Postgres SQL params into SQL
// https://bit.ly/3sZFmEN
let userInput = `
SELECT "OrgUser"."id" AS "OrgUser_id", "OrgUser"."role" AS "OrgUser_role", "OrgUser"."user_id" AS "OrgUser_user_id", "OrgUser"."org_id" AS "OrgUser_org_id", "OrgUser"."created_at" AS "OrgUser_created_at", "OrgUser"."deleted_at" AS "OrgUser_deleted_at", "OrgUser"."updated_at" AS "OrgUser_updated_at" FROM "org_user" "OrgUser" WHERE "OrgUser"."user_id" = $1 AND "OrgUser"."deleted_at" IS NULL -- PARAMETERS: [7]
`;
let split = userInput.split('-- PARAMETERS: ');
var sql = split[0].trim();
let params = JSON.parse(split[1]);
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
autoload -Uz compinit && compinit
# https://superuser.com/a/1092328
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
##
## Git
##
@rednebmas
rednebmas / ios-resize.py
Created June 10, 2018 22:41
iOS resize script
#!/usr/bin/env python3
import os
import sys
from subprocess import call
if len(sys.argv) == 1:
print("Usage:\n ios-resize filename @3x_size_optional_param (32x32)")
sys.exit()
@rednebmas
rednebmas / convert.py
Created May 20, 2018 00:53
Convert sqlite3 dump to mysql importable statements
import re, fileinput
print 'SET FOREIGN_KEY_CHECKS=0;'
def main():
for line in fileinput.input():
process = False
for nope in ('BEGIN TRANSACTION','COMMIT',
'sqlite_sequence','CREATE UNIQUE INDEX'):
if nope in line: break
@rednebmas
rednebmas / scrape_stevens_pass.py
Created May 8, 2018 23:58
Scrape images from Steven's pass webcams to see snow melt over time!
import urllib.request
import datetime
file_name = datetime.datetime.now().strftime("%Y-%m-%d %H.%M") + ".jpg"
urllib.request.urlretrieve("https://www.stevenspass.com/cams/cowboy/", "./cowboy/" + file_name)
urllib.request.urlretrieve("https://www.stevenspass.com/cams/base1/", "./base1/" + file_name)
urllib.request.urlretrieve("https://www.stevenspass.com/cams/jupiter/", "./jupiter/" + file_name)
@rednebmas
rednebmas / WindowPopAnimation.swift
Created December 3, 2017 08:23
Window pop animation
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
let window = UIApplication.shared.windows[0]
UIView.animate(withDuration: 0.25, animations: {
window.transform = CGAffineTransform(scaleX: 1.1, y: 1.1)
}, completion: { (completed) in
UIView.animate(withDuration: 0.25, animations: {
window.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
}, completion: { (completed) in
})
})
@rednebmas
rednebmas / .gitconfig
Created November 6, 2017 18:20
Just the aliases
[alias]
co = checkout
c = commit
br = branch
aliases = !git config --list | grep ^alias\\. | cut -c 7- | grep -Ei --color \"$1\" "#"
appcode = "!git ls-files --modified | grep "\\.xcscheme$" | xargs git co"
pl = pull
ph = push
A = add -A
amend = commit --amend