Skip to content

Instantly share code, notes, and snippets.

View cpuspellcaster's full-sized avatar

Dahlia Kelsey cpuspellcaster

  • Los Angeles
  • 23:13 (UTC -08:00)
View GitHub Profile
DELIMITER $$
DROP PROCEDURE IF EXISTS add_email_address_column_to_customers_table $$
-- Create the stored procedure to perform the migration
CREATE PROCEDURE add_email_address_column_to_customers_table()
BEGIN
-- Add the email_address column to the customers table, if it doesn't already exist
# installs to /opt/gradle
# existing versions are not overwritten/deleted
# seamless upgrades/downgrades
# $GRADLE_HOME points to latest *installed* (not released)
gradle_version=1.11
wget -N http://services.gradle.org/distributions/gradle-${gradle_version}-all.zip
sudo mkdir -p /opt/gradle
sudo unzip -fo gradle-${gradle_version}-all.zip -d /opt/gradle
sudo ln -sfn gradle-${gradle_version} /opt/gradle/latest
sudo printf "export GRADLE_HOME=/opt/gradle/latest\nexport PATH=\$PATH:\$GRADLE_HOME/bin" | sudo tee /etc/profile.d/gradle.sh > /dev/null
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten

ETags: a pretty sweet feature of HTTP 1.1

HTTP caching review

HTTP provides two ways for servers to control client-side caching of page components:

  • freshness may be based on a date or a token whose meaning is app-specific
  • whether or not the client needs to confirm the cached version is up-to-date with the server

This breaks down as follows:

  • Cache locally and don't check before using.

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.31090480089187622</real>
<key>Green Component</key>
<real>0.31097450852394104</real>
@cpuspellcaster
cpuspellcaster / build-openjdk9-osx.sh
Last active September 19, 2015 03:19 — forked from bonifaido/build-openjdk9-osx.sh
Build OpenJDK 9 Zero(Shark) on Mac OS X Yosemite (bash build-openjdk9-osx.sh)
#!/bin/bash
# Latest Mercurial, OS X Command Line Tools, JDK 8 and libffi are needed
# Tested with OSX 10.10.3 and Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
brew install mercurial
brew install libffi
brew link libffi --force
# only needed if you build the zeroshark variant
# brew install llvm
# brew link llvm --force
hg clone http://hg.openjdk.java.net/jdk9/jdk9
@cpuspellcaster
cpuspellcaster / gist:44b447aeaa6b113dea8f
Created September 27, 2015 21:12
Gradle Task to write a Java classpath to a textfile named .classpath
task writeClasspath << {
buildDir.mkdirs()
new File(buildDir, ".classpath").text = configurations.runtime.asPath + "\n"
}
@cpuspellcaster
cpuspellcaster / streamToPromise.js
Last active May 14, 2016 05:37
For those times when you need to promise but you want to stream: https://jsla.slack.com/archives/general/p1463179910000661
function streamToPromise (stream) {
return new Promise((resolve, reject) => {
stream.on('end', resolve)
stream.on('error', reject)
})
}