This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static String convert2Round(String thaiString) throws UnsupportedEncodingException { | |
| String result = ""; | |
| String[] charset = {"ISO-8859-1", "UTF-8", "TIS-620"}; | |
| for(int i=0; i<charset.length; i++) { | |
| for(int j=0; j<charset.length; j++) { | |
| if(charset[i].equals(charset[j])) { | |
| continue; | |
| } | |
| String encode = "Style: algo=" + charset[i] + ">" + charset[j] + "\n"; | |
| encode += "Style: result=" + new String(thaiString.getBytes(charset[i]), charset[j]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MergeOperation implements RxOperationCase { | |
| @Override | |
| public void runSmoothAtSilk() { | |
| String TAG = "MergeOperation.runSmoothAtSilk"; | |
| System.out.println(TAG + " START >>>>>> "); | |
| Observable.merge(UserProfile.mockApi(), LuckyCategory.mockApi(), FortuneQueue.mockApi()) | |
| .observeOn(Schedulers.io()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Experiment { | |
| private static final long WAIT_TIME = TimeUnit.SECONDS.toMillis(1); | |
| private static void wait1Seconds() { | |
| try { | |
| Thread.sleep(WAIT_TIME); | |
| System.out.println(); | |
| } catch (InterruptedException e) { | |
| e.printStackTrace(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface Api { | |
| String getApiName(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UserProfile implements Api { | |
| private String id; | |
| private String name; | |
| private int level; | |
| private long userExp; | |
| private long expToNextLevel; | |
| private String currentCategory; | |
| public static Observable<Api> mockApi() { | |
| return Observable.just(getUserFromSession("mocking")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LuckyCategory implements Api { | |
| private String category; | |
| private int entryNo; | |
| private double discountRate; | |
| public static Observable<Api> mockApi() { | |
| LuckyCategory luckyCategory = new LuckyCategory(); | |
| luckyCategory.setCategory("Shoe"); | |
| luckyCategory.setEntryNo(25); | |
| luckyCategory.setDiscountRate(10.5); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FortuneQueue implements Api { | |
| private int entryNo; | |
| private Date entryTime; | |
| private int luckyScale; | |
| public static Observable<Api> mockApi() { | |
| FortuneQueue queue = new FortuneQueue(); | |
| queue.setEntryNo(25); | |
| queue.setEntryTime(new Date(System.currentTimeMillis())); | |
| queue.setLuckyScale(5); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| boolean luckyUser = FortuneQueue.enterNo(API 2) == LuckyCategory.enterNo(API 3) && | |
| UserProfile.currentCategory(API 1) == LuckyCategory.category(API 3); | |
| if(luckyUser) { | |
| boolean receiveSpecialDiscount = | |
| ((FortuneQueue.luckyScale(API 2) * UserProfile.userExp(API 1))/ UserProfile.expToNextLevel(API 1)) | |
| > 1; | |
| if(receiveSpecialDiscount) { | |
| discountAmount = totalBuy * LuckyCategory.discountRate(API 3); | |
| payAmount = totalBuy - discountAmount; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DivideExample { | |
| public static void main(String[] args) { | |
| int a = 9; | |
| int b = 2; | |
| int c = 5; | |
| double average1 = (a+b+c) / 3; | |
| System.out.println("average1 of a+b+c = " + average1); | |
| int x = 9; | |
| int y = 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AskMonitor am = new AskMonitor("Time Vortex Hocus", 2, alarm); | |
| am.setValue(3); | |
| if (am.getValue() > am.getLimit()) | |
| am.getAlarm().warn(am.getName() + " too high"); |
NewerOlder