Skip to content

Instantly share code, notes, and snippets.

View nvquanghuy's full-sized avatar

Huy Nguyen nvquanghuy

View GitHub Profile
@nvquanghuy
nvquanghuy / mysql.sql
Last active January 21, 2021 07:39
Unnesting strings in Redshift and MySQL
create table books (tags varchar(1000));
insert into books values
('A, B, C, D'),
('D, E'),
('F'),
('G, G, H')
;
select
shell -${SHELL}
defscrollback 10000
hardstatus string '%H:%'
bindkey -k F1 prev
bindkey -k F2 next
caption always "%{= kc}load: %l | %{W} %-w%{+br}%n %t%{-br}%+w %-21=%{= .m}%D %d.%m.%Y %0c"
create table nick(a varchar, b varchar, num integer);
insert into nick values ('a', 'a', 2), ('b', 'b', 1), ('c', 'c', 3);
with R as (
select a, b, generate_series(1, num) from nick
)
select a, b from R;
@nvquanghuy
nvquanghuy / rubymine.md
Created January 14, 2016 14:30
RubyMine Shortcuts

Huy's RubyMine shortcuts

  • Cmd + Shift + N: Open file searcher
  • Cmd + 1: toggle project explorer
  • Cmd + Shift + T: open corresponding test file
  • Cmd + B: go to definition
  • Cmd + E: Recent Files
@nvquanghuy
nvquanghuy / gist:8591653
Created January 24, 2014 03:36
fluentd multiple processes sharing same configuration
# p1.conf
<source>
type http
port 20001
</source>
include shared.conf
# p2.conf
<source>
type http
#!/bin/bash
# File location: ~/.nvm/
DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$DIR/nvm.sh"
if [ ! "$NODE_VERSION" ]; then
echo 'NODE_VERSION not set'
exit 1

Keybase proof

I hereby claim:

  • I am nvquanghuy on github.
  • I am nvquanghuy (https://keybase.io/nvquanghuy) on keybase.
  • I have a public key whose fingerprint is BA03 1572 5DAF 7195 03E0 2DEE 9181 4298 F4C5 39AD

To claim this, I am signing this object:

@nvquanghuy
nvquanghuy / resize.js
Created September 12, 2014 06:09
resize triggering
// Create a resizeEnd event trigger
$(function () {
$(window).resize(function () {
if (this.resizeTO) clearTimeout(this.resizeTO);
this.resizeTO = setTimeout(function () {
$(this).trigger('resizeEnd');
}, 500);
});
});
class JsonCoder
# Called to deserialize data to ruby object.
def load(data)
d = Oj.load(data || '{}')
d.recursive_symbolize_keys
end
# Called to convert from ruby object to serialized data.
def dump(obj)
obj.kind_of?(String) ? obj : Oj.dump(obj, mode: :compat)