Skip to content

Instantly share code, notes, and snippets.

@tjbladez
tjbladez / computed.coffee
Created May 8, 2012 17:16
basic computed properties in backbone
Namespace.models.Base = Backbone.Model.extend
initialize: ()->
Backbone.Model::initialize @, arguments
return if _.isUndefined(@computed)
@_computed = {}
for attr, dependencies of @computed
@on "change:#{attr}", ()=>
@parndt
parndt / pre-commit
Last active December 16, 2015 11:59 — forked from ideasasylum/pre-commit
Place this in ~/.git_template/hooks/pre-commit and chmod to 755. Now, ensure you have git >= 1.7.1 and run: git config --global init.templatedir '~/.git_template' Back in your repository, run git init again and the hook will appear.
#!/usr/bin/env ruby
spec_hits = []
checks = {
'_spec\.rb$' => ['focus:[:space:]*true'],
'\.rb$' => ['binding\.pry', 'debugger']
}
# Find the names of all the filenames that have been (A)dded (C)opied or (M)odified
filenames = `git diff --cached --name-only --diff-filter=ACM`.split("\n")
@alexaivars
alexaivars / setter_pattern.coffee
Created January 12, 2012 08:41
Getter Setter patter for Coffeescript
Function::define = (prop, desc) ->
Object.defineProperty this.prototype, prop, desc
class GetterSetterTest
constructor: (@_obj = {}) ->
# 'obj' is defined via the prototype, the definition proxied through
# to 'Object.defineProperty' via a function called 'define' providing
# some nice syntactic sugar. Remember, the value of '@' is
# GetterSetterTest itself when used in the body of it's class definition.
@garthk
garthk / profile
Created June 21, 2015 23:51
boot2docker 1.7.0 cert fix
wait4eth1() {
CNT=0
until ip a show eth1 | grep -q UP
do
[ $((CNT++)) -gt 60 ] && break || sleep 1
done
sleep 1
}
wait4eth1
@bryanstearns
bryanstearns / gist:4331076
Created December 18, 2012 19:23
I put this in my basebox postinstall scripts to help NTP deal with large time differences
# Make sure ntpd doesn't give up if the time is way off
cp /etc/ntp.conf /etc/ntp.conf.old
(echo tinker panic 0; cat /etc/ntp.conf.old) >/etc/ntp.conf
/etc/init.d/ntp restart
@brendanzab
brendanzab / reactive_systems_bibliography.md
Last active October 10, 2022 06:36
A reading list that I'm collecting while building my Rust ES+CQRS framework: https://github.com/brendanzab/chronicle

Functional, Reactive, and Distributed Systems Bibliography

Books

@garybernhardt
garybernhardt / selectable_queue.rb
Last active November 23, 2022 12:42
A queue that you can pass to IO.select.
# A queue that you can pass to IO.select.
#
# NOT THREAD SAFE: Only one thread should write; only one thread should read.
#
# Purpose:
# Allow easy integration of data-producing threads into event loops. The
# queue will be readable from select's perspective as long as there are
# objects in the queue.
#
# Implementation:
@lrytz
lrytz / z-automator.png
Last active February 4, 2023 21:20
Shortcut for Syntax Highlighting in Keynote
@johnllao
johnllao / HelloProto.java
Created November 5, 2015 04:25
Protobuf Descriptor and Dynamic Messages
package org.hello.protobuf;
import java.util.Map;
import com.google.protobuf.*;
import com.google.protobuf.Descriptors.*;
import com.google.protobuf.DescriptorProtos.*;
public class HelloProto {
@leifg
leifg / Vagrantfile
Last active November 12, 2023 08:31
Add a second disk to system using vagrant
file_to_disk = './tmp/large_disk.vdi'
Vagrant::Config.run do |config|
config.vm.box = 'base'
config.vm.customize ['createhd', '--filename', file_to_disk, '--size', 500 * 1024]
config.vm.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
end