Skip to content

Instantly share code, notes, and snippets.

View anhldbk's full-sized avatar

Anh Le (Andy) anhldbk

View GitHub Profile
anhldbk / Spooky-Capturer.js
Created September 29, 2014 09:58
Using Spooky to capture web images with customed resolutions
var spooky = new Spooky({
child: {
transport: 'http'
casper: {
logLevel: 'debug',
verbose: true,
pageSettings: {
loadImages: true, // The WebPage instance used by Casper
loadPlugins: false, // use these settings
anhldbk /
Last active April 15, 2023 03:53
Inject jQuery into Selenium Driver
from selenium import webdriver
driver = webdriver.Firefox()
with open('jquery-1.9.1.min.js', 'r') as jquery_js:
jquery = #read the jquery from a file
driver.execute_script(jquery) #active the jquery lib
anhldbk /
Created October 1, 2014 09:19
Running Selenium Headless
#!/usr/bin/env python
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
# now Firefox will run in a virtual display.
# you will not see the browser.
anhldbk /
Created October 13, 2014 07:23
Get public IP with Python & Requests
import requests
r = requests.get(r'')
ip= r.json()['ip']
print 'Your IP is', ip
anhldbk / less
Created November 4, 2014 03:20
install less compiler with yum
$ sudo yum install rubygems
$ sudo yum install gcc-c++
$ sudo yum install ruby-devel
$ sudo gem install less
$ sudo gem install therubyracer
$ lessc yourLessFile.less > yourCssFile.css
anhldbk / nginx_conf
Created November 14, 2014 02:27
Virtual Host Configuration with Nginx
# Modify file /etc/nginx/sites-enabled/default
server {
listen 80;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
anhldbk /
Created July 24, 2015 07:29
RESTful with Vert.x
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
anhldbk /
Created July 31, 2015 09:49
Sequence Handler for Vietnamese (Mallet)
import cc.mallet.pipe.Input2CharSequence;
import cc.mallet.pipe.Pipe;
import cc.mallet.pipe.SerialPipes;
import cc.mallet.types.Instance;
import cc.mallet.types.SingleInstanceIterator;
import cc.mallet.types.TokenSequence;
import vn.hus.nlp.tokenizer.VietTokenizer;
import vn.viettel.cyberspace.commons.Utils;
group 'TeeRunner'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'application' = ['src']
mainClassName = "com.bigsonata.tee.Runner"
sourceCompatibility = 1.5
repositories {
anhldbk /
Created August 15, 2015 00:10
Anaconda - create environment
conda create -n python2 python=2.7 anaconda
source activate python2