Skip to content

Instantly share code, notes, and snippets.

@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;
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|
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(-)
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);
@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
@zetachang
zetachang / gist:4111314
Created November 19, 2012 15:37
Instruction on adding a Acknowledgements Settings.bundle
  • To add Settings.bundle in Xcode. Command N and in Resource, choose Settings Bundle .
  • Open Root.plist in source code, paste the code below to replace it,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>PreferenceSpecifiers</key>
	
@zetachang
zetachang / gist:4105844
Created November 18, 2012 15:35
Textmate grammer
bracketed_content = {
name = 'meta.bracketed.objc';
begin = '\[';
end = '\]';
beginCaptures = { 0 = { name = 'punctuation.section.scope.begin.objc'; }; };
endCaptures = { 0 = { name = 'punctuation.section.scope.end.objc'; }; };
patterns = (
{ name = 'meta.function-call.predicate.objc';
begin = '(?=predicateWithFormat:)(?<=NSPredicate )(predicateWithFormat:)';
end = '(?=\])';
#include <stdio.h>
#include <stdlib.h>
void three_n_plus_one(int n,int *count,int a[]);
int main(void)
{
int count=0,input[3],a[100],i,j;
printf("請輸入三個值:");
scanf("%d %d %d",&input[0],&input[1],&input[2]);
for(i=0;i<3;i++)
<!DOCTYPE html>
%html
%head
%meta{:charset=>"utf-8"}
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame -->
%meta{:content=>"IE=edge,chrome=1", :"http-equiv"=>"X-UA-Compatible"}
= stylesheet_link_tag "site"
= javascript_include_tag "https://www.google.com/jsapi"
= javascript_include_tag "application"
%meta{:property=>"og:title",:content=>"針對新聞說出你的看法--台灣投票 Taiwan Voting"}
@import "compass"
@import "preboot"
@import "compass-bootstrap/compass_bootstrap"
@mixin center
margin-left: auto
margin-right: auto
body
//background: image_url('background3.jpg')
background: #dcdcdc
#topbar