Skip to content

Instantly share code, notes, and snippets.

View alvinlai's full-sized avatar

Alvin Lai alvinlai

  • Mountain View, CA
View GitHub Profile
#!/bin/sh
OSX_VERS=$(sw_vers -productVersion | awk -F "." '{print $2}')
# Get Xcode CLI tools
# https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-3905972D-B609-49CE-8D06-51ADC78E07BC.dvtdownloadableindex
TOOLS=clitools.dmg
if [ ! -f "$TOOLS" ]; then
if [ "$OSX_VERS" -eq 7 ]; then
DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_xcode_os_x_lion_april_2013.dmg
elif [ "$OSX_VERS" -eq 8 ]; then

Install OS X 10.10 Yosemite in VirtualBox

(based on this pastebin i've found via Google, markdownified and adjusted to work with the official Yosemite release)

Yosemite's first developer preview was released right after Monday's WWDC opening keynote. For the general public, an open beta will be available to download later this summer. However, for those who want a sneak peek at the new hotness, there is a way to safely install it without risking your machine, using the free and powerful VirtualBox application from Oracle.

(LEGAL DISCLAIMER: This guide aims to explain how to create a virtual machine on a regularly purchased Apple computer, running a genuine Mac OS X operating system, for testing purposes only.)

do shell script "xcode-select --install"
do shell script "sleep 1"
tell application "System Events"
tell process "Install Command Line Developer Tools"
keystroke return
click button "Agree" of window "License Agreement"
end tell
end tell

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

require './hash-table'
describe MyHash do
rspec_hash = MyHash.new
describe '#assign_or_find_index' do
it 'should return a number between 0 and 100' do
random_string = (0...8).map { (65 + rand(26)).chr }.join
expect(rspec_hash.assign_or_find_index(random_string)).to be_between(0, 100)
end
class MyHash
attr_reader :buckets
def initialize
@buckets = []
end
def assign_or_find_index(k)
special_function(k) % 100
end
//
// RVNReceiptValidation.m
//
// Created by Satoshi Numata on 12/06/30.
// Copyright (c) 2012 Sazameki and Satoshi Numata, Ph.D. All rights reserved.
//
// This sample shows how to write the Mac App Store receipt validation code.
// Replace kRVNBundleID and kRVNBundleVersion with your own ones.
//
// This sample is provided because the coding sample found in "Validating Mac App Store Receipts"

Experimental Generation of Interpersonal Closeness

Instructions to Subjects Included With Task Slips Packet

This is a study of interpersonal closeness, and your task, which we think will be quite enjoyable, is simply to get close to your partner. We believe that the best way for you to get close to your partner is for you to share with them and for them to share with you. Of course, when we advise you about getting close to your partner, we are giving advice regarding your behavior in this demonstration only, we are not advising you about your behavior outside of this demonstration.

In order to help you get close we've arranged for the two of you to engage in a kind of sharing game. You're sharing time will be for about one hour, after which time we ask you to fill out a questionnaire concerning your experience of getting close to your partner.

You have been given three sets of slips. Each slip has a question or a task written on it. As soon as you both finish reading these instructions, you should

@alvinlai
alvinlai / handsondockernotes.md
Last active August 29, 2015 14:11
Handson Dockernotes Update

Notes

This was preventing the alvin/handson-postgres image from being downloaded:

moby/moby#9327

I had to modify the Dockerfiles and rebuild them for a couple of reasons:

  • docker pull only downloads images tagged 'latest'. While this can be circumvented with a -a flag, it didn't seem to work for me.
  • the old images were built off ubuntu 12.10 which is deprecated, apt sources for that version is no longer available.
@alvinlai
alvinlai / gist:b4cf0f92767b8fb8a687
Created December 8, 2014 23:22
Postgres on OS X
To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
postgres -D /usr/local/var/postgres