Skip to content

Instantly share code, notes, and snippets.

View troyk's full-sized avatar

Troy Kruthoff troyk

View GitHub Profile
@troyk
troyk / hubcode.zsh
Created February 10, 2021 18:53
zsh must haves
View hubcode.zsh
hubcode () {
local repo=$1
[[ ! $repo =~ "https://*" ]] && repo="https://github.com/${repo}"
local temp="$(mktemp -d)"
git clone --depth 1 "${repo}" "${temp}"
code --wait -n "${temp}"
rm -rf "${temp}"
}
@troyk
troyk / hnjobsfilter.js
Last active August 1, 2019 17:34
filter HN who's hiring to golang, elixir and ruby
View hnjobsfilter.js
var gojobs = 0, elixirjobs = 0, rubyjobs = 0;
document.querySelectorAll('.athing.comtr').forEach(function(el){
var text = el.innerText.toLowerCase();
var show = false;
if (text.indexOf('golang')>0 || text.indexOf(', go ')>0 || text.indexOf(' go,')>0) {
gojobs++; show=true;
}
if (text.indexOf('elixir')>0) {
elixirjobs++; show=true;
}
@troyk
troyk / just_use_fkeys.sql
Created April 10, 2019 23:33
Polymorphic relationships with triggers in postgresql
View just_use_fkeys.sql
-- saving here for later reference incase I decide to complicate things, decided to just use foreign keys
create table user_groups {
id bigint PRIMARY KEY default id_generator(),
account_id bigint not null references accounts(id) on delete cascade on update cascade,
updated_at timestamptz,
name citext not null
}
CREATE TYPE notification_level AS ENUM ('change', 'complete', 'digest', 'all');
@troyk
troyk / desc.txt
Last active January 26, 2018 17:48
300 char entry for HR startup of the year
View desc.txt
Next generation background screening technology disrupting the industry with mobile first candidate experience, automated compliance, single-sign-on integrations and fastest delivery (98% of reports, less than 27 hours)
@troyk
troyk / jwt.go
Created April 7, 2016 04:21
golang jwt example
View jwt.go
package cmd
import (
"encoding/json"
"flag"
"fmt"
"os"
"regexp"
"strings"
@troyk
troyk / db.go
Created November 12, 2015 23:17
golang sql query abstraction
View db.go
package db
import (
"database/sql"
"log"
"strings"
"sync"
_ "github.com/lib/pq" // required for database/sql
"golang.org/x/net/context"
@troyk
troyk / restart
Created October 2, 2015 22:39
restart script for blit
View restart
#!/bin/bash
# sudo stop www-blit.com
# rm /var/www/blit/tmp/puma/*
# sudo start www-blit.com
# TODO: figure out how to restart sidekiq
ps auxf | grep "blit"
blit_puma_pid=$(ps -C ruby -F | grep '/puma.*\[blit\]' | awk {'print $2'})
echo "sending SIGUSR1 to pid $blit_puma_pid"
kill -s SIGUSR1 $blit_puma_pid
@troyk
troyk / cmd
Created April 22, 2015 21:25
how to compile bootstrap
View cmd
lessc bootstrap.less --clean-css="--s1 --advanced --compatibility=ie8" > ~/Projects/textrocket/public/css/lib/
View limit.maxfiles.plist
<?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>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
@troyk
troyk / activerecord
Created February 27, 2015 23:59
AR vs Sequel in real world rails scenario
View activerecord
Summary:
Total: 13.0664 secs.
Slowest: 0.3004 secs.
Fastest: 0.0760 secs.
Average: 0.1303 secs.
Requests/sec: 76.5321
Status code distribution:
[200] 1000 responses