Skip to content

Instantly share code, notes, and snippets.

View tonidezman's full-sized avatar
🎯
Focusing

Toni Dezman tonidezman

🎯
Focusing
View GitHub Profile
@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|
@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"
@amejiarosario
amejiarosario / rails_migration_cheatsheet.md
Created June 18, 2012 21:40
Rails Migration - Cheatsheet
@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:
@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.
@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
@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!
@tomas-stefano
tomas-stefano / Capybara.md
Last active May 2, 2024 05:16
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@brysgo
brysgo / post_checkout_migrations.sh
Last active October 5, 2019 11:13 — forked from skyriverbend/rails_switch_branch.py
Post checkout hook for managing rails migrations and bundle install
CHECKING_OUT_BRANCH=$3
OLD_BRANCH=$1
NEW_BRANCH=$2
if [ $CHECKING_OUT_BRANCH -eq 1 ]
then
FILES_CHANGED=`git diff $OLD_BRANCH $NEW_BRANCH --name-status`
MIGRATIONS_REMOVED=`echo "$FILES_CHANGED" | egrep 'D\tdb/migrate/([0-9]+)' | sort -r`
MIGRATIONS_ADDED=`echo "$FILES_CHANGED" | egrep 'A\tdb/migrate/([0-9]+)'`
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 6, 2024 02:17
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\