Skip to content

Instantly share code, notes, and snippets.

@searls
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
adamwathan / v-cloak.md
Last active Mar 13, 2021
Useful CSS utilities for Vue.js cloaking
View v-cloak.md

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

Use like:

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

Encoding Video

Installing

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
dideler / upgrade-postgres-9.3-to-9.4.md
Last active Jun 8, 2020
Upgrading PostgreSQL from 9.3 to 9.4 when upgrading Ubuntu 14.04 to 14.10
View upgrade-postgres-9.3-to-9.4.md

TL;DR

Create a backup:

pg_dumpall > mybackup.sql

Perform the upgrade:

sudo pg_dropcluster 9.4 main --stop
@t2
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!']
DATE_TIME_FORMAT = '%Y-%m-%d'
def initialize(birthdate, opts={})
@brandonkelly
brandonkelly / templating.md
Last active Oct 27, 2020
Templating in EE vs. Craft
View templating.md
@jonbretman
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
alex-zige / gist:5795358
Last active Feb 27, 2021
Rails Rspec API Testing Notes
View gist:5795358

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
  |--- views
@indec
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 "com.apple.preference.sound"
tell application "System Events"
tell process "System Preferences"
@jlong
jlong / uri.js
Created Apr 20, 2012
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"