Skip to content

Instantly share code, notes, and snippets.

View askeing's full-sized avatar

Askeing Yen (fyen) askeing

View GitHub Profile
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
@askeing
askeing / MutationObserverGoogleDocs.js
Last active April 8, 2016 09:21
MutationObserver of Google Docs
var editor = document.querySelector('.kix-appview-editor');
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
var entry = {
mutation: mutation,
el: mutation.target,
value: mutation.target.textContent,
oldValue: mutation.oldValue
};
https://bugzilla.mozilla.org/show_bug.cgi?id=1206649#c11
1) Install HAR Export Trigger extension
https://addons.mozilla.org/en-US/firefox/addon/har-export-trigger/
(you need Firefox 42+)
2) Set the following prefs in your Firefox profile:
devtools.netmonitor.har.enableAutoExportToFile;true // auto export when page load finishes
extensions.netmonitor.har.autoConnect;true // This one allows exporting without the Toolbox
@askeing
askeing / 2016-04-14_Perf_Timing_Data.txt
Last active April 15, 2016 08:41
2016-04-14 Perf Timing of G-Force-Test 200 Pages
PerfTiming Chart: http://askeing.github.io/D3_performance_chart/
200+ pages Data: https://docs.google.com/document/d/1EpYUniwtLvBbZ4ECgT_vwGUfTHKnqSWi7vgNJQBemFk/edit?pref=2&pli=1
empty pages Date: https://docs.google.com/document/d/1YNxUZPc7xB4OtnxnRLMIKlagMzSOh3_uggp2WCz3aww/edit
@askeing
askeing / install_packages.sh
Last active April 14, 2016 19:07
Homebrew and Git
alias ll='ls -lah'
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
if [ -f ~/.bashrc ]; then
@askeing
askeing / error test
Created April 15, 2016 02:06
servo mach test error
Ran 4669 tests finished in 2872.0 seconds.
• 4650 ran as expected. 1361 tests skipped.
• 2 tests crashed unexpectedly
• 17 tests timed out unexpectedly
Error running mach:
['test']
The error occurred in code that was called by the mach command. This is either
@askeing
askeing / remove_all_merged_remote_branches.sh
Created June 1, 2016 03:17
Remove all merged remote branches
git branch -r --merged master | sed 's/ *origin\///' | grep -v 'master$' | xargs git push origin --delete
@askeing
askeing / correlation_similarity.py
Last active July 26, 2016 08:25
correlation coefficient and cosine similarity
import numpy
def corr_percentage(a, b):
# Ref:
# - https://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient
# - http://docs.scipy.org/doc/numpy/reference/generated/numpy.corrcoef.html
#return 0.5 * numpy.corrcoef(a,b)[0][1] + 0.5
return numpy.abs(numpy.corrcoef(a,b)[0][1])
def cosine_similarity(a, b):
@askeing
askeing / bootstrap-linux.sh
Last active September 6, 2016 07:26
Create Ubunt 14.04 LTS VM on Linux
#!/bin/bash
# Author: askeing
# Version: 0.0.1
func_log () {
echo "$@" | tee -a bootstrap-linux.log
}
################
# Create new Firefox profile
## Mac, Windows
firefox --profile <PROFILE_DIR> -silent
## Ubuntu
firefox -createprofile "<PROFILE_NAME> <PROFILE_DIR>" -silent
# disable Flash
user_pref("plugin.state.flash", 0);