Skip to content

Instantly share code, notes, and snippets.

View gilbertwat's full-sized avatar

Gilbert Wat gilbertwat

View GitHub Profile
@gilbertwat
gilbertwat / gist:4010030
Created November 4, 2012 03:33 — forked from stran12/gist:1394757
Step-by-step installation of cGit with Nginx

How to install cGit on Nginx (Ubuntu server)

Step-by-step installtion of cGit on nginx without funky rewrite rules.

Pre-requisites

This is for :

@gilbertwat
gilbertwat / remove-artifacts-gh.sh
Created March 23, 2022 09:16
Remove all Github Action Artifacts for 1 repo
#!/bin/zsh
ORG=${ORG:-"preface-ai"}
REPO=${REPO:-"preface-website-frontend"}
echo "Removing artifacts in {$REPO} from {$ORG}"
IDS="$(gh api /repos/$ORG/$REPO/actions/artifacts --paginate --jq '.artifacts[] | .id')"
echo $IDS
if [ -z "$IDS" ];
@gilbertwat
gilbertwat / AppLocaleDatePickerDialog.java
Created January 25, 2013 03:40
DatePickerDialog that honors the locale set by the app
package com.gilbert.wat.widget;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Calendar;
import android.app.DatePickerDialog;
import android.content.Context;
import android.os.Build;
import android.widget.DatePicker;
@gilbertwat
gilbertwat / ExpandableTextView.java
Created August 26, 2013 05:56
A TextView that only click to expand to show full text and click to show shorten text, The ellipsis can be configured too.
package com.mpayme.znap.core.widget;
import java.lang.reflect.Field;
import android.content.Context;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
@gilbertwat
gilbertwat / .vimrc
Last active January 31, 2020 09:19
.vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-plug stuff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin()
" Fuzzy Search
Plug '/usr/local/opt/fzf'
" Surround open / close
Plug 'tpope/vim-surround'
" File explorer
Plug 'scrooloose/nerdtree'
set-window-option -g mode-keys vi
set-option -g history-limit 3000
set -g mouse on
@gilbertwat
gilbertwat / how-to-do-technical-discussion.md
Created May 8, 2018 00:09
How to do technical discussion?

How to do technical discussion?

  1. Define problems.
  • Define common terms:
    • What means by x ? Even when x is a common terms?
      • For example in delivery platform: What means by refund? Turns out engineering team has different definition with product team 😅
      • Save us precious time and make sure our discussion is valid
  • Define priorities (Tech Lead responsibility):
  • Is it life or death?
@gilbertwat
gilbertwat / avoid_deadlock.rb
Created March 27, 2018 09:01
Avoid Deadlock
def must_deadlock
new_waypoints = get_new_waypoints
order.transaction do
order.waypoints.destroy_all
new_waypoints.each |waypoint| do
Order.waypoints.create!(waypoint)
end
end
end
@gilbertwat
gilbertwat / ggv_geekbot.rb
Created December 25, 2017 07:05
Geekbot API to CSV for easy analysis
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'rubygems'
require 'json'
require 'csv'
after = 1509494400 #2017-11-01 00:00:00 +0800
user_id = 'JS Console Network Tab can help you'
@gilbertwat
gilbertwat / GGV_outage_template.md
Last active December 13, 2017 02:42
GGV_outage_template.md

Outage Report

Duration: (x)min
From: YYYYMMDDHHmm
To: YYYYMMDDHHmm
Summary: summary

Outage Timeline:

HHmm: Problem Found
HHmm: Ops screaming