Skip to content

Instantly share code, notes, and snippets.

@asserchiu
asserchiu / affirmation
Created May 22, 2015 18:45
MuleSoft Contributor Agreement Acceptance by Asser Chiu
I, Asser Chiu, have read and do accept the MuleSoft Contributor Agreement
at http://www.mulesoft.org/legal/contributor-agreement.html
Accepted on Sat May 23 2015 02:45:05 GMT+0800 (Taipei Standard Time)
@asserchiu
asserchiu / score_a_word.py
Created May 21, 2015 10:08
Score a word with a: 1, b: 2, ..., z: 26.
#!/usr/bin/python
# -*- coding: utf-8 -*-
def score_a_word(word=''):
# TODO: add exception!
sum = 0
for char in word.lower():
sum += (ord(char) - 96)
print(word + ' for ' + str(sum))
@asserchiu
asserchiu / gist:73e577a739529d7ba53d
Last active November 27, 2018 02:34
Bookmarklets
// GoTo: Canonical URL of current page
javascript:(function(){document.location=document.querySelector("link[rel='canonical']").href;})();
// GoTo: Amazon ASIN URL (minimal URL for items)
javascript:(function(){document.location=document.location.origin+'/dp/'+document.getElementById('ASIN').value;})();
// Get: QR Code of current page
javascript:(function(){document.location="http://chart.apis.google.com/chart?chs=256x256&cht=qr&chld=|1&chl="+encodeURIComponent(document.location);})();
// Enable and Disable document design mode
@asserchiu
asserchiu / Telegram.desktop
Created February 25, 2015 14:42
Telegram Web in `webapp-container`. Tested in Ubuntu Trusty. Change the *Icon* to your own icon path. It is recommanded to place this file at `/usr/share/applications/`(for all users) or at `~/.local/share/applications/`(for current user).
[Desktop Entry]
Name=Telegram Web
Comment=Telegram Web in `webapp-container`
Type=Application
Icon=/path/to/Telegram.png
Exec=webapp-container --store-session-cookies --webappUrlPatterns=https?://web.telegram.org/* https://web.telegram.org/ %u
Terminal=false
Categories=Network;
@asserchiu
asserchiu / fillZero.py
Last active August 29, 2015 14:14
Zero fill all files ends with .secrete using python3
#!/usr/bin/env python
# Tested in:
# Windows 8.1 Enterprise, en_US
# Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05)
# [MSC v.1600 32 bit (Intel)] on win32
import os
import sys
@asserchiu
asserchiu / index.html
Created October 20, 2014 08:02
Weekly distribution in block styled visualization.
<!--
House Hunter By Day, Not So Much After Midnight - Trulia TrendsTrulia Trends
http://www.trulia.com/trends/2011/09/house-hunter-by-day-not-so-much-after-midnight/
House Hunting All Day, Every Day - Trulia Insights
http://www.trulia.com/vis/tru247/
-->
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
@asserchiu
asserchiu / gist:817bf66ccf209e24d0fe
Last active September 9, 2018 07:27
C pointers.
char *x; // x: a pointer to char
char x[3]; // x: an array[3] of char
char x(); // x: a function() returning char
char *x[3]; // x: an array[3] of pointer to char
char (*x)[3]; // x: a pointer to array[3] of char
char **x; // x: a pointer to pointer to char
char *x(); // x: a function() returning pointer to char
char *x()[3]; // x: a function() returning array[3] of pointer to char
char (*x[])(); // x: an array[] of pointer to function() returning char
char (*x())(); // x: a function() returning pointer to function() returning char
@asserchiu
asserchiu / README.md
Last active August 29, 2015 14:04
Online regular expression editor and tester
@asserchiu
asserchiu / Preferences.sublime-settings
Last active October 23, 2016 09:05
Sublime Text Preference
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"close_windows_when_empty": false,
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"find_selected_text": true,
"fold_buttons": true,
"folder_exclude_patterns":
@asserchiu
asserchiu / gist:10273352
Last active August 29, 2015 13:58
JavaScript `for ... in ... xxx.hasOwnProperty`
var a = {
'0': 3,
'3': 5,
'10': 8
};
function fn(dics, num) {
var resp = null;
var keys = Object.keys(dics);
console.log("----------");