Skip to content

Instantly share code, notes, and snippets.

View davidchua's full-sized avatar

David davidchua

View GitHub Profile
UPDATE pg_index
SET indisready=false
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='<TABLE_NAME>'
);
UPDATE pg_index
SET indisready=true
@davidchua
davidchua / nginx.grok
Created January 31, 2019 07:10 — forked from msiegenthaler/nginx.grok
Grok pattern for nginx ingress in Kubernetes
%{IPORHOST:client_ip} - \[%{IPORHOST:x_forwarded_for}\] - %{DATA:client_identity} \[%{HTTPDATE:timestamp}\] \"(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|-)\" %{NUMBER:response} (?:%{NUMBER:bytes_sent;long}|-) (?:"(?:%{URI:referrer}|-)") %{QS:user_agent} %{NUMBER:request_length;long} %{NUMBER:response_time;double} %{DATA:upstream_proxy} %{NUMBER:upstream_bytes_sent;long} %{NUMBER:upstream_response_time} %{NUMBER:upstream_response}
@davidchua
davidchua / gist:a97242da1a4d2bd3eba1185f082ba8b5
Last active May 10, 2016 10:02
Chunking a list into groups of (x)
def chunk(l,n):
for i in range(0,len(l),n):
yield l[i:i+n]
list = [] # chunks
chunk(list, 30)
@davidchua
davidchua / ia.xml
Last active April 24, 2016 03:12
Facebook Instant Article - Jekyll Feed (FB Compliant) - More Info: http://dchua.com/2016/04/24/hooking-up-jekyll-to-facebook-instant-articles/
---
layout: null
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>{{ site.name | xml_escape }}</title>
<link>{{ site.url }}</link>
<description>
# ~/.vim/bundle/my-snippets/snippets/markdown.snippets
snippet highlight
{% highlight ${1} %}
%{2}
{% endhighlight %}
@davidchua
davidchua / redis-server-for-init.d-startup
Last active December 20, 2015 03:19 — forked from lsbardel/redis-server-for-init.d-startup
wget -O /etc/init.d/redis-server https://gist.github.com/davidchua/6062428/raw/ chmod 755 /etc/init.d/redis-server update-rc.d redis-server defaults # run it on startup
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@davidchua
davidchua / gist:5661182
Created May 28, 2013 07:59
Cappers (Capistrano) file for node.js production deployment - Make sure you have 'cappers' gem installed
set :application, "Myapp"
set :repository, "ssh://git@bitbucket.org/yourrepo/app.git"
set :deploy_to, "/approot"
set :user, 'deployer'
set :use_sudo, false
set :use_nave, false
set :main_js, 'server.js'
@davidchua
davidchua / non-rails-deploy.rb
Created March 21, 2013 01:07
Capistrano Deploy Recipe for Non-Rails App (PHP/HTML)
set :application, "<name>"
set :repository, "<repo>"
set :deploy_to, "/path/to/name"
set :user, 'deployer'
set :use_sudo, false
set :rvm_type, :system
set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
@davidchua
davidchua / non-us-s3-buckets
Created March 15, 2013 07:20
Modify ~/.s3cfg after installing s3cmd and running s3cmd --configure. This solves Errno 32: Broken Pipe error when trying to push a file to a non-US S3 bucket.
# in ~/.s3cfg
# modify host_base and host_bucket to the proper endpoints
host_base = s3-ap-southeast-1.amazonaws.com
host_bucket = %(bucket)s.s3-ap-southeast-1.amazonaws.com
@davidchua
davidchua / nginx-init
Created March 15, 2013 06:33
Working NGIX init.d script to be placed in /etc/init.d/nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon