Skip to content

Instantly share code, notes, and snippets.

@zetachang
zetachang / rep.rb
Last active December 16, 2015 04:49
A proof of concept which wrap IRB in a different feed-driven API
require 'irb'
module IRB
WAITING_FOR_INPUT_IDENTIFIER = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
class MyInputMethod < StdioInputMethod
def gets
puts WAITING_FOR_INPUT_IDENTIFIER
print @prompt + "\n"
line = @stdin.gets
module React
def self.create_element(klass)
%x{
function ctor(){
this.constructor = ctor
React.Component.apply(this, arguments);
klass._alloc.prototype.$initialize.call(this);
};
ctor.prototype = klass._proto;
Object.assign(ctor.prototype, React.Component.prototype);
From 22a8d63c748a3abf1dc0dd619d4d3b0d3f848c5c Mon Sep 17 00:00:00 2001
From: David Chang <zeta11235813@gmail.com>
Date: Fri, 30 Sep 2016 17:50:12 +0800
Subject: [PATCH] Some fix
---
application.rb | 7 ++++---
controller.rb | 4 +++-
2 files changed, 7 insertions(+), 4 deletions(-)
class Hash
def destruct(&block)
keys = block.parameters.map{|a| a[1]}
block.call(*self.values_at(*keys))
end
end
h = { a: 10, foo: 'bar', c: true }
h.destruct { |foo, a|
@zetachang
zetachang / read-access.sql
Created May 24, 2017 01:10 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;