Skip to content

Instantly share code, notes, and snippets.

View up1's full-sized avatar

Somkiat Puisungnoen up1

View GitHub Profile
@up1
up1 / Hello.java
Created June 14, 2015 03:47
Facebook infer
class Hello {
int test() {
String s = null;
return s.length();
}
}
@up1
up1 / MockExampleTest.java
Last active August 29, 2015 14:23
Building Effective Unit Tests
@RunWith(MockitoJUnitRunner.class)
public class MockExampleTest {
@Mock
Context mockContext;
@Test
public void readStringFromContext() {
when(mockContext.getString(R.string.app_name)).thenReturn("GDG2015");
@up1
up1 / example.java
Last active August 29, 2015 14:23
Logging application ?
Log.info("Start process");
try {
if(ennableLogging()) {
Log.info("Start doSomething");
}
doSomething();
if(ennableLogging()) {
Log.info("Finish doSomething");
@up1
up1 / executor.yml
Last active August 29, 2015 14:23
Introduction to Taurus
---
settings:
default-executor: grinder
# Title (concise, 50 characters or fewer, imperative language — "Fetch" vs "Fetches")
# Body (detailed explanation)
# number (bug/issue/tracking if applicable)
@up1
up1 / DemoTesting01Tests.swift
Last active August 29, 2015 14:24
Xcode 7 beta 3 + Swift
import XCTest
@testable import DemoTesting01
class DemoTesting01Tests: XCTestCase {
}
@up1
up1 / comment.txt
Last active August 29, 2015 14:25
How to write bad code?
/* You are not expected to understand this. */
return TRUE; //return TRUE
/**
* isValid
* return boolean value
*/
@up1
up1 / addfriend.java
Last active August 29, 2015 14:25
Defensive programming
public void addFriendToList(List<Friend> friends, Friend newFriend) {
if (friends != null && newFriend != null) {
friends.add(newFriend);
}
}
@up1
up1 / compojure.clj
Last active August 29, 2015 14:27
Demo :: Web framework on JVM
(ns hello-world.handler
(:require [compojure.core :refer :all]
[compojure.route :as route]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]))
(defroutes app-routes
(GET "/" [] "Hello World")
(route/not-found "Not Found"))
(def app
@up1
up1 / another.feature
Last active August 29, 2015 14:27
Improve your test 01
Scenario: Reject Pre-paid account purchase
Given a user with "500 THB" in a pre-paid account
When the user attemp to buy a "700 THB" ticket
Then the purchase is rejected
And the user is left with "500 THB" in the account