Skip to content

Instantly share code, notes, and snippets.

@mebubo
mebubo / findclass.py
Created August 24, 2012 08:19
Find classes in jars
#!/usr/bin/env python
import sys, os
from zipfile import ZipFile
# Given a directory of jar files and a pattern, list all files that
# contain matching classes, and the matching classes
#
# Usage: findclass.py <dir> <pattern>
@mebubo
mebubo / reverse.sh
Created August 24, 2012 12:36
Reverse a string in bash
#!/bin/bash
# reverse a string
reverse () {
local REVERSED=""
ORIGINAL=$1
for i in $(seq 0 $(( ${#ORIGINAL} - 1 )) ); do
REVERSED=${ORIGINAL:${i}:1}$REVERSED
done
echo $REVERSED
@mebubo
mebubo / Decrypt.java
Created September 6, 2012 09:08
Decrypt proactive credentials
package credentials;
import java.security.KeyException;
import org.ow2.proactive.authentication.crypto.CredData;
import org.ow2.proactive.authentication.crypto.Credentials;
public class Decrypt {
static String CRED_PATH = "config/authentication/rm.cred";
static String KEY_PATH = "config/authentication/keys/priv.key";
@mebubo
mebubo / Deadlock.java
Created September 6, 2012 17:38
A really bad implementation of a deadlock
public class Deadlock {
private static final Object pause = new Object();
private static volatile boolean proceed;
private static class Waiting {
volatile boolean waiting;
}
private static class DeadlockingThread extends Thread {
@mebubo
mebubo / order_of_growth
Created September 8, 2012 12:22
Estimate order of growth
What is the order of growth of the worst case running time of the following code fragment as a function of N?
int sum = 0;
for (int i = 1; i <= N*N; i = i*2)
for (int j = 0; j < i; j++)
sum++;
The body of the innermost loop executes 1 + 2 + 4 + 8 + ... + N^2 ~ 2 N^2 times.
@mebubo
mebubo / telephonie_tarifs
Created September 12, 2012 04:07
telephonie_tarifs
Russie:
| | fixe | mobile |
|-------------+-------------------------------------+---------------|
| freebox | 0 € | 0.22 € |
| free mobile | 0.08 € | 0.22 € |
| skype | spb, msk: 0.02 € rest: 0.043 € | 0.07 € |
| callwithus | spb: 0.01 lenobl: 0.02 msk: 0.015 $ | 0.04 - 0.05 $ |
@mebubo
mebubo / pretty_print_json.php
Created September 14, 2012 13:52
Pretty-print json
<?php
$r = json_decode(file_get_contents($argv[1]));
print_r($r);
@mebubo
mebubo / nook.css
Created February 18, 2013 19:05
Extra css for Nook
@font-face {
font-family: "DroidFont", serif, sans-serif;
font-weight: normal;
font-style: normal;
src: url(res:///system/fonts/DroidSerif-Regular.ttf);
}
@font-face {
font-family: "DroidFont", serif, sans-serif;
font-weight: bold;
font-style: normal;
@mebubo
mebubo / jvm.txt
Created February 20, 2013 15:10
Hotspot options
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8765
jmap -dump:format=b,file=<path> <pid>
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<path>
bash ./bin/unix/jetty-launcher -A dist/war/rest.war -R dist/war/rm.war -r pamr://0 -S dist/war/scheduler.war -s pamr://1 -p 8899 -Dproactive.pamr.router.address=britany.activeeon.com -Dproactive.communication.protocol=pamr
curl -v -k --data 'username=demo&password=demo' -H 'Accept: */*' http://localhost:8899/rest/rest/scheduler/login
curl -H 'Accept: */*' -H 'sessionid: 6c33dbce13cf8aff8e17c05498e0e4741b143466c33dbce13cf8aff8e18000' http://localhost:8899/rest/rest/scheduler/jobs/2/livelog | python -m json.tool