Skip to content

Instantly share code, notes, and snippets.

View onpaws's full-sized avatar
🚴‍♂️
building things

Pat onpaws

🚴‍♂️
building things
View GitHub Profile
@onpaws
onpaws / resetSSHsession
Created December 30, 2015 21:18
how to reset SSH connection
If you wake up your laptop and a previous SSH connection is broken, but you want to keep your local shell:
[Enter] ~ .
@onpaws
onpaws / daylightsavings.sh
Created December 30, 2015 23:28
daylight savings zone file
[ubuntu@myhost ~]$ zdump -v America/New_York | grep 2016
America/New_York Sun Mar 13 06:59:59 2016 UTC = Sun Mar 13 01:59:59 2016 EST isdst=0 gmtoff=-18000
America/New_York Sun Mar 13 07:00:00 2016 UTC = Sun Mar 13 03:00:00 2016 EDT isdst=1 gmtoff=-14400
America/New_York Sun Nov 6 05:59:59 2016 UTC = Sun Nov 6 01:59:59 2016 EDT isdst=1 gmtoff=-14400
America/New_York Sun Nov 6 06:00:00 2016 UTC = Sun Nov 6 01:00:00 2016 EST isdst=0 gmtoff=-18000
@onpaws
onpaws / puma.rb
Created May 12, 2016 02:57
rails 5.0.0.rc1 unmodified
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
//fetch() is based on Promises
fetch('http://api.github.com/users')
.then(result => console.log(result))
//ES7 async/await
async function getMovieAsync() {
let response = await fetch('http://www.omdbapi.com/?t=The Matrix');
let movie = await response.json();
console.log(movie.Title);
}
@onpaws
onpaws / keybase.md
Created June 15, 2016 18:32
keybase github identity proof

Keybase proof

I hereby claim:

  • I am onpaws on github.
  • I am paws (https://keybase.io/paws) on keybase.
  • I have a public key ASBYTLCqxqixhZqWbEbHt8HsAsumyJhzaKIkqoRN2DB-IQo

To claim this, I am signing this object:

@onpaws
onpaws / fetch.js
Last active June 18, 2016 17:53
fetch()
/* Sample of using fetch() Promise API */
fetch('http://api.github.com/users')
.then(response => console.log(response), error => console.error(error));
//Readable Stream
fetch('http://api.github.com/users')
.then(response => console.log(response.body), error => console.error(error));
//via https://jakearchibald.com/2015/thats-so-fetch/
fetch('/big-data.csv').then(function(response) {
@onpaws
onpaws / randomSelect.js
Last active June 18, 2016 16:40
select random array member
arr = ['Brad', 'Dan', 'Jessica','Rachel']
random = Math.floor(Math.random() * arr.length)
console.log(arr[random])
@onpaws
onpaws / nativeEvents.js
Created August 3, 2016 19:01
simulate a click without jQuery (native fire event)
function eventFire(el, etype){
if (el.fireEvent) {
el.fireEvent('on' + etype);
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
}
}
eventFire(document.getElementById('submitButton'), 'click');
@onpaws
onpaws / mysql-mini.rb
Created August 21, 2016 20:54
ruby instantiate mysql client
require 'mysql2'
client = Mysql2::Client.new(:host => "localhost", :username => "shippable")
results = client.query('use mysql')
@onpaws
onpaws / dtrace-samples
Created August 30, 2016 18:15
DTrace samples from
# gleaned from BCantrill's Google talk via
# https://www.youtube.com/watch?v=6chLw2aodYQ
sudo dtrace -n syscall:::entry
sudo dtrace -n syscall:::entry{trace(execname)}
sudo dtrace -n syscall:::entry'{@[execname] = count()}' #@ means aggregation in D
#how manys syscalls did Chrome Canary make?
sudo dtrace -n syscall:::entry/execname == "Google Chrome Ca"/{@[probefunc] = count()}