Skip to content

Instantly share code, notes, and snippets.

Troy Kruthoff troyk

View GitHub Profile
@troyk
troyk / hnjobsfilter.js
Last active Aug 1, 2019
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 Apr 10, 2019
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 Jan 26, 2018
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 Apr 7, 2016
golang jwt example
View jwt.go
package cmd
import (
"encoding/json"
"flag"
"fmt"
"os"
"regexp"
"strings"
@troyk
troyk / db.go
Created Nov 12, 2015
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 Oct 2, 2015
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 Apr 22, 2015
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 Feb 27, 2015
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
@troyk
troyk / stringer.ex
Created Feb 5, 2015
This aint so bad is it??
View stringer.ex
defmodule Rocket.Stringer do
def sanitize_phone(ph) do
ph = Regex.replace(~r/[^0-9]/,ph,"")
case Regex.run(~r/\d{5,10}$/,ph) do
[phone] -> phone
_ -> nil
end
end
You can’t perform that action at this time.