This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This program shows the result of applying the % and # shell parameter | |
# expansion modifiers to a parameter, for those who are constantly looking it | |
# up. | |
x=${1:?Usage: parmexp <parameter>} | |
echo "(hash dot star) ‥‥‥‥‥‥‥‥....... $x \${x#.*} → ${x#.*}" | |
echo "(hash hash dot star) .......... $x \${x##.*} → ${x##.*}" | |
echo "(percent dot star) ............ $x \${x%.*} → ${x%.*}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"bytes" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"testing" | |
) | |
type incrt byte |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
name="My Cool Web App Project" | |
serve="npm start" | |
watch="node_modules/.bin/cake watch" | |
serve="npm start" | |
tmux has-session -t "$name" | |
if [ $? != 0 ] | |
then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Script to update this host's DNS entry on Cloudflare. Silently succeeds. | |
It requires you to have set the environment variables: | |
- CLOUDFLARE_API_KEY | |
- CLOUDFLARE_EMAIL | |
- CLOUDFLARE_HOSTNAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of using | |
require 'sqlite3' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection("sqlite3::memory:") | |
conn = ActiveRecord::Base.connection | |
conn.create_table :users do |t| | |
t.string :name | |
end | |
conn.create_table :user_matches do |t| | |
t.references :sender |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl -CS | |
# Look up metadata for a tracks. Uses fpcalc, which comes with AcoustID | |
# Chromaprint (bitbucket.org/acoustid/chromaprint), the AcoustID web service, | |
# and the Musicbrainz web service. | |
# | |
# Run it with no arguments for help. | |
# | |
# For each file, it prints: | |
# * the filename | |
# * the result "score" (how likely a match it is, 0-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require 'objspace' | |
trap("PROF") do | |
if $__PROFILING__ | |
GC.start | |
filename = Time.now.strftime("objects-%Y%m%d%H%S.json") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env perl | |
# Takes input like | |
# 1 | |
# 2 | |
# 3 | |
# and outputs | |
# (1, 2, 3) | |
# | |
# Useful for converting a single column of SQL IDs to a list that you can use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env perl | |
# A simple command-line utility for finding and retrieving JavaScript libraries | |
# from cdnjs.com | |
use strict; | |
use warnings; | |
use LWP::Simple; | |
my $lib = shift or die "No script entered on the command-line!"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Capistrano 3.x Vagrant stage | |
# config/deploy/vagrant.rb | |
set :stage, :vagrant | |
set :rails_env, "production" | |
vagrant_ssh_config = `vagrant ssh-config`.split("\n")[1..-1].map(&:strip).inject({}) do |m, s| | |
k, v = s.split(/\s/, 2).map(&:strip); m[k] = v; m | |
end |