Skip to content

Instantly share code, notes, and snippets.

View panlw's full-sized avatar
🎯
Focusing

Neo Pan panlw

🎯
Focusing
View GitHub Profile
@panlw
panlw / idea
Created February 16, 2016 02:35 — forked from chrisdarroch/idea
Open a project in IntelliJ IDEA from your command line!
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1`
wd=`pwd`
# were we given a directory?
if [ -d "$1" ]; then
# echo "checking for things in the working dir given"
wd=`ls -1d "$1" | head -n1`
@panlw
panlw / ie67891011-css-hacks.txt
Created September 1, 2016 05:16 — forked from ricardozea/ie67891011-css-hacks.txt
IE CSS hacks - IE6, 7, 8, 9, 10, 11
IE6 Only
==================
_selector {...}
IE6 & IE7
==================
*html or { _property: }
IE7 Only
==================
@panlw
panlw / ClientInfo.java
Created July 4, 2017 14:00 — forked from c0rp-aubakirov/ClientInfo.java
How to get full client info using servlet request, including client IP, browser, os, use-agent and referer
public void printClientInfo(HttpServletRequest request) {
final String referer = getReferer(request);
final String fullURL = getFullURL(request);
final String clientIpAddr = getClientIpAddr(request);
final String clientOS = getClientOS(request);
final String clientBrowser = getClientBrowser(request);
final String userAgent = getUserAgent(request);
logger.info("\n" +
// @see https://stackoverflow.com/questions/1327074/how-to-execute-in-sql-queries-with-springs-jdbctemplate-effectivly
Set<Integer> ids = ...;
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("ids", ids);
List<Foo> foo = getJdbcTemplate().query("SELECT * FROM foo WHERE a IN (:ids)",
parameters, getRowMapper());
@panlw
panlw / CustomerRepository.kt
Created May 13, 2018 14:59
MyBatis(Kotlin)
package com.example.repository
import com.example.domain.Customer
import org.apache.ibatis.annotations.Delete
import org.apache.ibatis.annotations.Insert
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.SelectKey
import org.apache.ibatis.annotations.Update
@panlw
panlw / .ackrc
Created May 27, 2018 06:27 — forked from hernamesbarbara/.ackrc
Example configuration for using Ack to search file tree
#ack is a tool like grep, designed for programmers with large trees of heterogeneous source code
#to install ack, see http://betterthangrep.com/
#to use ack, launch terminal (mac osx) and type 'ack <some_keywords>'
#ack will search all files in the current directory & sub-directories
#here's how I have my config file setup. this file is located on mac osx here
# ~/.ackrc
# Always sort the files
@panlw
panlw / default
Created May 27, 2018 10:10 — forked from dtomasi/default
Brew Nginx PHP7
server {
listen 80;
server_name localhost;
root /Users/YOUR_USERNAME/Sites;
access_log /Library/Logs/default.access.log main;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
}
@panlw
panlw / dnsmasq OS X.md
Created May 27, 2018 16:16 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.

Requirements

Install

@panlw
panlw / macosx-install-php-oracle-oci8.md
Created June 1, 2018 03:15 — forked from thinhhung/macosx-install-php-oracle-oci8.md
install Oracle PHP Extension (oracle OCI8) - instantclient for Mac OS 10.8 - homebrew environnement

Installation

This procedure is tested on Mac OS X 10.12.5 with Developpers tools installed (xCode).

PHP 7.1 installed with Homebrew.

Preparation

Download the following files from Oracle website (yes, you need to create an account and accept terms):

@panlw
panlw / MongoUtil.java
Created June 8, 2018 03:19
Timestamp in ObjectId of MongoDB
public abstract class EdpMongoUtil {
/**
* @param objectId ObjectId of MongoDB
* @return time of java.time.Instant
*/
public static Instant timeFromObjectId(String objectId) {
return Instant.ofEpochMilli(Integer.parseInt(objectId.substring(0, 8), 16) * 1000);
}