Skip to content

Instantly share code, notes, and snippets.

@stingh711
stingh711 / gist.html
Created March 14, 2012 08:50
How to embed gist
<html>
<body id="Hallo" onload="">
<script src="https://gist.github.com/2035118.js"> </script>
</body>
</html>
@stingh711
stingh711 / pom.xml
Created March 20, 2012 03:25
pom.xml for a spring mvc project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zyxel</groupId>
<artifactId>sting</artifactId>
<name>abc</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
@stingh711
stingh711 / changelog.xml
Created March 22, 2012 10:11
Liquibase change log
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
<changeSet author="sting (generated)" id="1307605540491-1">
<createTable tableName="ADDRESSES">
<column name="ID" type="INT">
<constraints nullable="false" primaryKey="true" primaryKeyName="CONSTRAINT_D"/>
</column>
<column name="NAME" type="VARCHAR(255)"/>
</createTable>
</changeSet>
class MyMeta(type):
def __init__(cls, name, bases, attrs):
print "__init__ is called"
type.__init__(cls, name, bases, attrs)
def __call__(cls, *args, **kargs):
print "I am called"
return type.__call__(cls, *args, **kargs)
def __setattr__(cls, name, value):
@stingh711
stingh711 / sysctl.conf
Created July 9, 2012 06:21
Adjust kernel network parameters
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.core.rmem_default=65536
net.core.wmem_default=65536
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 65536 16777216
net.ipv4.tcp_mem=16777216 16777216 16777216
net.ipv4.route.flush=1
net.core.netdev_max_backlog=30000
net.ipv4.udp_mem=16777216 16777216 16777216
@stingh711
stingh711 / MinorGc.java
Created July 17, 2012 04:51
Test minor GC
private static final int _1M = 1024 * 1024;
/**
* Test with -verbose:gc -XX:+PrintGCDetails -Xms20M -Xmx20M -Xmn10M
*/
public void testMinorGc() {
byte[] a1, a2, a3, a4;
a1 = new byte[_1MG / 2];
System.out.println(1);
a2 = new byte[3 * _1MG];
@stingh711
stingh711 / MaxTenuringThreshold.java
Created July 17, 2012 06:20
Test MaxTenuringThreshold
private static final int _1M = 1024 * 1024;
/**
* Test with -verbose:gc -XX:+PrintGCDetails -Xms20M -Xmx20M -Xmn10M -XX:MaxTenuringThreshold=1
*/
public static void testMaxTenuringThreshold() {
byte[] a1, a2, a3;
a1 = new byte[_1M / 4];
System.out.println(1);
@stingh711
stingh711 / OnlyFullGc.java
Created July 17, 2012 07:35
Try to make JVM only do full GC
class OnlyFullGc {
private static final int _1M = 1024 * 1024;
//java -verbose:gc -XX:+PrintGCDetails -XX:PretenureSizeThreshold=3145728 -Xms20M -Xmx20M -Xmn10M OnlyFullGc
//1
//2
//[GC [Tenured: 9216K->4237K(10240K), 0.0110910 secs] 9543K->4237K(19456K), [Perm : 91K->91K(12288K)], 0.0113940 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
//3
//Heap
@stingh711
stingh711 / mount_ebs.sh
Created July 24, 2012 08:02
How to mount another EBS as /var on EC2 (ubuntu)
#!/bin/bash
#attach the EBS to /dev/sdf before running it
#format EBS
mkfs -t ext4 /dev/xvdf
#copy original /var to /dev/xvdf
mkdir /mnt/new
mount /dev/xvdf /mnt/new
cd /var
@stingh711
stingh711 / settings.xml
Created August 8, 2012 02:42
Maven repository setting
<?xml version="1.0"?>
<settings>
<mirrors>
<mirror>
<id>nexus</id>
<url>http://172.25.21.93:8081/nexus/content/groups/public</url>
<mirrorOf>*</mirrorOf>
</mirror>
<mirror>
<id>Midas-snapshot</id>