Skip to content

Instantly share code, notes, and snippets.

Gabriel Vivas gabssnake

View GitHub Profile
@gabssnake
gabssnake / hooks.js
Created Apr 29, 2020
Using callbacks as iterators à la React Hooks
View hooks.js
// Not my credit, this comes from @jedschmidt on Twitter
// https://twitter.com/jedschmidt
// Example usage:
//
// void async function() {
// let [clicks, onclick] = iterator()
// document.querySelector('button').addEventListener('click', onclick)
// for await (let click of clicks) console.log(click)
// }()
@gabssnake
gabssnake / tracker_blocking.rb
Created Apr 24, 2020 — forked from dhh/tracker_blocking.rb
Current list of spy pixels named'n'shamed in HEY, as of April 23, 2020
View tracker_blocking.rb
module Entry::TrackerBlocking
extend ActiveSupport::Concern
included do
has_many :blocked_trackers
end
email_service_blockers = {
"ActiveCampaign" => /lt\.php(.*)?l\=open/,
"AWeber" => "openrate.aweber.com",
@gabssnake
gabssnake / .colors
Created Dec 15, 2019 — forked from daytonn/.colors
Bash Color functions
View .colors
# Colors
end="\033[0m"
black="\033[0;30m"
blackb="\033[1;30m"
white="\033[0;37m"
whiteb="\033[1;37m"
red="\033[0;31m"
redb="\033[1;31m"
green="\033[0;32m"
greenb="\033[1;32m"
View FizzBuzz.js
// Separate rules from work
const rules = { '3': 'Fizz', '5': 'Buzz' }
const fbuzz = i => Object.keys(rules).reduce((s, n) => s + (i % n ? '' : rules[n]), '') || i
for (let i = 1; i <= 100; i++) console.log(fbuzz(i))
@gabssnake
gabssnake / scrdec18-VC8.exe
Created Sep 1, 2017 — forked from bcse/scrdec18-VC8.exe
Windows Script Decoder 1.8 (Decoding JScript.Encoded)
@gabssnake
gabssnake / index.js
Last active Jan 20, 2017
Bloomrun perf tests
View index.js
'use strict'
var async = require('async')
var dependency = require('bloomrun')
var tests = require('./tests')
function measure (test) {
return function (i, done) {
var time = process.hrtime()
test(err => done(err, process.hrtime(time)))
@gabssnake
gabssnake / SimpleSpy.js
Created Oct 2, 2015
Javascript Spy on object method. Keeps the arguments of each call and can be later destroyed
View SimpleSpy.js
function Spy (object, method) {
var original = object[method];
var spy = {
calls: [],
destroy: function () {
object[method] = original;
}
};
object[method] = function () {
var args = Array.prototype.slice.call(arguments);
View wget copy website recursive.txt
wget \
--recursive \
--no-parent \
--page-requisites \
--no-clobber \
--html-extension \
--convert-links \
--restrict-file-names=windows \
View osx-10.10-setup.md

Mac OS X 10.10 Yosemite

Custom recipe to get OS X 10.10 Yosemite running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

Install Software

View __ js placeholder mini polyfill.js
// simple placeholder polyfill (requires jQuery)
// http://snippetrepo.com/snippets/html5-placeholder-on-ie8-input-fields
(function($, document){
var test = document.createElement('input');
var polyfill = function () {
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
You can’t perform that action at this time.