Skip to content

Instantly share code, notes, and snippets.

searls / client.js
Created May 13, 2018
Sometimes I find it handy when I'm developing a single page app to have all front-end errors forwarded to the backend's log (when something doesn't work, I can look in a single terminal window)
View client.js
const puts = (...anything) => {
fetch("/api/puts", {
method: 'POST',
headers: {
'Content-Type': 'application/json'
body: JSON.stringify({content: anything})
adamwathan /
Last active Mar 13, 2021
Useful CSS utilities for Vue.js cloaking

Handy helpers for controlling visibility of elements until Vue has compiled.

Use like:

<div v-cloak>
    <span class="v-cloak--inline">Loading...</span> <!-- Only displayed before compiling -->
    <span class="v-cloak--hidden">{{ post.title }}</span> <!-- Hidden until compiling is finished -->
Vestride /
Last active May 5, 2021
Encoding video for the web

Encoding Video


Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
dideler /
Last active Jun 8, 2020
Upgrading PostgreSQL from 9.3 to 9.4 when upgrading Ubuntu 14.04 to 14.10


Create a backup:

pg_dumpall > mybackup.sql

Perform the upgrade:

sudo pg_dropcluster 9.4 main --stop
t2 / birthday_liker.rb
Last active Sep 23, 2016
Like and Comment on every 'Happy Birthday' post on your Facebook feed at once.
View birthday_liker.rb
require 'date'
require 'koala'
class BirthdayLiker
FACEBOOK_TOKEN = 'your_oauth_key'
BIRTHDAY_WORDS = %w(birthday bday birfday birth born)
THANKS_OPTIONS = ['Thank you!', 'Thanks!', 'Appreciate it!']
def initialize(birthdate, opts={})
brandonkelly /
Last active Oct 27, 2020
Templating in EE vs. Craft
jonbretman / type.js
Last active Jul 31, 2018
Simple type checking in JavaScript.
View type.js
(function (root) {
var type = function (o) {
// handle null in old IE
if (o === null) {
return 'null';
// handle DOM elements
alex-zige / gist:5795358
Last active Feb 27, 2021
Rails Rspec API Testing Notes
View gist:5795358

Rails Rspec APIs Testing Notes

Folders Structure

  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
  |--- views
indec / switch_audio.applescript
Last active Dec 17, 2015
An Applescript to cycle the audio input and output sources between two (or more) audio devices
View switch_audio.applescript
on alfred_script(q)
set output_devices to {"Display Audio", "Generic USB Audio Device "}
set input_devices to {"Display Audio", "Generic USB Audio Device "}
set device_keywords to {"speakers", "headphones"}
tell application "System Preferences"
reveal anchor "output" of pane id ""
tell application "System Events"
tell process "System Preferences"
jlong / uri.js
Created Apr 20, 2012
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "";
parser.protocol; // => "http:"
parser.hostname; // => ""
parser.port; // => "3000"
parser.pathname; // => "/pathname/"; // => "?search=test"
parser.hash; // => "#hash"; // => ""