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
| const fetch = require("node-fetch"); | |
| export const fetchClient = baseUrl => endpoint => (success, failure) => { | |
| fetch(baseUrl + endpoint) | |
| .then(res => res.json()) | |
| .then(success) | |
| .catch(failure); | |
| }; |
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 'benchmark/ips' | |
| hash_array = (1..10000).map{|n| {name: "foo#{n}"}} | |
| Benchmark.ips do |x| | |
| x.time = 100 | |
| x.report("reverse") do | |
| hash_array.sort_by!{|v| v[:name]} | |
| hash_array.reverse! |
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
| DIR="$HOME/dev" | |
| tmux new-session -d -s project_name -n processes | |
| tmux send-keys 'top' 'C-m' | |
| tmux split-window -v | |
| tmux send-keys 'top' 'C-m' | |
| tmux split-window -h | |
| tmux send-keys 'top' 'C-m' | |
| tmux new-window -n vim -c "$DIR" | |
| tmux send-keys 'vim' 'C-m' | |
| tmux attach -t project_name |
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_relative 'require_file' | |
| include RequireFile | |
| $0 # => "current_file.rb" | |
| __FILE__ # => "current_file.rb" | |
| __LINE__ # => 6 | |
| File.expand_path(__FILE__) # => "path/to/current_file.rb" | |
| stdout_method | |
| # $0 # => "current_file.rb" |
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
| ใใใฆ = %w(ใใผ ใกใใ ใฑใผ) | |
| ใใใใใ = { :"ใใผ" => 0, | |
| :"ใกใใ" => 1, | |
| :"ใฑใผ" => 2} | |
| loop do | |
| print 'ใใใใใ... :' | |
| ใทใใใใผใฎๆ = gets.chomp |
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
| posts = Post.all | |
| Benchmark.bm do |x| | |
| x.report(:exists) {posts.exists?} | |
| x.report(:present) {posts.present?} | |
| end | |
| user system total real | |
| Post Exists (0.3ms) SELECT 1 AS one FROM "posts" LIMIT 1 | |
| exists 0.020000 0.000000 0.020000 ( 0.028894) |
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 'benchmark' | |
| require 'set' | |
| array = Array.new(1_000_000){[1, 2, 3]} | |
| set = array.to_set | |
| Benchmark.bm(15) do |x| | |
| x.report('array:') { array.each do |n| n.include?(3) end } | |
| x.report('set:') { set.each do |n| n.include?(3) 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 create | |
| # ใชใใกใฏใฟใชใณใฐๅพ | |
| @staff = Staff.new(params[:staff]) | |
| if staff = Staff.find_by(email: @staff.email) | |
| session[:staff_id] = staff.id | |
| redirect :root | |
| else | |
| render :new | |
| 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
| box: inwy/[email protected] | |
| services: | |
| - wercker/postgresql | |
| build: | |
| steps: | |
| - bundle-install | |
| - rails-database-yml: | |
| service: postgresql | |
| - script: | |
| name: echo ruby information |
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 Murajun | |
| def initialize(name) | |
| @name = name | |
| end | |
| def murajun? | |
| @name == "murajun" | |
| end | |
| end |
NewerOlder