Skip to content

Instantly share code, notes, and snippets.


Phil Hansch phansch

View GitHub Profile
youhide / build.yml
Created Oct 25, 2019
GitHub Actions - Build for Windows, MacOS, Linux and release on tag.
View build.yml
name: Node CI
- 'v*'
jinnko / patch-killer-firmware.zsh
Last active Jan 9, 2021
Automate patching Killer Wireless firmware on Ubuntu for Dell XPS 9370
View patch-killer-firmware.zsh
#!/usr/bin/env zsh
# See the following AskUbuntu question for why this is a thing
# As the overwritten files are owned by the linux-firmware package you may want to add this
# script to an @reboot cron of the root user.
# This script uses the Windows driver package as the src of the firmware bin files. This can
# be acquired from
henrik / 1-exhaustive_case_exact_match.rb
Last active Apr 15, 2019
Experimental Ruby exhaustive conditionals that raise if no branch matches. A bit like in e.g. Elm.
View 1-exhaustive_case_exact_match.rb
# This replaces conditions like: `case …; when …; when …; else raise "Nothing matched!"` if an exact match is all you need.
def cond(input, hash)
hash.fetch(input) { raise "No branch for #{input.inspect}!" }.call
input = :good
good: -> { puts "So good!" },
bad: -> { puts "So bad!" },
ascclemens /
Last active Apr 21, 2020
Rust and Travis CI cache

Rust and Travis CI cache

Using Travis CI's cache is very useful and helps cut Rust job times way, way down. However, the way that the default caching for Cargo is set up means it will quickly bloat.

Travis currently checks ~/.cargo and target/ for any changes from the current cache after a build. There will always be changes in target/ if the source has changed, which it usually does when a Travis build runs. This means new incremental object files, fingerprints, and build script compilation files are being added to the cache every build.

odigity / knex.js
Last active Feb 2, 2021
Wrapping a unit test in a transaction for easy cleanup with Knex.js
View knex.js
const Promise = require('bluebird')
const config = require('./config.json')
const knex = require('./lib/knex')(config.database).connection()
const mock = () => ({ user_id: Math.floor(Math.random() * 999) + 1, payload_type: 'foo', attributes: JSON.stringify({}) })
const before = (t) => {
phansch /
Last active Jul 9, 2021 — forked from chetan/
Improved YARD cheatsheet
CoryFoy / analytics.rb
Last active Mar 3, 2021
An example of calling the Analytics API using machine creds and the V4 API from Ruby
View analytics.rb
require 'google/apis/analyticsreporting_v4'
require 'googleauth'
include Google::Apis::AnalyticsreportingV4
include Google::Auth
VIEW_ID = "12345678" #your profile ID from your Analytics Profile
SCOPE = ''
@client =
zmalltalker / gist:5900206
Last active Nov 3, 2016
Install ruby-install, chruby and ruby 1.9.3 on Centos - Install puppet - Run `puppet apply <(curl -S`
View gist:5900206
# chruby
# ruby-install
# ruby 1.9.3
# /etc/profile.d/
Exec {
path => ["/bin","/usr/bin", "/usr/local/bin"]
file { "/etc/profile.d/":
ensure => present,
jordelver / gist:5806460
Created Jun 18, 2013
Sharing files using netcat
View gist:5806460

Sharing files using netcat

The receiver

nc -l 5566 > data-dump.sql

Listen on port 5566 and redirect output to data-dump.sql

The sender

tjh / character_set_and_collation.rb
Created Jan 31, 2012
Convert all Rails table column collation and character set
View character_set_and_collation.rb
#!/usr/bin/env ruby
# Put this file in the root of your Rails project,
# then run it to output the SQL needed to change all
# your tables and columns to the same character set
# and collation.
# > ruby character_set_and_collation.rb