Skip to content

Instantly share code, notes, and snippets.

View up1's full-sized avatar

Somkiat Puisungnoen up1

View GitHub Profile
@up1
up1 / build.gradle
Created October 14, 2015 03:30
Android Lint
android {
...
lintOptions {
// set to true to turn off analysis progress reporting by lint
quiet true
// if true, stop the gradle build if errors are found
abortOnError false
// if true, only report errors
ignoreWarnings true
@up1
up1 / CSVLibrary.py
Last active January 11, 2022 19:04
Robot Framework :: Working with CSV file
class CSVLibrary(object):
def read_csv_file(self, filename):
file = open(filename, 'r')
csvfile = csv.reader(file)
file.close
return [row for row in csvfile]
@up1
up1 / X.java
Created October 22, 2015 06:44
Singleton pattern
public class X {
private static X instance = null;
private X() {}
public static X instance() {
if (instance == null)
instance = new X();
return instance;
}
@up1
up1 / after.txt
Last active October 24, 2015 10:04
Elasticsearch :: special character
curl -XGET 'localhost:9200/twitter/_analyze?pretty=1&field=message' -d "Hello #Elasticsearch with @somkiat"
{
"tokens" : [ {
"token" : "hello",
"start_offset" : 0,
"end_offset" : 5,
"type" : "word",
"position" : 1
}, {
"token" : "#elasticsearch",
@up1
up1 / ImageValidator.php
Last active October 29, 2015 11:51
Demo of Compose method
class ImageValidator{
public function validate($value, Constraint $constraint){
if (null === $value || '' === $value) {
return;
}
if (null === $constraint->minWidth && null === $constraint->maxWidth) {
return;
}
@up1
up1 / Company.java
Last active November 5, 2015 10:07
miniCRM
class Company {
public int id;
public String name;
}
@up1
up1 / UserService.java
Last active November 13, 2015 14:49
Test Double :: Mock, Stub and Dummy
public class UserService {
private final UserDAO userDAO;
public UserService(UserDAO userDAO) {
this.userDAO = userDAO;
}
public void createUser(User user) {
//Some business logic and validation and etc
userDAO.save(user);
@up1
up1 / BusinessModel
Created November 22, 2015 15:08
My Haskell
class BusinessModel a where
data Event a :: *
data Command a :: *
init :: a
act :: Command a -> a -> Event a
apply :: Event a -> a -> a
@up1
up1 / Aha.java
Last active November 23, 2015 14:30
Java :: Pzzle
import static java.lang.System.out;
public class Aha {
public static void main(String ... args) {
Integer a = 1000, b = 1000;
out.println(a == b);
Integer c = 100, d = 100;
out.println(c == d);
}
}
@up1
up1 / convert.sh
Created November 25, 2015 08:22
VLC :: convert from wma to mp3
//https://khom.wordpress.com/2010/04/21/convert-mp4-and-flv-video-to-mp3-with-vlc/
for file in //Users/somkiat/Desktop/agile-tour-2015/Ked2/*.wma;
do /Applications/VLC.app/Contents/MacOS/VLC -I dummy "$file" --sout="#transcode{acodec=mp3,vcodec=dummy}:standard{access=file,mux=raw,dst=\"$(echo "$file" | sed 's/\.[^\.]*$/.mp3/')\"}" vlc://quit;
done