Skip to content

Instantly share code, notes, and snippets.

View rednebmas's full-sized avatar

Sam Bender rednebmas

View GitHub Profile
##
## this method of keyremapping was found: https://apple.stackexchange.com/a/283253/28701
## all key keycodes: https://developer.apple.com/library/content/technotes/tn2450/_index.html
##
# remap right option to forward delete
hidutil property --set '{"UserKeyMapping":
[{"HIDKeyboardModifierMappingSrc":0x7000000e6,
"HIDKeyboardModifierMappingDst":0x70000004c}]
}'
@rednebmas
rednebmas / init.lua
Created November 5, 2017 05:03
Hammerspoon config file
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)
<!-- http://alignedleft.com/tutorials/d3/making-a-bar-chart -->
<div class="container">
<style type="text/css">
div.bar {
display: inline-block;
width: 20px;
height: 75px; /* Gets overriden by D3-assigned height below */
margin-right: 2px;
background-color: teal;
}
@rednebmas
rednebmas / an_obj_pattern.js
Created February 4, 2017 23:19
Neat javascript object/class pattern
var myClass = function(constructorParam) { return {
/** object notation properties **/
x: "it ",
_state: 'awesome',
/** Getters and setters! **/
get state() {
return this._state;
},
set state(value) {
@rednebmas
rednebmas / nil.js
Last active January 12, 2017 01:20
Nil.js
/*
The Nil object behaves similarily to nil in Objective-C. You can infinitely
chain calls or property accessors on it and it will never throw an exception.
I developed this for unit testing.
Example usage:
var nil = new Nil();
console.log(nil.infinitelyChainsCalls().or.properties.withoutRepercussions());
Based on code from http://stackoverflow.com/a/29723887/337934
Proxy documentation: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Proxy
*/
@rednebmas
rednebmas / DropAllTables.py
Created January 7, 2017 00:52
Drop all tables from a SQLite database
try:
db.execute("CREATE TABLE Test (test_id INTEGER NOT NULL);")
db.execute("INSERT INTO Test (test_id) VALUES (1);")
tables = db.select(table="sqlite_master", where="type = 'table'", columns="name")
self.assertTrue(len(tables) == 1)
for table in tables:
db.execute("DROP TABLE " + table['name'])
tables = db.select(table="sqlite_master", where="type = 'table'", columns="name")
self.assertTrue(len(tables) == 0)
except Exception as e:
{
"auto_complete": true,
"caret_style": "solid",
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"folder_exclude_patterns":
[
".git",
"doc"
],
"font_size": 13,
@rednebmas
rednebmas / bash-color-grid.sh
Created August 26, 2016 16:04
Prints all bash prompt colors
# Thanks to plasmarob (http://unix.stackexchange.com/a/285956)
function colorgrid( )
{
iter=16
while [ $iter -lt 52 ]
do
second=$[$iter+36]
third=$[$second+36]
four=$[$third+36]
five=$[$four+36]
@rednebmas
rednebmas / XcodeSnippets.m
Last active September 22, 2017 05:35
My user defined code snippets for ObjC dev in Xcode
// completion shortcut: @propstrong
@property (nonatomic, strong) <#type#> *<#name#>;
// completion shortcut: @propweak
@property (nonatomic, weak) <#type#> *<#name#>;
// completion shortcut: @propassign
@property (nonatomic, assign) <#type#> <#name#>;
// completion shortcut: dispatch_async
dispatch_async(dispatch_get_main_queue(), ^{
<#code#>
@rednebmas
rednebmas / .vimrc
Last active April 20, 2018 17:09
My Vim config file
"" Important installed plugins:
""
"" YouCompleteMe
"" http://www.alexeyshmalko.com/2014/youcompleteme-ultimate-autocomplete-plugin-for-vim/
""
"" Airline status bar
execute pathogen#infect()
""