Skip to content

Instantly share code, notes, and snippets.

View pablobm's full-sized avatar

Pablo Brasero pablobm

View GitHub Profile
def substitute_command_tokens(check)
unmatched_tokens = Array.new
substituted = check[:command].split(':::').each_with_index do |match, index|
next if index % 2 == 1
token, default = $1.to_s.split('|', -1)
matched = token.split('.').inject(@settings[:client]) do |client, attribute|
if client[attribute].nil?
default.nil? ? break : default
else
client[attribute]
@pablobm
pablobm / application.route.js
Last active August 30, 2015 17:58
Action skips route
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
ping(from) {
console.log("ApplicationRoute^ping from", from);
}
},
});
@pablobm
pablobm / application.route.js
Created September 3, 2015 22:08
Injection without container
import Ember from 'ember';
import MyModel from '../models/my-model';
export default Ember.Route.extend({
model() {
return MyModel.create();
},
});
#
# hputs(): makes debug messages readable when debugging specs with the TextMate RSpec bundle
#
def hputs(*args)
puts ERB::Util.html_escape(args.join("\n")).gsub(/\r?\n/, '<br/>') + '<br/>'
end
function bondage(object, method_name) {
return function() {
return object[method_name].apply(object, arguments);
}
}
class Person(){
}
Person.prototype.doSomething = function() {
// Do something...
require 'pp'
def substitute_command_tokens(check)
unmatched_tokens = Array.new
substituted = check[:command].gsub(/:::([^:]*?):::/) do
token, default = $1.to_s.split('|', -1)
matched = token.split('.').inject(@settings[:client]) do |client, attribute|
if client[attribute].nil?
default.nil? ? break : default
else
@pablobm
pablobm / application.controller.js
Last active September 20, 2015 11:00
Moving between routes
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@pablobm
pablobm / development_email_interceptor.rb
Created January 24, 2011 12:46
Print email to stdout and log/mail.log
# lib/development_email_interceptor.rb
class DevelopmentMailInterceptor
def self.delivering_email(message)
File.open(File.join(Rails.root, *%w{log mail.log}), 'a') do |output|
output << "___ EMAIL STARTS ______________________________\n"
output << message.encoded
output << "^^^ EMAIL ENDS ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"
end
puts "Send email to #{message.to}. Subject: #{message.subject}"
@pablobm
pablobm / Cucumber Plain Text Feature.sublime-settings
Created December 20, 2011 11:41
Settings for Sublime Text 2
{
"extensions": [ "feature" ],
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_automatic_white_space": true,
"trim_trailing_white_space_on_save": true,
"draw_white_space": "all"
}
@pablobm
pablobm / app.adapters.stop.js
Created October 22, 2015 13:24
Adding parameters to query
import Ember from 'ember';
import ApplicationAdapter from 'london-waits/pods/application/adapter';
import config from 'london-waits/config/environment';
function readStopId(id) {
return id.split(':')[0];
}
export default ApplicationAdapter.extend({
pathForType(type) {