This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class B { | |
public static void main(String[] args) { | |
} | |
public class B { | |
public String d; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install ws4py | |
# pip install ws4py | |
# easy_install ws4py | |
from ws4py.client.threadedclient import WebSocketClient | |
class DummyClient(WebSocketClient): | |
def opened(self): | |
self.send("www.baidu.com") | |
def closed(self, code, reason=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//attach_shm.c | |
#include<sys/types.h> | |
#include<sys/ipc.h> | |
#include<sys/shm.h> | |
#include<stdio.h> | |
#define BUFSZ 1024 | |
int main() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import sun.jvm.hotspot.memory.*; | |
import sun.jvm.hotspot.oops.*; | |
import sun.jvm.hotspot.debugger.*; | |
import sun.jvm.hotspot.runtime.*; | |
import sun.jvm.hotspot.tools.*; | |
import sun.jvm.hotspot.utilities.*; | |
public class DirectMemorySize extends Tool { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
data := "A\xfe\x02\xff\x04" | |
for _, v := range data { | |
fmt.Printf("%#x ", v) //0x41 0xfffd 0x2 0xfffd 0x4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ABA { | |
private static int count = 0; | |
public static void main(String[] args) throws Exception { | |
ABA aba = new ABA(); | |
aba.increase(); | |
Thread.sleep(10000); | |
System.out.println(count); | |
} | |
public void increase() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KMP { | |
public static void main(String[] args) { | |
String source = "ababababcaab"; | |
String target = "abababca"; | |
KMP kmp = new KMP(); | |
int[] result = kmp.preProcess(target); | |
for(int i=0; i<result.length; i++) { | |
System.out.println(result[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user root; | |
worker_processes 1; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getLocalAddress() { | |
try { | |
// Traversal Network interface to get the first non-loopback and non-private address | |
Enumeration<NetworkInterface> enumeration = NetworkInterface.getNetworkInterfaces(); | |
ArrayList<String> ipv4Result = new ArrayList<String>(); | |
ArrayList<String> ipv6Result = new ArrayList<String>(); | |
while (enumeration.hasMoreElements()) { | |
final NetworkInterface networkInterface = enumeration.nextElement(); | |
final Enumeration<InetAddress> en = networkInterface.getInetAddresses(); | |
while (en.hasMoreElements()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//java -Xms20M -Xmx20M -Xmn10M -XX:SurvivorRatio=8 -XX:PermSize=32M -XX:MaxPermSize=64M -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -Xloggc:oom.log HeapOOM | |
import java.util.*; | |
public class HeapOOM { | |
public static void main(String[] args) { | |
List list = new ArrayList(); | |
int count = 0; | |
while(true) { | |
count++; | |
OOMObject o = new OOMObject("objname" + count); | |
if(count%10000==0) { |
NewerOlder