- don't use self.method name, just put it in class << self
- don't use get_property, use the property name directly get_ and set_ is considered noise in ruby
- always add () in function definition with parameters
- you should always specify your rescued excpetion class
- there are a lot of cryptic lines with implicit logic like flatten[1]
- be consistent with methods names "_by(id)"
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
end_char = ARGV.first | |
characters = ('A'..end_char).to_a + ('A'...end_char).to_a.reverse | |
max_level = end_char.ord - 'A'.ord | |
diamond = characters.map do |char| | |
current_level = char.ord - 'A'.ord | |
before_spaces = max_level - current_level | |
if char == 'A' |
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
end_char = ARGV.first | |
characters = ('A'..end_char).to_a + ('A'...end_char).to_a.reverse | |
max_level = end_char.ord - 'A'.ord | |
diamond = characters.map do |char| | |
current_level = char.ord - 'A'.ord | |
before_spaces = max_level - current_level | |
if char == 'A' |
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
AllCops: | |
Exclude: | |
- 'vendor/**/*' | |
- 'db/schema.rb' | |
Metrics/LineLength: | |
Enabled: false | |
Style/Documentation: | |
Enabled: false | |
Style/StringLiterals: | |
Enabled: false |
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
;; -*- mode: emacs-lisp -*- | |
;; This file is loaded by Spacemacs at startup. | |
;; It must be stored in your home directory. | |
(defun dotspacemacs/layers () | |
"Configuration Layers declaration. | |
You should not put any user code in this function besides modifying the variable | |
values." | |
(setq-default | |
;; Base distribution to use. This is a layer contained in the directory |
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
= AAccttiivveeRReeccoorrdd::::BBaassee << OObbjjeecctt | |
------------------------------------------------------------------------------ | |
= IInncclluuddeess:: | |
(from gem activerecord-4.2.5.1) | |
Core | |
Persistence | |
ReadonlyAttributes | |
ModelSchema | |
Inheritance |
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 | |
#Script to get all repositories under a user from bitbucket | |
#Usage: getAllRepos.sh [username] | |
#source: http://haroldsoh.com/2011/10/07/clone-all-repos-from-a-bitbucket-source/ | |
curl -u ${1} https://api.bitbucket.org/1.0/users/${1} > repoinfo | |
# curl -u adomingues https://api.bitbucket.org/1.0/users/adomingues | |
# cat repoinfo | |
for repo_name in `cat repoinfo | sed -r 's/("name": )/\n\1/g' | sed -r 's/"name": "(.*)"/\1/' | sed -e 's/{//' | cut -f1 -d\" | tr '\n' ' '` |
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
$(function(){ | |
$('button[type="submit"]').click(function(){ | |
var _this = $(this); | |
_this.attr('disabled', 'disabled'); | |
setTimeout(function(){ | |
_this.removeAttr('disabled'); | |
}, 3000); | |
}); | |
}); |
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 initializer will load all yaml files in config/yamls then assign each | |
# file content to a constant that is equal to the file name capitalized. | |
# if you added a file named `config/yamls/foo.yml` you can access its | |
# content through `FOO` constant |
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 String | |
def indices(part) | |
ids = [] | |
begin | |
ids << index(part, (ids[-1]||-1)+1) | |
end while !ids[-1].nil? | |
ids.pop | |
ids | |
end | |
end |