Skip to content

Instantly share code, notes, and snippets.

@gary-liguoliang
gary-liguoliang / gist:9403188
Last active September 3, 2015 10:01
Using JNDI in Spring - JNDI DataSource / Environment - using a <jee:jndi-lookup string inside an instance of PropertyPlaceholderConfigurer
<!-- by https://gist.github.com/prule/5523826 -->
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd">
@gary-liguoliang
gary-liguoliang / gist:9481416
Last active March 23, 2016 06:00
Disable automatic redirect in HttpGet using HttpClient
// HttpClient Version: 4.3.3
RequestConfig requestConfig = RequestConfig.custom().setRedirectsEnabled(false).build();
httpGet.setConfig(requestConfig);
CloseableHttpResponse response = httpClient.execute(httpGet);
System.out.println("Status Code: " + response.getStatusLine().getStatusCode());
// Older version: http://stackoverflow.com/questions/1519392/how-to-prevent-apache-http-client-from-following-a-redirect
package com.liguoliang.lang.collection;
import static org.junit.Assert.*;
import java.util.Iterator;
import org.junit.Before;
import org.junit.Test;
public class GListTest {
package com.liguoliang.lang.collection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class GList <T> implements Iterable<T>{
private List<T> _items = new ArrayList<T>();
@gary-liguoliang
gary-liguoliang / designer.html
Last active August 29, 2015 14:22
designer
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
map z createActiveTabbedHint
map u openLinkSearchBar
let qmark a = ["http://google.com", "http://reddit.com"]
@gary-liguoliang
gary-liguoliang / convert-java-system-out-to-slf4j.py
Last active November 3, 2018 10:32
Convert all java system.out.print to SLF4J
"""
Copyright 2015 Guoliang Li
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
@gary-liguoliang
gary-liguoliang / cout-java-import-classes.py
Created September 20, 2016 14:46
count Java import classes
"""
Copyright 2015 Guoliang Li
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
@gary-liguoliang
gary-liguoliang / Disable_Caps_Lock.reg
Created September 22, 2016 02:07
Disable_Caps_Lock.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
def further_process(file_name):
print 'processing :%s' % file_name
print 'processing: file: %s' % file_name
def split_to_files(s, split_start_with, split_end_with, func):
cursor = 0
while cursor >= 0:
try:
cursor = s.index(split_start_with, cursor + 1)