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 'socket' | |
require 'fiber' | |
class Selector | |
def initialize | |
@readable = {} | |
@writeable = {} | |
end | |
def wait_readable(io) |
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
# Start Command: rackup | |
require 'socket' | |
# Initialize Socket -> Pure Data | |
pd = TCPSocket.new 'localhost', 3000 | |
# Create HTTP Server | |
app = Proc.new do |env| | |
# /?Do=1&Re=0 | |
query = env['QUERY_STRING'] |
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 MyError < StandardError | |
attr_reader :code | |
def initialize(code) | |
@code = code | |
end | |
end | |
def go | |
raise MyError.new(404), 'Not Found' | |
rescue StandardError => e |
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
# CREATE TABLE nodes ( | |
# id bigserial primary key, | |
# parent_id bigint null | |
# ) | |
class Node < ApplicationRecord | |
def ancestors(depth: 10) | |
query = <<- SQL | |
WITH RECURSIVE node_paths(#{Node.column_names.join(', ')}, depth) AS ( |
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
soruce = File.readlines('source.txt').map(&:chomp) | |
target = File.readlines('target.txt').map(&:chomp) | |
source - target |
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
function RawToBook(raw) { | |
var columns = raw.split(','); | |
return { | |
IBSN: columns[0], | |
Title: columns[1], | |
Author: columns[2], | |
Press: columns[3], | |
Class: columns[4], | |
Description: columns[5], | |
}; |
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
pushMatrix(); // 儲存修改 | |
rotate(PI / 4); // rad = PI / 4 = 45deg (把角度換算成弧度) | |
ellipse(width / 2, height / 2, 100, 50); // 繪製一個橢圓(在畫面中央) | |
popMatrix(); // 套用修改 |
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
#!/bin/sh | |
# | |
# Check for ruby style errors | |
red='\033[0;31m' | |
green='\033[0;32m' | |
yellow='\033[0;33m' | |
NC='\033[0m' | |
if git rev-parse --verify HEAD >/dev/null 2>&1 |
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
Cat.summon do | |
skin do | |
var :catBody, 'rgb(230, 165, 100)' | |
var :catBelly, 'rgb(240, 190, 120)' | |
var :catTail, 'rgb(190, 130, 80)' | |
var :strokeColor, 'rgb(50, 50, 70)' | |
end | |
skeleton do |
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
/* | |
doc.Items.map(function(id) { | |
return Check. | |
findById(id.toString()) | |
.then(function(doc){ | |
doc = doc.toObject(); | |
return doc; | |
}) | |
}) | |
*/ |