Skip to content

Instantly share code, notes, and snippets.

View ggrandes's full-sized avatar
🛠️
I may be slow to respond.

G.Grandes ggrandes

🛠️
I may be slow to respond.
  • Spain
  • 09:20 (UTC +02:00)
View GitHub Profile
@chixq
chixq / sigar.java
Created May 21, 2013 06:19
java system monitor using sigar
import java.util.ArrayList;
import java.util.List;
import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.CpuPerc;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.cmd.Ps;
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active April 24, 2025 05:26
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@witscher
witscher / tomcat.conf
Created June 13, 2012 13:24
Apache Tomcat Upstart script
description "Tomcat Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
# run as non privileged user
# add user with this command:
## adduser --system --ingroup www-data --home /opt/apache-tomcat apache-tomcat
@ayosec
ayosec / LibC.java
Created December 24, 2011 01:41
LibC binding with JNA
package com.ayosec.misc;
import com.sun.jna.*;
public class LibC {
public interface Handle extends Library {
Handle module = (Handle) Native.loadLibrary("c", Handle.class);
int getpid();
@isopov
isopov / KeepAliveLocalhostTest.java
Created July 16, 2011 20:52
Simple bench comparing creating new connection per each HttpRequest and using one keep-alive connection (Based on Netty)
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.charset.Charset;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.bootstrap.ServerBootstrap;
@isopov
isopov / NettyTest.java
Created July 12, 2011 09:52
Problem with sending/receiving Http POST request with Netty (solved)
import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK;
import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.util.concurrent.Executors;
import junit.framework.Assert;
@stfp
stfp / SelfKiller.java
Created May 19, 2011 03:21
Java class to kill the current process using JNA
/* Requires JNA
* Get jna.jar here: http://java.net/projects/jna/sources/svn/show/trunk/jnalib/dist
*/
import com.sun.jna.Library;
import com.sun.jna.Native;
public class SelfKiller
{
private interface CLibrary extends Library
{