Skip to content

Instantly share code, notes, and snippets.

View fellix's full-sized avatar

Rafael Felix fellix

View GitHub Profile
package main
import (
"time"
"entities"
)
func main() {
d := time.Date(2008, time.November, 10, 23, 0, 0, 0, time.UTC)
entities.ageFromNow(d) // compiling error
@fellix
fellix / fmt.go
Last active September 26, 2015 01:19
package main
import "fmt"
func main() {
fmt.Println("Hello Golang")
}
@fellix
fellix / turnip_helper.rb
Created September 10, 2014 00:45
turnip_helper with fixtures
require 'rails_helper'
RSpec.configure do |config|
config.before(:each, type: :feature) do
fixture_path = "#{Rails.root}/spec/fixtures"
fixtures = Dir["#{fixture_path}/**/*.yml"].map { |f| File.basename(f, '.yml') }
ActiveRecord::FixtureSet.create_fixtures(fixture_path, fixtures)
end
end
files = Dir.glob("app/**/*.rb")
files.concat Dir.glob("lib/**/*.rb")
files.each do |file_name|
lines = File.readlines(file_name)
if !["#encoding: utf-8\n", "# encoding: utf-8\n"].include?(lines.first)
puts "Rewriting #{file_name}"
lines = ["#encoding: utf-8\n"].concat lines
new_file = File.new(file_name, "w")
lines.each { |line| new_file.write line }
@fellix
fellix / repeating_decimal.rb
Last active December 18, 2015 12:19
turning a repeating decimal into fraction
class Numeric
def £(other_number)
RepeatingDecimal.new(self, other_number)
end
end
class RepeatingDecimal
attr_reader :repeating
def initialize(base, repeating)
oftWrap = true
tabSize = 2
softTabs = true
@fellix
fellix / error.log
Created February 27, 2013 19:49
ruby 2.0 + rails 4.0.beta1 + bundle install = error
bundle
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/Users/felix/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http.rb:917:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint (OpenSSL::SSL::SSLError)
from /Users/felix/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http.rb:917:in `block in connect'
from /Users/felix/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/timeout.rb:51:in `timeout'
from /Users/felix/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http.rb:917:in `connect'
from /Users/felix/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http.rb:861:in `do_start'
from /Users/felix/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http.rb:856:in `start'
from /Users/felix/.rvm/gems/ruby-2.0.0-p0@oeconomicae/gems/bundler-1.3.0/lib/bundler/vendor/net/http/persistent.rb:628:in `start'
Collection.extend({
byId: function () {
this.filter(function (n) {
console.log(n);
return n;
});
}
})
@fellix
fellix / tv_show.rb
Last active December 13, 2015 20:59
class TvShow
def initialize
yield self if block_given?
end
def self.add(&block)
tv_show = TvShow.new(&block)
@@shows ||= []
@@shows << tv_show
end
errorHandler: function (model, response) {
var result = $.parseJSON(response.responseText);
_(result.errors).each(function (errors, attribute) {
var inputWithError = $('#'+attribute),
parentDiv = inputWithError.parent();
parentDiv.addClass('error');
_(errors).each(function (error) {
$("<span class='help-inline'></span>").