This file contains 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
# frozen_string_literal: true | |
module RuboCop | |
module Cop | |
module Rails | |
# Checks for duplicate calls to ActiveRecord::Base.ignore_columns= as the | |
# subsequent calls will override the first call. | |
# | |
# @example | |
# # bad |
This file contains 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
" Highlight Ruby 1.8.x hash rocket | |
" This will prevent you to ever write it again | |
highlight ObsoleteHashRocket ctermbg=red guibg=red | |
au ColorScheme * highlight ObsoleteHashRocket guibg=red | |
au BufEnter * match ObsoleteHashRocket /=>/ | |
au InsertEnter * match ObsoleteHashRocket /=>/ | |
au InsertLeave * match ObsoleteHashRocket /=>/ |
This file contains 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 "open-uri" | |
require "json" | |
API_URL = "https://store.playstation.com/chihiro-api/viewfinder/US/en/19/STORE-MSF77008-SUMMERSALEPSVGG?size=100&gkb=1&geoCountry=US" | |
STORE_URL = "https://store.playstation.com/#!/en-us/cid=%s" | |
data = JSON.parse(open(API_URL).read) | |
games = [] | |
data["links"].each do |game| |
This file contains 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
# Usage | |
class User | |
serialize :data, YAMLColumnWithSyckFallback.new | |
end |
This file contains 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
using terms from application "Colloquy" | |
on process user command c with arguments for view | |
try | |
if c is in {"nowplaying", "np", "playing"} then | |
tell application "Google Chrome" | |
repeat with w in (every window) | |
repeat with t in (every tab whose URL contains "play.google.com/music") of w | |
if (execute t javascript "document.getElementsByClassName('playing').length") is equal to 1 then | |
set tTitle to execute t javascript "document.getElementById('playerSongTitle').innerText;" | |
set tArtist to execute t javascript "document.getElementById('player-artist').innerText;" |
This file contains 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
[~] rvm alias list | |
default => ruby-2.3.0 | |
[~] rvm alias create 2.1 2.1.0 | |
ruby-2.1.0 is not installed. | |
Creating alias 2.1 for ruby-2.1.0... | |
[~] rvm alias list | |
2.1 => ruby-2.1.0 | |
default => ruby-2.3.0 | |
[~] rvm alias create 2.1 2.1.8 | |
ruby-2.1.8 is not installed. |
This file contains 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
# Note: This assume that you're using libxml2 from Homebrew, which is keg-only. | |
# Run this command: | |
$ bundle config build.nokogiri --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xslt-dir=/usr/local/opt | |
# Remove and rebundle. You use Bundler, right? | |
$ yes | gem uninstall nokogiri --force | |
$ bundle |
This file contains 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
irb(main):001:0> class Foo | |
irb(main):002:1> def initialize(a, b = a.to_s) | |
irb(main):003:2> puts [a, b].inspect | |
irb(main):004:2> end | |
irb(main):005:1> end | |
=> nil | |
irb(main):006:0> Foo.new 1 | |
[1, "1"] | |
=> #<Foo:0x007f973d9ca410> |
This file contains 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
gpr() { | |
current_branch=`git rev-parse --abbrev-ref HEAD` | |
if [[ $1 != '' ]]; then | |
upstream=$1 | |
else | |
upstream='master' | |
fi | |
origin_username=`git remote -v | grep 'origin.\+fetch' | sed "s/^.*github.com[\/:]\(.*\)\/\(.*\)\.git.*$/\1/"` | |
origin_repository=`git remote -v | grep 'origin.\+fetch' | sed "s/^.*github.com[\/:]\(.*\)\/\(.*\)\.git.*$/\2/"` | |
if [[ `git remote | grep sikachu` != '' ]]; then |
This file contains 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
Benchmark.bmbm do |x| | |
x.report('start_with?') { 10_000.times { "fooo".start_with?('foo') }} | |
x.report('regexp') { 10_000.times { "fooo" =~ /^foo/ }} | |
end |
NewerOlder