Skip to content

Instantly share code, notes, and snippets.

@rwjblue
rwjblue / components.my-component.js
Last active September 1, 2015 18:44
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
// Computed property doesn't get the num changes when we have a didReceiveAttrs() defined. If we remove didReceiveAttrs(), it will work.
didReceiveAttrs() {
this._super(...arguments);
},
// Defining will make the computed property to work even if didReceiveAttrs() is defined.
@rwjblue
rwjblue / pconsole.sh
Created February 20, 2012 18:38 — forked from rondale-sc/pconsole.sh
pconsole bash/zsh alias
pconsole () {
if [[ -e ./config/environment.rb ]];
then
rails_env="development"
if [[ "$1z" != "z" ]]; then rails_env=$1; fi;
RAILS_ENV=$rails_env pry -r ./config/environment.rb -r rails/console/app -r rails/console/helpers;
else pry;
fi
}
@rwjblue
rwjblue / print_folder_tk.rb
Created June 26, 2012 18:09 — forked from pwelch/print_folder_tk.rb
Ruby/Tk script with GUI to print a folder using a system call to lp (CUPS). (Requires cups gem)
#!/usr/bin/env ruby
require 'tk'
require 'tkextlib/tile'
require 'tkextlib/bwidget'
require 'cups'
$dirname = TkVariable.new
root = TkRoot.new {title "Print Folder"}
@rwjblue
rwjblue / hour_intervals_from_times.rb
Created August 25, 2012 01:22 — forked from rondale-sc/hour_intervals_from_times.rb
Calculate percentage of interval covered within a given hour.
def hour_intervals(start_time, stop_time)
results = Hash.new {|h,k| h[k] = Hash.new(0)}
(start_time.to_i..stop_time.to_i).step(60).collect do |minute|
minute_time = Time.at(minute)
interval = case minute_time.min
when (0..14) then 0
when (15..29) then 15
when (30..44) then 30
when (45..59) then 45
set project_directory to do shell script "find ~/ ~/Source ~/Source/ruby ~/Source/ruby/webapps -maxdepth 1 -type d -name " & q & " | head -1"
on pathexists(path)
try
path as alias
return true
on error
return false
end try
end pathexists
@rwjblue
rwjblue / application.controller.js
Last active November 20, 2015 02:53 — forked from amk221/application.controller.js
Component helper didUpdateAttrs bug
import Ember from 'ember';
export default Ember.Controller.extend({
version: Ember.VERSION,
value: 1,
actions: {
changeValue() {
this.incrementProperty('value')
}
}
@rwjblue
rwjblue / application.controller.js
Created November 21, 2015 15:50 — forked from courthead/application.controller.js
action bubbling weirdness
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
reportClick(element) {
alert(element);
}
}
class TestConnection
def repeat_test
while true do
if packet_loss > 0
`say 'link down'`
end
end
end
def packet_loss
@rwjblue
rwjblue / foo.diff
Created February 6, 2013 19:36 — forked from jonleighton/foo.diff
diff --git a/lib/spring/application.rb b/lib/spring/application.rb
index 6e241a8..69ef383 100644
--- a/lib/spring/application.rb
+++ b/lib/spring/application.rb
@@ -22,9 +22,6 @@ module Spring
@stdout = IO.new(STDOUT.fileno)
@stderr = IO.new(STDERR.fileno)
- @stdin = File.open('/dev/null', 'r')
-
require 'routes' # from routes.rb file below
class CreateRouteTests
def initialize(routes_file)
self.routes = ROUTES
end
def routes
@routes ||= ROUTES
end