Skip to content

Instantly share code, notes, and snippets.

@kyip-dev
kyip-dev / game02_temp.html
Created October 24, 2015 10:17
temp work, will be remove later
<!doctype html>
<title>Test Test</title>
<style>
#stage {
position: relative;
}
.cell {
position: absolute;
width: 80px;
@kyip-dev
kyip-dev / create-ip-to-location.sql
Created October 22, 2015 08:50
SQL-selectInsertMissingRangeRecord
CREATE TABLE IP_TO_LOCATION (
"IP_FROM" NUMBER NOT NULL,
"IP_TO" NUMBER NOT NULL,
"COUNTRY_CODE" VARCHAR2(3 CHAR) NOT NULL,
"COUNTRY_NAME" VARCHAR2(64 CHAR) NOT NULL,
"TYPE" VARCHAR2(2 CHAR),
"CHANGE_TS" TIMESTAMP (6) DEFAULT systimestamp,
CONSTRAINT IP_TO_LOCATION_PK PRIMARY KEY ("IP_FROM", "IP_TO", "TYPE")
)
@kyip-dev
kyip-dev / UserService.java
Last active October 22, 2015 09:08
Junit-argumentCaptorExample
public void updateUserCORandIP(String registerIpAddress, User consumer) {
logger.trace("COR of user [USER_ID:{}] is null, start getting COR by [IP_ADDRESS:{}]", consumer.getUserId(), registerIpAddress);
if (StringUtils.isBlank(registerIpAddress)) {
throw new WebApplicationException(new IllegalArgumentException("IP address is null, no country can be found"));
}
commonInternalApi.setBasePath(userConfiguration.getCommonModuleUrl());
String cor = null;
try {
GetCountryResponse response = commonInternalApi.getCountryMappingByIp(registerIpAddress);
@kyip-dev
kyip-dev / dao.java
Last active October 22, 2015 08:08
DAO-criteriaBuilder sample
public List<User> searchUser(String email, String mobile, String name, boolean filterDeleted) {
CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
CriteriaQuery<User> cqUser = cb.createQuery(User.class);
Root<User> rootUser = cqUser.from(User.class);
cqUser.select(rootUser);
List<Predicate> predicateList = new ArrayList<Predicate>();
Predicate p1 = cb.conjunction();