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 User < ActiveRecord::Base | |
| self.roles | |
| @roles ||= %w(admin moderator contributor) | |
| end | |
| end | |
| # > User.roles | |
| # => ["admin", "moderator", "contributor"] |
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
| #!/usr/bin/env ruby | |
| if ['--help', '-h'].include?(ARGV[0]) || ARGV.size != 2 | |
| puts <<-EOT | |
| Make web application shortcut | |
| Usage: makewebapp <name> <URL> | |
| EOT | |
| exit | |
| 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
| Section "InputClass" | |
| Identifier "keyboard defaults" | |
| MatchIsKeyboard "on" | |
| Option "XKbOptions" "caps:lctrl,ctrl:swap_lalt_lctl" | |
| EndSection |
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 hashify | |
| "##{gsub(' ', '_')}" | |
| end | |
| 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
| def day_json | |
| ids = popular_people.pluck(:id).join('.') | |
| Rails.cache.fetch("pc/dj/#{ids}") do | |
| render_to_string json: popular_people | |
| end | |
| 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
| We Found 52 Days, Yaaay: | |
| 2016-08-06 | |
| 2016-08-13 | |
| 2016-08-20 | |
| 2016-08-27 | |
| 2016-09-03 | |
| 2016-09-10 | |
| 2016-09-17 | |
| 2016-09-24 | |
| 2016-10-01 |
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
| 'use strict' | |
| let Stack = function(max){ | |
| if(typeof max != 'number' || max == NaN){ | |
| throw new Error(max + ' should be a number'); | |
| } | |
| var Store = [], | |
| top = 0, | |
| empty = function() { return top === 0; }, |
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
| def time(&block) puts Benchmark.measure(&block) 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
| class SimpleGit | |
| def self.git(method_name, cmd = nil) | |
| define_method(method_name) do |args| | |
| if cmd | |
| git("#{cmd} #{args}") | |
| else | |
| git("#{method_name} #{args}") | |
| end | |
| end | |
| 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
| AllCops: | |
| Exclude: | |
| - 'vendor/**/*' | |
| - 'db/schema.rb' | |
| - 'db/migrate/**/*' | |
| Metrics/LineLength: | |
| Enabled: false | |
| Style/Documentation: | |
| Enabled: false | |
| Style/StringLiterals: |