Skip to content

Instantly share code, notes, and snippets.

@fengshuo
fengshuo / sidekiq_monitoring
Created July 16, 2019 19:55 — forked from ngsmrk/sidekiq_monitoring
Sidekiq queue checking via rails console
stats = Sidekiq::Stats.new
stats.queues
stats.enqueued
stats.processed
stats.failed
@fengshuo
fengshuo / Trie.js
Created June 7, 2019 18:33 — forked from deadlocked247/Trie.js
Trie implementation in ES6, good for string autocomplete
/* Class representing a Trie data structure */
export default class Trie {
/**
* Creates a Trie
* @return {Object} Trie
*/
constructor() {
this.words = 0;
this.prefixes = 0;
@fengshuo
fengshuo / postgres_queries_and_commands.sql
Created January 17, 2019 20:57 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@fengshuo
fengshuo / nokogiri_install
Created November 9, 2018 21:18 — forked from sobstel/nokogiri_install
nokogiri -> ERROR: cannot discover where libxml2 is located on your system
# `ERROR: Error installing nokogiri:
# ERROR: Failed to build gem native extension.
#
# current directory: /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.7.0/ext/nokogiri
# /usr/local/var/rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170103-68488-r71c9j.rb extconf.rb --with-xml=/usr/local/Cellar/libxml2/ --use-system-libraries
# checking if the C compiler accepts ... yes
# checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
# Building nokogiri using system libraries.
# ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
# *** extconf.rb failed ***
@fengshuo
fengshuo / git-tag-delete-local-and-remote.sh
Created April 26, 2017 00:42 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@fengshuo
fengshuo / gist:b0fe2721cbc0f6cae2ac380c4596cb8f
Last active March 15, 2017 23:33 — forked from lucasdinonolte/gist:4016361
Copy current git branch to clipboard
For those, who don't know how to make this work: create a file, e.g. git_branch_name_to_clipboard.sh in your user directory with following content:
`git branch | grep "*" | awk '{ print $2 }' | pbcopy`
or use this to remove the new line when you paste:
`git branch | grep "*" | awk '{ print $2 }' | tr -d '\n' | pbcopy`
Then in `.gitconfig file`, which is located in your user folder, add these lines under [alias]:
@fengshuo
fengshuo / index.html
Last active November 27, 2016 18:45
force layout large
<!DOCTYPE html>
<meta charset="utf-8">
<style>
rect{
fill: white;
}
circle {
stroke: #000;
stroke-opacity: .5;
}
@fengshuo
fengshuo / index.html
Created November 24, 2016 01:33
force layout
<!DOCTYPE html>
<meta charset="utf-8">
<style>
rect{
fill: white;
}
circle {
stroke: #000;
stroke-opacity: .5;
}
@fengshuo
fengshuo / 0-react-hello-world.md
Created March 14, 2016 13:29 — forked from danawoodman/0-react-hello-world.md
React Hello World Examples
@fengshuo
fengshuo / cat-colors.json
Created March 5, 2016 11:44
PostCSS basic setup and test with Gulp
{
"colorList": {
"c1" : ["#000000", "#000011"],
"c2" : ["#000011", "#000022"],
"c3" : ["#000022", "#000033"],
"c4" : ["#000033", "#000044"],
"c7" : ["#000044", "#000055"],
"c8" : ["#000055", "#000066"],
"c9" : ["#000066", "#000077"],
"c10" : ["#000077", "#000088"]