Skip to content

Instantly share code, notes, and snippets.

View ilovejs's full-sized avatar
🐡

Hao ilovejs

🐡
  • 15:10 (UTC +10:00)
View GitHub Profile
@ilovejs
ilovejs / histogram_in_pg.sql
Created April 12, 2018 00:39
histogram_in_pg.sql
SELECT
x,
WIDTH_BUCKET(x, 1, 10, 9) AS "x In Which Bucket ?"
FROM
generate_series(1, 10) x;
SELECT
ROW_NUMBER() OVER(),
*
FROM
@ilovejs
ilovejs / gist:56b8ef100f1c1572df88b067f61967ec
Created July 2, 2018 06:51 — forked from douglasjarquin/gist:2208690
Amazon RDS Performance Tuning Settings
rds-modify-db-parameter-group {param-group-name} \
--parameters="name=character_set_server, value=utf8, method=pending-reboot" \
--parameters="name=collation_server, value=utf8_general_ci, method=pending-reboot" \
--parameters="name=tmp_table_size, value={DBInstanceClassMemory/16}, method=pending-reboot" \
--parameters="name=max_heap_table_size, value={DBInstanceClassMemory/16}, method=pending-reboot" \
--parameters="name=query_cache_type, value=1, method=pending-reboot" \
--parameters="name=query_cache_size, value=131072, method=pending-reboot" \
--parameters="name=table_open_cache, value=2500, method=pending-reboot" \
--parameters="name=join_buffer_size, value={DBInstanceClassMemory/64}, method=pending-reboot" \
--parameters="name=thread_cache_size, value={DBInstanceClassMemory/12582880}, method=pending-reboot" \
@ilovejs
ilovejs / rds.sh
Created July 2, 2018 06:52 — forked from onyxraven/rds.sh
Amazon RDS Performance Tuning Settings
#XLarge DBInstanceClassMemory = 15892177440 = 14.8GB
#/32 = 496630545 = 473MB
#/64 = 248315272 = 236MB
#/128 = 124157636 = 118MB
#/256 = 62078818 = 59MB
#/512 = 31039409 = 29MB
#/12582880 = 1263 #default same divisor as max_connections = 4041.6MB = 4237924762
#/25165760 = 623 # half of max_connections = 1993.6MB
#/50331520 = 315 # quarter of max_connections = 1008MB = 1056964608
#*(3/4) #default innodb pool size = 11922309120
@ilovejs
ilovejs / CTE_not_fun.sql
Created July 12, 2018 01:10
CTE has limitation
--https://www.citusdata.com/blog/2018/05/15/fun-with-sql-recursive-ctes/
--Return: x
WITH RECURSIVE tens(x) AS (
SELECT 10
UNION
SELECT x + 10 FROM tens WHERE x + 10 <= 100
)
SELECT x FROM tens;
--Without having to drop down to a procedural language like plpgsql or plv8.
/* Inferred Table */
CREATE TABLE users (
id serial PRIMARY KEY,
email text
);
CREATE TABLE tasks (
id serial PRIMARY KEY,
name text,
project_id NUMERIC,
--https://www.citusdata.com/blog/2018/05/15/fun-with-sql-recursive-ctes/
--Return: x
WITH RECURSIVE tens(x) AS (
SELECT 10
UNION
SELECT x + 10 FROM tens WHERE x + 10 <= 100
)
SELECT x FROM tens;
--Without having to drop down to a procedural language like plpgsql or plv8.
@ilovejs
ilovejs / platform.sh
Created August 10, 2018 06:17 — forked from saicologic/platform.sh
fork of s3-bash
#!/bin/bash
if [ `uname` = "SunOS" ]; then
alias grep='/usr/gnu/bin/grep'
fi
@ilovejs
ilovejs / hyper.js
Created July 9, 2019 10:02 — forked from coco-napky/hyper.js
Hyper config for git bash in Windows
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)',
package main
import (
"fmt"
"gopkg.in/go-playground/validator.v9"
)
// Test ...
type Test struct {
package main
import (
"fmt"
"math"
)
func main() {
var i interface{}
describe(i)