Skip to content

Instantly share code, notes, and snippets.

View tonidezman's full-sized avatar
🎯
Focusing

Toni Dezman tonidezman

🎯
Focusing
View GitHub Profile
@robinboening
robinboening / player.rb
Last active January 13, 2019 06:16
ruby-warrior level6
class Player
FULL_HEALTH = 20
def play_turn(warrior)
@warrior = warrior
if need_to_rest?
if able_to_rest?
warrior.rest!
@mssola
mssola / singleton.rb
Created August 2, 2013 07:44
Different ways to create the Singleton pattern in Ruby.
##
# This files shows some possible implementations of the Singleton pattern
# in Ruby. I'm not a huge fan of the Singleton pattern, but it's nice
# in some cases. In this file I'm going to implement a simple logger.
#
##
# The first implementation that can come to our minds is to create a class
# that holds an instance as a class variable that can be accessed through
@jendiamond
jendiamond / gist:6128723
Last active April 11, 2024 11:35
Creating your own Gem & Command Line Interface Using Bundler

Presentation slides

Create a Gem - Make it a CLI - Add Rspec Tests

Create a Gem - Make it a Command Line Interface - Add Rspec Tests Using Bundler & Thor

#Creating your own Gem

  1. Run this command in your Terminal. This creates and names all the files you need for your gem. We are going to create a Lorem Ipsum Generator; you can call it whatever you want but seeing as we are creating a Lorem Ipsum generator we'll call it lorem. Read about gem naming conventions.
@istana
istana / devise.sk.yml
Created June 26, 2013 13:07
Slovak locale for Devise
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
# Just to be clear:
# Author: Ivan Stana, http://github.com/istana
# License: MIT
# Base file: devise.en.yml
# Some elements taken from https://gist.github.com/MarosPixel/1295185 thx
# For versions 2.2, 3.0, maybe other
sk:
@amejiarosario
amejiarosario / rails_migration_cheatsheet.md
Created June 18, 2012 21:40
Rails Migration - Cheatsheet
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@chumpy
chumpy / yaml_compare.rb
Created January 29, 2012 00:20
compare two yaml files in ruby
#require 'active_support/core_ext'
class YamlCompare
def self.compare_keys first_file_info, second_file_info, results_location
first_file = Hash.new
second_file = Hash.new
deltas_file = Hash.new
File.open( first_file_info[:file_location] ) { |yf| first_file = YAML.load( yf ) }
File.open( second_file_info[:file_location] ) { |yf| second_file = YAML.load( yf ) }
first_file[first_file_info[:root]].each_pair do |k,v|