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
def extended_gcd(a, b) | |
raise ArgumentError unless a >= b and b >= 0 and a + b > 0 | |
if b == 0 | |
d, x, y = a, 1, 0 | |
else | |
(d, p, q) = extended_gcd(b, a % b) | |
x = q | |
y = p - q * (a / b) | |
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
def <=>(other) | |
head.match do |lm| | |
lm.none do | |
other.head.match do |rm| | |
rm.some { -1 } | |
rm.none { 0 } | |
end | |
end | |
lm.some do |left_head| | |
other.head.match do |rm| |
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
# /etc/nginx/nginx.conf | |
http { | |
access_log /dev/stdout; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
proxy_cache_path /tmp levels=1:2 keys_zone=thumbs:10m inactive=24h max_size=1G; | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; |
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 'fear' | |
User = Struct.new(:id, :name, :admin) | |
Fear.register_extractor(User, Fear.case(User, &:to_a).lift) | |
matcher = Fear.matcher do |m| | |
m.xcase('User(_, name, true)') do |name:| | |
puts "Hi #{name}, you are welcome" | |
end | |
m.xcase('User(_, _, false)') do |
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 'fear' | |
# @example Usage | |
# set = BinaryTreeSet.new | |
# set.add(4) | |
# set.includes?(4) #=> true | |
# set.includes?(5) #=> false | |
# set.delete(4) | |
# set.includes(4) #=> false | |
# |
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
ab -n 10 -c 1 http://127.0.0.1:8080/fast_scan\?file_path\=/foo/bar | |
This is ApacheBench, Version 2.3 <$Revision: 1807734 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 127.0.0.1 (be patient).....done | |
Server Software: | |
Server Hostname: 127.0.0.1 |
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
code = <<-RUBY | |
c = fzbz = -> v { | |
s = v % 3 < 1 ? 'Fizz' : '' | |
v % 5 < 1 && s << 'Bazz' | |
v < 1 ? [] : c[v - 1] + [s == '' ? v : s] | |
} | |
RUBY | |
fzbz = eval(code) |
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
package main | |
import ( | |
"bytes" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os/exec" | |
"regexp" |
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
RSpec::Matchers.define :be_identical_docx_file_to do |expected_docx_file| | |
match do |actual_docx_file| | |
expected_file = extract_zip_file(expected_docx_file) | |
actual_file = extract_zip_file(actual_docx_file) | |
expected_file == actual_file | |
end | |
# @param path [String] path to docx file | |
# @return [{String => String}] maps file names to file content | |
private def extract_zip_file(path) |
NewerOlder