Use node-inspector to debug hubot!
sudo npm install -g node-inspector
coffee --nodejs --debug $(which hubot)
class Singleton(type): | |
instance = None | |
def __call__(cls, *args, **kwargs): | |
if cls.instance is None: | |
cls.instance = super(Singleton, cls).__call__(*args, **kwargs) | |
return cls.instance | |
if __name__ == '__main__': |
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc | |
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/ | |
// author: Pawel Kozlowski | |
var myApp = angular.module('myApp', []); | |
//service style, probably the simplest one | |
myApp.service('helloWorldFromService', function() { | |
this.sayHello = function() { | |
return "Hello, World!" |
import com.eclecticdesignstudio.motion.Actuate; | |
import cpp.vm.Thread; | |
import nme.display.Sprite; | |
import nme.events.Event; | |
import nme.Lib; | |
class ThreadingExample extends Sprite { | |
When using the linux utility dd, there is no visual output of the progress, how long it is going to take, or anything else. Easy to solve with the use of pv: | |
% sudo fdisk -l | |
% pv /dev/sda | dd of=/dev/sdb bs=100M | |
that’ll display the amount of data transferred, the elapsed time, the throughput speed, a nice progress bar, and the ETA. For devices that do not have a fixed size, let’s say, /dev/zero, there’ll be only a throughput display. | |
- http://www.yournearestbar.com/2011/10/monitoring-dd-with-a-progress-bar/ |
Use node-inspector to debug hubot!
sudo npm install -g node-inspector
coffee --nodejs --debug $(which hubot)
As configured in my dotfiles.
start new:
tmux
start new with session name:
# Run command(s) over SSH | |
run() { | |
ssh deploy@${HOST} -t $* || exit 1 | |
} | |
# Transfer all the specified files/directories to working directory | |
upload() { | |
tar czf - $* | ssh deploy@${HOST} tar xzf - -C /etc/chef || exit 1 | |
} |
#!/usr/bin/env lua | |
-- Posted this online because of http://news.ycombinator.com/item?id=3535349 | |
ordered = {} | |
index = {} | |
need_continuation = false | |
first_continued_line = 0 | |
function add_or_replace(line) |
# Ruby is using Duck Typing, rather than checking types, Ruby checks if an object can or cannot respond to a method. | |
# Here is a "port" of the Haxe example in Ruby. | |
# Ruby is not a compiled language, so that the "easiest" syntax comes with some shortcoming, | |
# those errors can only be detected at runtime, your favorite IDE won't warn you before :) | |
ints = [1, 2, 3] | |
strings = ["a", "bb", "ccc"] | |
def biggerThan1(x) | |
x > 1 |
# Use: it { should accept_nested_attributes_for(:association_name).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })} | |
RSpec::Matchers.define :accept_nested_attributes_for do |association| | |
match do |model| | |
@model = model | |
@nested_att_present = model.respond_to?("#{association}_attributes=".to_sym) | |
if @nested_att_present && @reject | |
model.send("#{association}_attributes=".to_sym,[@reject]) | |
@reject_success = model.send("#{association}").empty? | |
end | |
model.send("#{association}").clear |