Skip to content

Instantly share code, notes, and snippets.

Avatar

Huy Nguyen nvquanghuy

View GitHub Profile
@nvquanghuy
nvquanghuy / mysql.sql
Last active Jan 21, 2021
Unnesting strings in Redshift and MySQL
View mysql.sql
create table books (tags varchar(1000));
insert into books values
('A, B, C, D'),
('D, E'),
('F'),
('G, G, H')
;
select
View .screenrc
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"
View replicate.sql
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 Jan 14, 2016
RubyMine Shortcuts
View rubymine.md

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 Jan 24, 2014
fluentd multiple processes sharing same configuration
View gist:8591653
# p1.conf
<source>
type http
port 20001
</source>
include shared.conf
# p2.conf
<source>
type http
View nvm-exec
#!/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
View keybase.md

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 Sep 12, 2014
resize triggering
View resize.js
// Create a resizeEnd event trigger
$(function () {
$(window).resize(function () {
if (this.resizeTO) clearTimeout(this.resizeTO);
this.resizeTO = setTimeout(function () {
$(this).trigger('resizeEnd');
}, 500);
});
});
View gist:8894931
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)