Skip to content

Instantly share code, notes, and snippets.

View peterfication's full-sized avatar

Peter Morgenstern peterfication

View GitHub Profile
@peterfication
peterfication / brew-install.sh
Created January 29, 2016 12:22 — forked from jsz0/brew-install.sh
my default brew/cask installs
# firsrun:
# install xcode-cli-tools
# xcode-select --install
# install homebrew
# ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# install caskroom
# brew install caskroom/cask/brew-cask
# update/install:
@peterfication
peterfication / decode_yakbak.js
Created November 27, 2016 10:17
Decode body response created by https://github.com/flickr/yakbak
var zlib = require('zlib');
var gunzip = zlib.createGunzip();
var buf1 = new Buffer("...", "base64")
var buf2 = new Buffer("...", "base64")
var buf3 = new Buffer("...", "base64")
var buf = Buffer.concat([buf1, buf2, buf3])
zlib.gunzip(buf, function(err, dezipped) {
console.log(dezipped.toString())
});

Keybase proof

I hereby claim:

  • I am peterfication on github.
  • I am peterfication (https://keybase.io/peterfication) on keybase.
  • I have a public key ASC_g4c6ErfhnPFz892Od0c5GvZA-BVhu4RhxgBASalbSgo

To claim this, I am signing this object:

@peterfication
peterfication / vimgolf.js
Created April 19, 2017 08:22
Get all challenges of vimgolf.com as a list that can be copy and pasted into a spreadsheet.
// Copy and paste this script into the Javascript console at https://www.vimgolf.com
// and you get a tab delimited list of the entries that can be copied and pasted
// into a spreadsheet.
var resultString = [];
$('#content .grid_7 div h5').each(function(i, e) {
var $link = $(e).find('a');
var url = 'https://www.vimgolf.com' + $link.attr('href');
var urlParts = url.split('/');
var challengeID = urlParts[urlParts.length - 1];
// Analyze asana task export in JS console
// Format of a task title has to be "[estimated amount of time] title (Actual time used for the task)"
// It prints out the average deviation of the estimated time
// Open the export JSON in Chrome and run this script in the browser console
if (typeof(x) === 'undefined') {
const x = JSON.parse($('pre').innerHTML)
}
var differences = []
@peterfication
peterfication / sweetalert_rails_confirm_old.js
Last active November 30, 2017 06:48
Rails SweetAlert confirm old
// Override the default confirm dialog of Rails
$.rails.handleConfirm = link => {
if (link.data('confirm') === undefined){
return true
}
showSweetAlertConfirmationDialog(link)
return false
}
@peterfication
peterfication / sweetalert_rails_confirm_new_wrong.js
Last active November 30, 2017 06:49
First try SweetAlert Rails confirm new
// Override the default confirm dialog of Rails
Rails.handleConfirm = link => {
if (link.data('confirm') === undefined){
return true
}
showSweetAlertConfirmationDialog(link)
return false
}
@peterfication
peterfication / rails_sweetalert_confirm_webpacker.js
Last active November 28, 2017 15:36
Rails SweetAlert confirm Webpacker
import Rails from 'rails-ujs';
const handleConfirm = () => {
// Do your thing
}
// Add event listener before the other Rails event listeners like the one
// for `method: :delete`
Rails.delegate(document, 'a[data-confirm-swal]', 'click', handleConfirm)
const handleConfirm = link => {
// Do your thing
}
Rails.delegate(document, 'a[data-confirm-swal]', 'click', handleConfirm)
document.addEventListener('rails:attachBindings', element => {
Rails.delegate(document, 'a[data-confirm-swal]', 'click', handleConfirm)
})