This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'#'+(0x1000000+(Math.random())*0xffffff).toString(16).substr(1,6); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# You might have to install a new version of rsync for this to work. | |
# This is easily done by `brew install rsync` and restarting your terminal. | |
# To use a file as an exclude-list you can use the option | |
# --exclude-from='donot-deploy.txt' | |
# Change these to match your settings | |
USER_NAME='username' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from weakref import WeakKeyDictionary | |
class AdvancedDescriptor(object): | |
""" | |
Base class for descriptors, is hard to understand but works for most cases. | |
from https://www.youtube.com/watch?v=P92z7m-kZpc | |
""" | |
def __init__(self, name=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% flash.each do |type, message| %> | |
<div class="<%= bootstrap_flash_class type %>"><%= message %></div> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This oneliner generates a new secret_token.rb file, | |
# just paste it in your terminal at the root of your project | |
# and it will take care of the rest. | |
echo "$(rails r "p Rails.application.class.parent_name" | sed "s/\"//g")::Application.config.secret_token = '$(rake secret)'" > ./config/initializers/secret_token.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JsonForStrategy | |
def initialize | |
@strategy = FactoryGirl.strategy_by_name(:build).new | |
end | |
delegate :association, to: :@strategy | |
def result(evaluation) | |
@strategy.result(evaluation).to_json | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'simplecov' | |
SimpleCov.start 'rails' | |
ENV["RAILS_ENV"] ||= "test" | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'minitest/autorun' | |
require 'rails/test_help' | |
require 'factories' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :register_statistics do | |
require 'rails/code_statistics' | |
STATS_DIRECTORIES << ['Services', 'app/services'] | |
STATS_DIRECTORIES << ['Services Tests', 'test/services'] | |
CodeStatistics::TEST_TYPES << 'Services Tests' | |
end | |
Rake::Task['stats'].enhance [:register_statistics] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IO.readlines("/usr/share/dict/words").map(&:strip) # array of english words |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Typoglycemia | |
def self.convert(text) | |
text.gsub(/(\w+)/) { |word| scramble_middle_characters(word) } | |
end | |
def self.scramble_middle_characters(word) | |
return word if word.length < 4 | |
word[0] + shuffle_letters(word[1...-1]) + word[-1] | |
end |
OlderNewer