Skip to content

Instantly share code, notes, and snippets.

@qfrank
qfrank / grails note
Last active September 1, 2015 13:01
grails url-mappings-report
// test com.xx.PushServiceSpec
test-app unit: **.Push*
// specify service init non-lazy, just add a static lazyInit property with false
static lazyInit = false
import org.grails.databinding.converters.ValueConverter
import test.Address
@qfrank
qfrank / gradle note
Last active August 29, 2015 14:22
Gradle note
// setting compile encoding:
// compileJava.options.encoding = 'UTF-8'
// compileGroovy.options.encoding = 'UTF-8'
// compileTestGroovy.options.encoding = 'UTF-8'
// compileTestJava.options.encoding = 'UTF-8'
tasks.withType(AbstractCompile) {
options.encoding = 'UTF-8'
}
chrome://flags/#enhanced-bookmarks-experiment
@qfrank
qfrank / gist:9c09c3728cd8aac017b2
Last active August 29, 2015 14:23
tomcat virtual mapping xml
private static createVirtualMappingXml(){
if(Environment.current != Environment.DEVELOPMENT){
def catalinaHome = System.getenv('CATALINA_HOME')
if(!catalinaHome){
catalinaHome = System.getProperty("catalina.base")
}
if(!catalinaHome){
throw new RuntimeException("找不到环境变量CATALINA_HOME")
}
.svn
.idea
target
logs
out
stacktrace.log
*.class
# default HSQL database files for production mode
@qfrank
qfrank / TestHttpPost.java
Last active November 17, 2015 03:44
http post without ssl validation
package test;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
@qfrank
qfrank / MyImprovedNamingStrategy.java
Last active January 1, 2016 01:43
模仿grails NamingStrategy
package com.ys.scs.persistence;
import org.hibernate.AssertionFailure;
import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.internal.util.StringHelper;
/**
* User: Frank Tang <br/>
* Date: 15/11/26<br/>
@qfrank
qfrank / TableMd5.java
Created June 2, 2017 10:26
mysql table definition md5
private String md5(String table) {
String columnDefinitionSql = "SELECT column_name,ordinal_position,column_default,is_nullable,column_type\n" +
"FROM information_schema.columns\n" +
"WHERE table_schema = '%s' AND table_name = '%s' order by column_name";
MessageDigest md5 = DigestUtils.getMd5Digest();
jdbcTemplate.query(String.format(columnDefinitionSql, dbSchema, table), row -> {
ResultSetMetaData meta = row.getMetaData();
int cols = meta.getColumnCount();
for (int i = 1; i <= cols; i++) {
@qfrank
qfrank / go_port_forwarding.go
Created May 10, 2020 14:14 — forked from qhwa/go_port_forwarding.go
network port forwarding in go lang
package main
import (
"fmt"
"io"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":8080")

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.