Skip to content

Instantly share code, notes, and snippets.

View aitor's full-sized avatar
👊
Working!

Aitor García Rey aitor

👊
Working!
View GitHub Profile
@straydogstudio
straydogstudio / without_runner.rb
Last active August 29, 2015 14:05
Render a template outside of Rails
require 'abstract_controller'
require 'action_controller'
require 'action_view'
require 'active_record'
# require any helpers
require './app/helpers/application_helper'
# active record only if data is here
require './app/models/widget'
require File.dirname(__FILE__) + '/spec_helper'
describe "The library itself" do
Spec::Matchers.define :have_no_tab_characters do
match do |filename|
@failing_lines = []
File.readlines(filename).each_with_index do |line,number|
@failing_lines << number + 1 if line =~ /\t/
end
@failing_lines.empty?
# encoding: UTF-8
# Guess the charset encoding of a given input, by submitting it to vote to different guessers.
require 'rubygems'
require 'open-uri'
if RUBY_VERSION > "1.9"
# ruby encodings only work on 1.9
class Yukihiro
def guess_charset(str)
@sween
sween / rgbmacro.txt
Created October 18, 2010 02:34
Objective C Macro for using RGB Colors
#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
cell.textColor = UIColorFromRGB(0x333333);
/*!
* JavaScript whatevCache - v0.2pre - 12/30/2010
* http://benalman.com/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// whatevCache.set( key, value [, ttl ] );
@porras
porras / why_steak.md
Created January 8, 2011 14:48
Why Steak (over Cucumber)

Why Steak (over Cucumber)

From here

  • Plain text have no value if people writing and reading the specs are developers. Code is natural language for developers (specially if that code is Ruby). Having a client who reads the specs is a possible situation and Cucumber is cool there, but in my experience that situation is not the most common one. If in your case there's no value in having your specs in English rather than in Ruby, Cucumber is an additional layer of abstraction in exchange of nothing.

  • There's a myth about clients writing the specs. It sounds like a unicorn to me, but let's take it. Still, I wouldn't want it. Clients are experts in problems, I am expert in solutions. I want the client to describe the problem I have to solve, not to describe the solution.

  • Some people say Cucumber is cool because you write the stories, the client validates them, and then you can start developing. That is not Agile. The on

@aeden
aeden / gem-index-with-dns.md
Created January 16, 2011 13:31
Using DNS for Rubygems index

Currently the RubyGems index is stored as a Gzip file that is a marshalled array. Whenever Bundler needs to install a gem that is not yet installed it downloads the index, gunzips it and unmarshals it. It then looks for dependencies that are described in another file that is also a gzipped and marshalled file. There are several issues that arise from this setup:

  • The full index must be downloaded and parsed, but does not contain dependency data, which must then be downloaded and parsed. This is a relatively time consuming process.
  • The index must be centralized.

Additionally the gems themselves are currently centralized since there is nothing in the meta data that indicates where the gem should be downloaded from. However in order to allow this it is important to find ways of keeping the index from being poisoned (is this an issue in the centralized system?)

Dependency Resolution

@cowboyd
cowboyd / allruby.rb
Created January 17, 2011 19:36
Proof of concept for making all ruby available to javascript.
require 'v8'
require 'openssl'
class Module
def [](name)
self.const_get(name)
end
end
@calavera
calavera / gist:790579
Created January 21, 2011 22:41
Kata de api fluida
class User
attr_reader :name, :age
def initialize(name, age)
@name, @age = name, age
end
end
class Filter
attr_reader :method, :value
def initialize(method, value)
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.