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
properties = box.schema.space.create('properties') | |
properties:create_index('primary', {parts = {1, 'str'}, type = 'HASH', unique = true, if_not_exists = true}) | |
properties:replace({'node_id', 0}) | |
nodes = box.schema.space.create('nodes') | |
nodes:create_index('primary', {parts = {1, 'num', 2, 'str'}, type = 'TREE', unique = true, if_not_exists = true}) | |
function load_words() | |
local words = "/opt/dict/words" | |
for line in io.lines(words) 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
DROP TABLE qrtz_blob_triggers; | |
DROP TABLE qrtz_calendars; | |
DROP TABLE qrtz_cron_triggers; | |
DROP TABLE qrtz_fired_triggers; | |
DROP TABLE qrtz_job_details CASCADE; | |
DROP TABLE qrtz_locks; | |
DROP TABLE qrtz_paused_trigger_grps; | |
DROP TABLE qrtz_scheduler_state; | |
DROP TABLE qrtz_simple_triggers; | |
DROP TABLE qrtz_simprop_triggers; |
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
small = (1..10).to_a | |
big = (1..5_000).to_a | |
Fiber.new do | |
puts "It's ok" | |
puts *small | |
puts "It is not ok" | |
puts *big | |
end.resume |
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 Player | |
def play_turn(warrior) | |
@max_health ||= warrior.health | |
case state(warrior) | |
when :lost | |
warrior.pivot! | |
when :captive | |
warrior.rescue! | |
when :enemyfar |
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 TrieDict | |
attr_reader :dict | |
def initialize | |
@dict = {} | |
end | |
def put(str) | |
d = nil | |
str.chars.each do |c| |
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 'rack/utils' | |
run proc{ | |
res = "Hello World" | |
headers = Rack::Utils::HeaderHash.new | |
headers["Connection"] = "close" | |
headers["Content-Length"] = res.bytesize.to_s | |
headers["Access-Control-Allow-Origin"] = [ "http://mir.mail.ru", "http://my.mail.ru" ] | |
[200, headers, [res] ] |
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
run proc{ | |
res = "Hello World" | |
[ | |
200, | |
{ | |
"Connection" => "close", | |
"Access-Control-Allow-Origin" => [ "http://domain1.com", "http://domain2.com" ] * "\n", | |
"Content-Length" => res.bytesize.to_s | |
}, | |
[res] |
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 Foo | |
def Foo.bar | |
end | |
class << Foo | |
def baz | |
end | |
end | |
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
# Ruby | |
module App | |
extend self | |
def call(env) | |
[ | |
200, | |
{ 'Content-Type' => 'application/json' }, | |
['{"message": "Hello World"}'] | |
] |
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 Helpers | |
module Truncate | |
def teardown | |
teardown_couch | |
end | |
def teardown_couch | |
helpers = connection.design_docs["helpers"] | |
unless helpers && helpers.views.include?("truncate") | |
create_view |
NewerOlder