Skip to content

Instantly share code, notes, and snippets.

View anhldbk's full-sized avatar
🌴
Calm

Anh Le (Andy) anhldbk

🌴
Calm
View GitHub Profile
@anhldbk
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
anhldbk / Selenium.Python.InjectJS.py
Last active April 15, 2023 03:53
Inject jQuery into Selenium Driver
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://www.facebook.com/')
with open('jquery-1.9.1.min.js', 'r') as jquery_js:
jquery = jquery_js.read() #read the jquery from a file
driver.execute_script(jquery) #active the jquery lib
driver.execute_script("$('#email').text('anhld')")
@anhldbk
anhldbk / Selenium.Python.Headless.py
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))
display.start()
# now Firefox will run in a virtual display.
# you will not see the browser.
@anhldbk
anhldbk / get_public_ip.py
Created October 13, 2014 07:23
Get public IP with Python & Requests
import requests
r = requests.get(r'http://jsonip.com')
ip= r.json()['ip']
print 'Your IP is', ip
@anhldbk
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
anhldbk / nginx_conf
Created November 14, 2014 02:27
Virtual Host Configuration with Nginx
# Modify file /etc/nginx/sites-enabled/default
server {
listen 80;
server_name data.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
@anhldbk
anhldbk / LinguisticsServer.java
Created July 24, 2015 07:29
RESTful with Vert.x
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vertx.java.core.Handler;
import org.vertx.java.core.Vertx;
import org.vertx.java.core.VertxFactory;
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.core.http.RouteMatcher;
import java.io.IOException;
@anhldbk
anhldbk / CharSequence2VietnameseTokenSequence.java
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;
import java.io.*;
group 'TeeRunner'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'application'
sourceSets.main.java.srcDirs = ['src']
mainClassName = "com.bigsonata.tee.Runner"
sourceCompatibility = 1.5
repositories {
@anhldbk
anhldbk / run.sh
Created August 15, 2015 00:10
Anaconda - create environment
conda create -n python2 python=2.7 anaconda
source activate python2