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
<?php | |
class Nyan { | |
static public function static_method_nyan() { | |
echo 'static nyan', "\n"; | |
} | |
static public function __callStatic($name, $args) { | |
$method_name = 'static_method_' . $name; |
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
#!/bin/bash | |
jquery_version="1.9.1" | |
jquery_name="jquery-${jquery_version}.min.js" | |
jquery_url="http://code.jquery.com/$jquery_name" | |
mkdir -p haml coffee sass vendor public/{javascripts,stylesheets,images,lib} | |
touch vendor/.gitkeep | |
curl -L "$jquery_url" > "public/lib/$jquery_name" |
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
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 ] |
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
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 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 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 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 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 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 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; |