Skip to content

Instantly share code, notes, and snippets.

SC.ShowHelper = SC.View.extend
# We bind to either of these values...
if: true
unless: false
# ... to control visibility.
shouldDisplay: (->
@get('if') and not @get('unless')
).property('if', 'unless')
//= require_self
//= require sproutcore
//= require my_other_library
//= require_tree ./test
// Some trivial stubs that allow all the above to load gracefully without a browser.
document = {};
jQuery = function(){return {ready: function(){}}};
require 'v8'
@ctxt = V8::Context.new
@ctxt.eval(Rails.application.assets.find_asset('test').to_s)
@ef4
ef4 / jasmine-reporter.js
Created September 15, 2011 18:58
Minimal Jasmine Setup for Browser & Console with Rails 3.1
//
// Jasmine Reporter for theubyracer on the console
//
// Originally adapted from https://github.com/mhevery/jasmine-node
//
// Helpers
//
App.AgendaController = SC.Object.extend
month: (->
if m = /agenda\/(\d+)/.exec(@get('subpath'))
Number(m[1])
else
(new Date).getMonth() + 1
).property('subpath').cacheable()
year: (->
if m = /agenda\/\d+\/(\d+)/.exec(@get('subpath'))
App.AgendaController = SC.Object.extend
month: (->
if m = /agenda\/(\d+)/.exec(@get('subpath'))
Number(m[1])
else
(new Date).getMonth() + 1
).property('subpath').cacheable()
year: (->
if m = /agenda\/\d+\/(\d+)/.exec(@get('subpath'))
@ef4
ef4 / usb-headset.sh
Created March 18, 2012 15:08
Automatically switch all PulseAudio streams to a USB headset
#!/bin/bash
# Adapted from Erik Johnson's script at
# http://terminalmage.net/2011/11/17/setting-a-usb-headset-as-the-default-pulseaudio-device/
#
# Updated by Edward Faulkner <ef@alum.mit.edu> to move existing
# streams and eliminate the extra fork script.
# You'll need to change these to point at your headset device.
OUTPUT="alsa_output.usb-Generic_FREETALK_Everyman_0000000001-00-Everyman.analog-stereo"
@ef4
ef4 / gist:6399936
Created August 31, 2013 18:51
chroot creation for owncloud
cd /var/lib/owncloud
tar -c /dev/null /dev/zero /dev/urandom /etc/timezone /etc/resolv.conf /etc/hosts /etc/localtime /usr/share/zoneinfo | tar x
mkdir -m 1733 -p ./var/lib/php5
mkdir -m 1777 ./tmp
@ef4
ef4 / gist:6399944
Created August 31, 2013 18:52
php5-fpm configuration for owncloud
[owncloud]
user = owncloud
listen = /var/run/php5-fpm-owncloud.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0600
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
@ef4
ef4 / gist:6399951
Created August 31, 2013 18:53
nginx config for owncloud
server {
listen 80;
return 301 https://$server_name$request_uri; # enforce https
}
server {
listen 443 ssl;
ssl_certificate your_certificate_filename;
ssl_certificate_key your_certificate_key;