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 M1 | |
| def nyan1 | |
| run_callback(->(*args){ args.join }, '1', '2', '3') | |
| end | |
| private | |
| def run_callback(callback, *args) | |
| callback.(*args) | |
| 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 'active_record' | |
| module ActsAsSplittable | |
| def acts_as_splittable(options = {}) | |
| options.reverse_merge!( | |
| callbacks: true, | |
| ) | |
| extend ClassMethods |
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
| upstream php54 { | |
| server 127.0.0.1:9000; | |
| } | |
| server { | |
| listen 80; | |
| access_log /var/log/nginx/access.log main; | |
| error_log /var/log/nginx/error.log warn; |
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
| var entity = function(string) { | |
| return ('' + string).replace(/(?:[\uD800-\uDBFF][\uDC00-\uDFFF]|[\S\s])/g, function(m0) { | |
| var c = m0.length === 2 ? | |
| (((m0.charCodeAt(0) & 0x3ff) << 10) | (m0.charCodeAt(1) & 0x3ff)) + 0x10000 : | |
| m0.charCodeAt(0); | |
| return '&#x' + c.toString(16) + ';'; | |
| }); | |
| }; |
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 Authenticatable | |
| extend ActiveSupport::Concern | |
| included do | |
| helper_method :current_user, :signed_in?, :me?, :own? | |
| end | |
| module Exceptions | |
| class Exception < SecurityError; end # SecurityError でいいのか謎 | |
| class SignInRequired < Exception; 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 User < ActiveRecord::Base | |
| has_secure_password validations: false | |
| validates :password, | |
| presence: {if: :password_required?, on: :create}, | |
| confirmation: {if: :password_required?} | |
| validates :password_confirmation, | |
| presence: {if: :password_present?} |
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
| if [ -z "$INSTALLDIR" ]; then | |
| exit 1 | |
| fi | |
| cat > /Library/LaunchDaemons/com.bitnami-drupal.apache.service.plist <<EOS | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> |
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 'parslet' | |
| module Tumblr | |
| module Parser | |
| class Base < Parslet::Parser | |
| def space | |
| match('\s').repeat(1) | |
| end | |
| def space? |
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
| set :default_run_options, :pty => true | |
| set(:username) { Capistrano::CLI.ui.ask('Username: ') } | |
| set(:password) { Capistrano::CLI.password_prompt('Password: ') } | |
| namespace :deploy do | |
| task :nyan, :roles => [:app] do | |
| run 'something interactive' do |channel, stream, output| | |
| Capistrano::Configuration.default_io_proc.call(channel, stream, output) | |
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
| Number.prototype.to = function(n) { | |
| for (var result = [], i = parseInt(this); i <= n; i ++) { | |
| result.push(i); | |
| } | |
| return result; | |
| }; | |
| console.log(10..to(20)); | |
| // [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ] |