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 "bundler" | |
require "net/http" | |
require "json" | |
output = [] | |
debug_mode = ARGV[0] == "--debug" | |
gems = Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile)) |
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 "benchmark" | |
time = Benchmark.measure do | |
words = File.read("wordlist.txt").downcase.split("\n") | |
anagrams = Hash.new{|hash, key| hash[key] = []} | |
words.each do |word| | |
root = word.chars.sort.join | |
anagrams[root] << word | |
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
# Find the whole number _n_ that consists of 10 digits | |
# (e.g. 3451209876) for which the first _k_ digits | |
# can be divided by _k_ with `2 <= _k_ <= 9` | |
# | |
# Examples: | |
# The first 2 digits of _n_ can be divided by 2 (`34` => true) | |
# The first 3 digits of _n_ can be divided by 3 (`345` => true) | |
# The first 4 digits of _n_ can be divided by 4 (`3451` => false) | |
# etc. | |
# |
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
grep -R 'color: #' app/assets/stylesheets/* | awk '{print $NF}' | sort | uniq |
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
sentences = [ | |
'Don’t like this trade.', | |
'Lets do it in the dark.', | |
'Foo bar' | |
] | |
sentences.each do |sentence| | |
puts sentence.downcase.gsub!(/[^a-z]/,'').split('').sort!.join('') | |
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
# config/initializers/sidekiq.rb | |
require 'sidekiq' | |
Sidekiq.configure_client do |config| | |
config.redis = { size: 1 } | |
end | |
Sidekiq.configure_server do |config| | |
config.redis = { size: 9 } | |
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
<fieldset> | |
<legend>Password with pattern <code>\d*</code></legend> | |
<label>Password: <input type="password" pattern="\d*"></label> | |
</fieldset> | |
<fieldset> | |
<legend>Password with pattern <code>[0-9]*</code></legend> | |
<label>Password: <input type="password" pattern="[0-9]*"></label> | |
</fieldset> |
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 | |
# Remove all branches which are merged in to master | |
# Run this from within your repository, something like: | |
# cd /path/to/repo | |
# script/remove-obsolete-branches | |
#----- | |
BRANCH=${1:-'master'} |
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 Too | |
def hot | |
puts 'Yes...' | |
end | |
end | |
too = Too.new | |
too.hot |
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
SELECT email, | |
RIGHT(email, LENGTH(email) - LOCATE('@', email)) as domain | |
FROM `table`; |
NewerOlder