Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Phil Hansch phansch

🎯
Focusing
View GitHub Profile
@youhide
youhide / build.yml
Created Oct 25, 2019
GitHub Actions - Build for Windows, MacOS, Linux and release on tag.
View build.yml
name: Node CI
on:
push:
tags:
- 'v*'
jobs:
upload-release:
@jinnko
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
# https://askubuntu.com/questions/1024281/dell-xps-13-9370-bluetooth-issues/1148484#1148484
#
# 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 https://www.dell.com/support/home/uk/en/ukbsdt1/drivers/driversdetails?driverId=1JVK3
@henrik
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
end
input = :good
cond(input,
good: -> { puts "So good!" },
bad: -> { puts "So bad!" },
@ascclemens
ascclemens / travis_cache.md
Last active Apr 21, 2020
Rust and Travis CI cache
View travis_cache.md

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
odigity / knex.js
Last active Feb 2, 2021
Wrapping a unit test in a transaction for easy cleanup with Knex.js
View knex.js
#!/usr/bin/node
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
phansch / yardoc_cheatsheet.md
Last active Jul 9, 2021 — forked from chetan/yardoc_cheatsheet.md
Improved YARD cheatsheet
View yardoc_cheatsheet.md
@CoryFoy
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 = 'https://www.googleapis.com/auth/analytics.readonly'
@client = AnalyticsReportingService.new
@zmalltalker
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 https://gist.github.com/zmalltalker/5900206/raw/b9d7c2263cef981a8384a4e2b513e67c70060436/gistfile1.pp)`
View gist:5900206
# chruby
# ruby-install
# ruby 1.9.3
# /etc/profile.d/chruby.sh
Exec {
path => ["/bin","/usr/bin", "/usr/local/bin"]
}
file { "/etc/profile.d/chruby.sh":
ensure => present,
@jordelver
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
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
DATABASE = ''