Skip to content

Instantly share code, notes, and snippets.

<link id="font" href="http://fonts.googleapis.com/css?family=Open+Sans:400,600&subset=latin,cyrillic" rel="stylesheet" media="none" onload="setTimeout(function(){document.getElementById('font').setAttribute('media', 'all')}, 0)">
@Timrael
Timrael / gist:11406259
Created April 29, 2014 17:05
TRF dump example
[{
"field": "children",
"op": "EQ",
"children": {
"0": [{
"field": "infants",
"op": "EQ",
"children": {
"0": [{
"field": "trip_class",
module HotelsApi
class Search
include NanoApi::Model
HOTELSCOMBINED_MAP = {
:search => :destination,
:file_name => :fileName,
:checkin => :depart_date,
:checkout => :return_date,
:rooms => :rooms,
require_relative "inet2"
puts ARGV
cart = Cart.new(ARGV.delete_at(0))
ARGV.each do |argument|
@items.each { |item| cart.add_expensive_item(item) if argument == item.name }
end
cart.save_to_file
>>> window.location.hash = "%25255B";
"%25255B"
>>> window.location.hash = window.location.hash;
"#%255B"
>>> window.location.hash = window.location.hash;
@Timrael
Timrael / rspec-syntax-cheat-sheet.rb
Created July 19, 2012 05:35 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@Timrael
Timrael / gist:2947172
Created June 18, 2012 06:38
MonkeyPatching
class Foo
def self.bar
puts "Hello, world!"
end
end
module Monkey
def self.included(base)
base.extend(ClassMethods)
base.class_eval do
@Timrael
Timrael / gist:2947135
Created June 18, 2012 06:28
Monkey Patching
class Foo
def bar
puts "Hello, world!"
end
end
module Monkey
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
@Timrael
Timrael / gist:1939102
Created February 29, 2012 08:17
Redmine WTF
notified << author if author && author.active? && author.notify_about?(self)
if assigned_to
if assigned_to.is_a?(Group)
notified += assigned_to.users.select {|u| u.active? && u.notify_about?(self)}
else
notified << assigned_to if assigned_to.active? && assigned_to.notify_about?(self)
end
end
@Timrael
Timrael / gist:1716729
Created February 1, 2012 11:55
Redmine plugin
Redmine::Plugin.register :redmine_xxx do
settings :default => { 'default_tracker_for_new_issue' => Tracker.first.id }
end
# 'Setting.plugin_redmine_xxx' will output '"default_tracker_for_new_issue1"'
Redmine::Plugin.register :redmine_xxx do