Skip to content

Instantly share code, notes, and snippets.

View ldong's full-sized avatar
Love & Peace

Alan Dong ldong

Love & Peace
  • Sunnyvale, CA
View GitHub Profile
ldong / vimrc_2018
Created August 18, 2018 01:02
2018 Vimrc
View vimrc_2018
" ==============================================================================
" Author: Alan Dong
" Version: 0.3.5
" Last Modified Date: 8/17/2018
" Description: My Vim Configuration file
" ==============================================================================
" set shell for bash as default
set shell=/bin/bash
CatTail / proto.js
Last active November 27, 2017 02:55
Javascript prototype in a nutshell
View proto.js
var assert = require('assert')
var util = require('util')
function test (inherits) {
function Fruit () {
Fruit.prototype.round = false
Fruit.prototype.sweet = true = function () {}
simonw /
Last active October 26, 2023 16:25
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using and

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
indiesquidge / promise-dot-all.js
Last active May 27, 2020 01:18
Recreating Promise.all with async/await
View promise-dot-all.js
Let us re-create `Promise.all`
`Promise.all` method returns a promise that resolves when all of the promises in the iterable argument have resolved,
or rejects with the reason of the first passed promise that rejects.
Read more about `Promise.all` on MDN:
A basic example would be something like this:
ldong /
Last active April 10, 2018 20:07
Brew formulas that definitely **NEED** to be installed
/usr/bin/ruby -e "$(curl -fsSL"

brew install tree rmtrash ag sift python python3 gawk tmux cscope ctags fasd git git-flow aria2 wget mmv rename

brew install tig jq fpp cloc htop ctop shellcheck mycli

brew tap homebrew/command-not-found
leonardofed /
Last active December 2, 2023 09:35
A curated list of AWS resources to prepare for the AWS Certifications

A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.

jamiewilson /
Last active September 6, 2023 23:19
Focusable HTML Elements

CSS :focus Selector

The :focus selector is used to select the element that has focus. It is allowed on elements that accept keyboard events or other user inputs.

  • HTMLInputElement
  • HTMLSelectElement
  • HTMLTextAreaElement
  • HTMLAnchorElement
  • HTMLButtonElement
  • HTMLAreaElement
pablobm /
Last active June 3, 2022 10:07
A clear convention for a CRUD with standard Ember + Ember Data

CRUD with Ember (+ Data)

Compatible with Ember 1.13.0+ Compatible with Ember Data 1.13.0+

Ember's official documentation describes a number of low-level APIs, but doesn't talk much about how to put them together. As a result, a simple task such as creating a simple CRUD application is not obvious to a newcomer.

dannguyen /
Last active October 25, 2023 20:03
Using Python 3.x and Google Cloud Vision API to OCR scanned documents to extract structured data

Using Python 3 + Google Cloud Vision API's OCR to extract text from photos and scanned documents

Just a quickie test in Python 3 (using Requests) to see if Google Cloud Vision can be used to effectively OCR a scanned data table and preserve its structure, in the way that products such as ABBYY FineReader can OCR an image and provide Excel-ready output.

The short answer: No. While Cloud Vision provides bounding polygon coordinates in its output, it doesn't provide it at the word or region level, which would be needed to then calculate the data delimiters.

On the other hand, the OCR quality is pretty good, if you just need to identify text anywhere in an image, without regards to its physical coordinates. I've included two examples:

####### 1. A low-resolution photo of road signs

View .git.alias
ga='git add'
gaa='git add --all'
galias='alias | grep git'
gapa='git add --patch'
gb='git branch'
gba='git branch -a'
gbda='git branch --merged | command grep -vE "^(\*|\s*master\s*$)" | command xargs -n 1 git branch -d'
gbl='git blame -b -w'
gbnm='git branch --no-merged'