Skip to content

Instantly share code, notes, and snippets.

@ninnypants
ninnypants / keymap.c
Created April 17, 2019 16:10
QMK macro to send and open a new zoom meeting with /zoom in slack. Built using Alfred mapped to cmd+space but may work with spotlight.
bool process_record_user( uint16_t keycode, keyrecord_t *record ) {
switch ( keycode ) {
case SLACK_ZOOM:
if ( record->event.pressed ) {
SEND_STRING( SS_DOWN( X_LGUI ) SS_TAP( X_SPACE ) SS_UP( X_LGUI ) );
_delay_ms( 250 );
SEND_STRING( SS_TAP( X_Z ) SS_TAP( X_O ) SS_TAP( X_O ) SS_TAP( X_M ) SS_TAP( X_ENTER ) );
_delay_ms( 5000 );
SEND_STRING( SS_DOWN( X_LGUI ) SS_TAP( X_SPACE ) SS_UP( X_LGUI ) );
_delay_ms( 250 );
M104 S0 ;extruder heater off
M140 S0 ;heated bed heater off (if you have it)
G91 ;relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more
G28 X0 ;move X to endstop out of the way
G28 Y210; move bed out for easier access
M84 ;steppers off
G90 ;absolute positioning
request_token_base_string = 'POST&' + CGI.escape("#{Pazienti2::Application::BLOG_URL}oauth1/request") + "&" + request_token_url.query
hmac = OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), params[:oauth_consumer_secret].encode("ASCII") + '&' + '', request_token_base_string.encode("ASCII"))
signature = Base64.encode64(hmac).chomp
request_token_params[:oauth_signature] = signature
@ninnypants
ninnypants / .gitconfig
Created January 28, 2016 02:58
Git aliases
[alias]
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
le = log --oneline --decorate
dlc = diff --cached HEAD^
p = pull
pu = push
@ninnypants
ninnypants / aoc-7.js
Created December 13, 2015 01:20
Solves advent of code day 7. To get the second answer copy the value of wire a into the assign command for b and run again.
var wires = {},
commands = [ 'bn RSHIFT 2 -> bo', 'lf RSHIFT 1 -> ly', 'fo RSHIFT 3 -> fq', 'cj OR cp -> cq', 'fo OR fz -> ga', 't OR s -> u', 'lx -> a', 'NOT ax -> ay', 'he RSHIFT 2 -> hf', 'lf OR lq -> lr', 'lr AND lt -> lu', 'dy OR ej -> ek', '1 AND cx -> cy', 'hb LSHIFT 1 -> hv', '1 AND bh -> bi', 'ih AND ij -> ik', 'c LSHIFT 1 -> t', 'ea AND eb -> ed', 'km OR kn -> ko', 'NOT bw -> bx', 'ci OR ct -> cu', 'NOT p -> q', 'lw OR lv -> lx', 'NOT lo -> lp', 'fp OR fv -> fw', 'o AND q -> r', 'dh AND dj -> dk', 'ap LSHIFT 1 -> bj', 'bk LSHIFT 1 -> ce', 'NOT ii -> ij', 'gh OR gi -> gj', 'kk RSHIFT 1 -> ld', 'lc LSHIFT 1 -> lw', 'lb OR la -> lc', '1 AND am -> an', 'gn AND gp -> gq', 'lf RSHIFT 3 -> lh', 'e OR f -> g', 'lg AND lm -> lo', 'ci RSHIFT 1 -> db', 'cf LSHIFT 1 -> cz', 'bn RSHIFT 1 -> cg', 'et AND fe -> fg', 'is OR it -> iu', 'kw AND ky -> kz', 'ck AND cl -> cn', 'bj OR bi -> bk', 'gj RSHIFT 1 -> hc', 'iu AND jf -> jh', 'NOT bs -> bt', 'kk OR kv -> kw', 'ks AND ku -> kv', 'hz OR ik -> il', 'b RSHIFT 1 -> v
@ninnypants
ninnypants / aoc-6.js
Created December 7, 2015 17:51
Solutions to advent of code day 6. http://adventofcode.com/day/6
var y, x, off = 0, on = 0, lights = [], brightness = 0,
commands = [ 'turn on 489,959 through 759,964', 'turn off 820,516 through 871,914', 'turn off 427,423 through 929,502', 'turn on 774,14 through 977,877', 'turn on 410,146 through 864,337', 'turn on 931,331 through 939,812', 'turn off 756,53 through 923,339', 'turn off 313,787 through 545,979', 'turn off 12,823 through 102,934', 'toggle 756,965 through 812,992', 'turn off 743,684 through 789,958', 'toggle 120,314 through 745,489', 'toggle 692,845 through 866,994', 'turn off 587,176 through 850,273', 'turn off 674,321 through 793,388', 'toggle 749,672 through 973,965', 'turn on 943,30 through 990,907', 'turn on 296,50 through 729,664', 'turn on 212,957 through 490,987', 'toggle 171,31 through 688,88', 'turn off 991,989 through 994,998', 'turn off 913,943 through 958,953', 'turn off 278,258 through 367,386', 'toggle 275,796 through 493,971', 'turn off 70,873 through 798,923', 'toggle 258,985 through 663,998', 'turn on 601,259 through 831,486', 'turn off 914
@ninnypants
ninnypants / aoc-5.php
Created December 5, 2015 20:25
Solutions to Advent of Code day 5. http://adventofcode.com/day/5
<?php
/**
* Solutions to Advent of code Day 5 {@link http://adventofcode.com/day/5}
*/
$nice = [];
$naughty = [];
foreach ( get_strings() as $string ) {
if ( is_nice( $string ) ) {
$nice[] = $string;
@ninnypants
ninnypants / aoc-4.php
Created December 4, 2015 21:45
Solves Advent of code puzzle 4 though brute force. May output the solution to the first challenge multiple times.
<?php
$match5 = 0;
$match6 = 0;
$i = 0;
$salt = 'yzbqklnj';
while ( '000000' !== $match6 ) {
$i++;
$hash = md5( $salt . $i );
$match5 = substr( $hash, 0, 5 );
@ninnypants
ninnypants / aoc-3-1.js
Last active December 3, 2015 16:38
Answers to Advent of Code day 3.
var i,
x = 0,
y = 0,
count = 0,
coords = {
'0,0': 1 // Present is delivered to the first house.
},
directions = '^><^>>>^<^v<v^^vv^><<^<><<vv^<>^<^v>^vv<>v><vv^^<>>^^^v<<vv><<^>^<^v<^>^v><<<v^<v<<<v<<vv<v<^><^>><>v>v^<<v^^<^v<><^>^<<^^^>v>>v^^<v>>^>vv><v>>^>>v^>^v>^<^^v>^>^^v<v>^^<v<>>v^^v><^><^<<>v^<^<^v<v>v^>>>v^v^>^<>^v<^^vv<v>^>^<>^^<vv^<><<v<^<^^>vv<>^>v<^>^v>v^>^v<>^><>><vv<>v^v<><>v^v>>>>v^^>^><^^<v<^><^<v>>^v^v<>v<<<^<<vvvv<<v^vv^>v^^^<^^^<v>>v<^v>>>>>v<^^^^>v<^<><v>>>>><v>>v^vvvv^^<v^<>^v<^v^>v><^>^v<<>>vv^>v>v^^>vv^<^vvv<>><>><><^^^<v<>^<^^^<v><^v>>v>^v<v^vv^<>^^^>v^^^v>>^v^^<^>>^>^<<v>>>^^<>>^vv>v^<^>>>><v<><><^^v<><<<<^^<>>^<vvv^><>v<v<<<<><v<<v>v<v^><vv<v^>^<^>v^^><^v>^^>v<>^v^<>^vv^><v^^vv>vvv>v>^<vv^>>^>>^>><>>>^^^^v<vv>^<>v^^><v^>^<>v<^^v><v<<><^v><>^^^^^v^v>>^^v><<><<vv>^^^^><^>v>><<<^v>v^^>^v^<^^v>v<^<<>>^v<<<v<<>>v<^v^><vv<v^v>v^<v>><v>^v<<<vv^>v<v>>v>>v><v><v^>v^^v>^v^>>>><>^>v>^v^>>>>v^<<vv<^v><<>v<v^<^^<<v<^v^^v^>vv><vv<v^<^>><^^>^<><^^<v<><^v^v^<^^>^<v><^<v>v^<<<^^v<v>^v>>><>^
var dimensions = [{ l: 3, w: 11, h: 24 }, { l: 13, w: 5, h: 19 }, { l: 1, w: 9, h: 27 }, { l: 24, w: 8, h: 21 }, { l: 6, w: 8, h: 17 }, { l: 19, w: 18, h: 22 }, { l: 10, w: 9, h: 12 }, { l: 12, w: 2, h: 5 }, { l: 26, w: 6, h: 11 }, { l: 9, w: 23, h: 15 }, { l: 12, w: 8, h: 17 }, { l: 13, w: 29, h: 10 }, { l: 28, w: 18, h: 6 }, { l: 22, w: 28, h: 26 }, { l: 1, w: 5, h: 11 }, { l: 29, w: 26, h: 12 }, { l: 8, w: 28, h: 29 }, { l: 27, w: 4, h: 21 }, { l: 12, w: 7, h: 16 }, { l: 7, w: 4, h: 23 }, { l: 15, w: 24, h: 8 }, { l: 15, w: 14, h: 2 }, { l: 11, w: 6, h: 29 }, { l: 28, w: 19, h: 9 }, { l: 10, w: 3, h: 1 }, { l: 5, w: 20, h: 13 }, { l: 10, w: 25, h: 1 }, { l: 22, w: 17, h: 7 }, { l: 16, w: 29, h: 3 }, { l: 18, w: 22, h: 8 }, { l: 18, w: 11, h: 19 }, { l: 21, w: 24, h: 20 }, { l: 4, w: 7, h: 17 }, { l: 22, w: 27, h: 12 }, { l: 1, w: 26, h: 6 }, { l: 5, w: 27, h: 24 }, { l: 29, w: 21, h: 3 }, { l: 25, w: 30, h: 2 }, { l: 21, w: 26, h: 2 }, { l: 10, w: 24, h: 27 }, { l: 10, w: 16, h: 28 }, { l: 18, w: 16, h: 23