Skip to content

Instantly share code, notes, and snippets.

View iporsut's full-sized avatar
🏠
Working from home

Weerasak Chongnguluam iporsut

🏠
Working from home
View GitHub Profile
@iporsut
iporsut / gist:9ca2b89eb83f7c555441
Created October 21, 2014 15:07
DummyAuthorizer Java
public class DummyAuthorizer implements Authorizer {
public Boolean authorize(String username, String password) {
return null;
}
}
type Authorizer interface {
Authorize(username, password string) (bool, error)
}
interface Authorizer {
public Boolean authorize(String username, String password);
}
@iporsut
iporsut / jstimer.html
Created September 10, 2014 03:31
JS Time Counter
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<p>Minute : <span id="minute">0</span></p>
<p>Second : <span id="second">0</span></p>
<script type="text/javascript">
var second = 0;
@iporsut
iporsut / map_reduce.hs
Created April 7, 2014 13:04
Haskell Map Reduce
import Data.Char
import Data.List
groupWord:: [(String,Integer)] -> [[(String,Integer)]]
sortLT:: (String, Integer) -> (String, Integer) -> Ordering
filterWord = filter (all isAlphaNum) . words
mapWordCounter = map (\w -> (w,1))
sortLT (w1,_) (w2,_)
@iporsut
iporsut / gist:9687086
Created March 21, 2014 14:11
Solve L99-P09 with Java 8 Feature
package com.t2decode.java.eight;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static junit.framework.Assert.assertEquals;
@iporsut
iporsut / gist:9617262
Created March 18, 2014 10:17
jQuery Slide Example
<!DOCTYPE html>
<html>
<head>
<title>Slide</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.2.6.js"></script>
<style type="text/css">
#slide-wrapper {
width: 200px;
height: 200px;
position: relative;
@iporsut
iporsut / gist:9521391
Created March 13, 2014 03:17
Form Template
#set ($url = $request.get('render-url'))
#set ($namespace = $request.get('portlet-namespace'))
#set($currentUrl = $request.attributes.CURRENT_URL)
#set($paramName = $httpUtil.getParameter($currentUrl, "question", false))
#set ($friendlyUrl = $request.get('attributes').get('FRIENDLY_URL'))
<!-- BEGIN OUTPUT -->
##$question.getData()
@iporsut
iporsut / gist:9480002
Created March 11, 2014 05:31
Add Liferay Article
@RenderMapping
public String main(RenderRequest request, RenderResponse response, Model model) throws SystemException, PortalException {
model.addAttribute("messages", messageToMDService.listMessageToMD());
if (request.getRemoteUser() != null) {
User user = UserLocalServiceUtil.getUserById(Long.parseLong(request.getRemoteUser()));
ThemeDisplay themeDisplay= (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
ServiceContext serviceContext = new ServiceContext();
@iporsut
iporsut / fizzbuzz.erl
Last active January 1, 2016 05:28
FizzBuzz Erlang with Decision Tree Model
-module (fizzbuzz).
-export ([solve/1]).
% %%Decision Tree%%
%
% fizzbuzz
% "fizzbuzz" fizz
% "fizz" buzz
% "buzz" Number