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 / executorService.java
Last active January 7, 2016 15:53
Using executor services
public class LimitedQueue<E> extends LinkedBlockingQueue<E>
{
public LimitedQueue(int maxSize)
{
super(maxSize);
}
@Override
public boolean offer(E e)
@anhldbk
anhldbk / install.md
Last active December 2, 2015 03:45
SBT with local maven

Install Jar file to local

mvn install:install-file -Dfile=spark-redis-master-assembly-0.1.0.jar -DgroupId=com.redislabs -DartifactId=spark-redis -Dversion=0.5.1 -Dpackaging=jar

Enable local maven

Put resolvers += Resolver.mavenLocal in your build.sbt file

name := "Wordy"
@anhldbk
anhldbk / run.sh
Created August 15, 2015 00:10
Anaconda - create environment
conda create -n python2 python=2.7 anaconda
source activate python2
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 / 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.*;
@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 / 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 / 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 / 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 / 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.