Skip to content

Instantly share code, notes, and snippets.

View davidqhr's full-sized avatar
🎯
Focusing

david davidqhr

🎯
Focusing
  • 18:47 (UTC -07:00)
View GitHub Profile
@davidqhr
davidqhr / read-access.sql
Created April 17, 2018 14:03 — 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;

Keybase proof

I hereby claim:

  • I am davidqhr on github.
  • I am davidqin (https://keybase.io/davidqin) on keybase.
  • I have a public key ASBgSkL7WWvRj1yeT6dh_-OqlTTw0EKy-ZPjBMV9DdyFFAo

To claim this, I am signing this object:

@davidqhr
davidqhr / rb_heap.rb
Last active May 18, 2017 16:53
simple ruby heap
class Heap
def initialize &block
@data = []
@less = block
end
def push i
@data.push i
len = @data.length
upward(len-1)
@davidqhr
davidqhr / 0_reuse_code.js
Created December 28, 2016 04:34
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@davidqhr
davidqhr / docker-compose.yml
Created November 23, 2016 03:48
elk docker compose
kibana:
container_name: elk-kibana
image: kibana:5
ports:
- "5601:5601"
environment:
ELASTICSEARCH_URL: http://elasticsearch:9200
links:
- elasticsearch
elasticsearch:
@davidqhr
davidqhr / upyun_refresh_cache.rb
Last active August 17, 2016 04:39
又拍云 刷新缓存
require 'uri'
require 'net/http'
require 'digest'
def refresh_upyun_cache urls
raw_password = 'xxx'
bucket = 'xxx'
operator = 'xxx'
date = Time.now.gmtime.strftime("%a, %d %b %Y %T GMT")
@davidqhr
davidqhr / mysql_partition.md
Last active December 28, 2016 06:27
mysql partition test on mac os

my mac

  • cpu i5 2 cores
  • RAM 8G

mysql version

SHOW VARIABLES LIKE '%version%';

+-------------------------+-----------------------+
| Variable_name           | Value                 |