Skip to content

Instantly share code, notes, and snippets.

@Asoul
Asoul / injected_code.js
Created March 17, 2015 12:20
Some one Injected My Chrome
if(!window.jQuery){!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m="1.11.0",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,argum
@Asoul
Asoul / bash_profile
Created September 1, 2015 15:33
Git bash
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
#export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
export PS1="\[\033[36m\]\u\[\033[m\] @ \[\033[31m\]\h:\[\033[33m\]\w\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
@Asoul
Asoul / invisible.txt
Created June 29, 2016 09:33
Invisible character
i​n​v​i​s​i​b​l​e
@Asoul
Asoul / send_line.py
Created July 16, 2016 09:39
An simple example to send line with BOT api
def send_line(message):
data = {
"to": ["YOUR-LINE-USER-ID"],
"toChannel": 1383378250,
"eventType": "138311608800106203",
"content": {
"contentType": 1,
"toType": 1,
"text": message
}

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@Asoul
Asoul / style.less
Created February 17, 2017 03:49
Atom style, darken the invisible and guide lines
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed and saved.
*
* Add your own CSS or Less to fully customize Atom.
* If you are unfamiliar with Less, you can read more about it here:
* http://lesscss.org
*/
window.i18n = window.i18n || {};
i18n._langCache = {}
i18n._availableLangs = [
'en',
'zh-TW',
'ja'
]
import requests
import time
endpoint = 'http://mis.twse.com.tw/stock/api/getStockInfo.jsp'
targets = ['0050']
timestamp = int(time.time() * 1000 + 1000000)
channels = '|'.join('tse_{}.tw'.format(target) for target in targets)
query_url = '{}?_={}&ex_ch={}'.format(endpoint, timestamp, channels)
req = requests.session()
req.get('http://mis.twse.com.tw/stock/index.jsp')
print(query_url)
class KMP:
def partial(self, pattern):
""" Calculate partial match table: String -> [Int]"""
ret = [0]
for i in range(1, len(pattern)):
j = ret[i - 1]
while j > 0 and pattern[j] != pattern[i]:
j = ret[j - 1]
ret.append(j + 1 if pattern[j] == pattern[i] else j)