Skip to content

Instantly share code, notes, and snippets.

View elct9620's full-sized avatar
💦
Level up!!!

蒼時弦や elct9620

💦
Level up!!!
View GitHub Profile
@elct9620
elct9620 / simple-reactive.rb
Last active December 30, 2016 07:36
Reactive Programming implement in Ruby (Self implemented version)
=begin
Observable.create( -> (x) { x.on_next(1) }
.subscribe( -> (x) { p x })
=end
require 'set'
class Scheduler
def initialize
@thread = Thread.new { run }
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
using UniRx;
public class DatabaseDownloader {
public static string DatabaseURL = "SERVER_URL";
private const string Token = "TOKEN";
/*
doc.Items.map(function(id) {
return Check.
findById(id.toString())
.then(function(doc){
doc = doc.toObject();
return doc;
})
})
*/
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
@elct9620
elct9620 / pre-commit
Last active April 20, 2017 07:12
.git/hooks/pre-commit
#!/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
pushMatrix(); // 儲存修改
rotate(PI / 4); // rad = PI / 4 = 45deg (把角度換算成弧度)
ellipse(width / 2, height / 2, 100, 50); // 繪製一個橢圓(在畫面中央)
popMatrix(); // 套用修改
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],
};
soruce = File.readlines('source.txt').map(&:chomp)
target = File.readlines('target.txt').map(&:chomp)
source - target
@elct9620
elct9620 / node.rb
Created October 22, 2017 14:54
Rails using PostgreSQL Recursive Query to find ancestors
# 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 (
class MyError < StandardError
attr_reader :code
def initialize(code)
@code = code
end
end
def go
raise MyError.new(404), 'Not Found'
rescue StandardError => e