Skip to content

Instantly share code, notes, and snippets.

View robinp's full-sized avatar

Robin Palotai robinp

  • Budapest, Hungary
View GitHub Profile
@robinp
robinp / Poller.cpp
Created January 7, 2011 16:08
jzmq-crash
/*
Copyright (c) 2007-2010 iMatix Corporation
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the Lesser GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
@robinp
robinp / Main.java
Created January 7, 2011 18:31
jzmq bug reproduce
package zmqbugtest;
import org.zeromq.ZMQ;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
@robinp
robinp / pom.xml
Created July 21, 2011 09:43
Sample pom.xml for Scala 2.8.1 maven project
<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.mygroup/groupId>
<artifactId>my-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>My wonderfull scala app</description>
<inceptionYear>2010</inceptionYear>
<licenses>
<license>
@robinp
robinp / bruteforcer.py
Created March 21, 2012 02:38
lost Android keystore password recovery utility
import subprocess as sp
import sys
# here you define general mutation rules
def upperCaseAllTs(x): return x.replace("t", "T")
def mySecretStrategy(x): return x.replace("34", "#$")
def cap(x): return x.capitalize()
# and put the mutator strategies here
strats = [upperCaseAllTs, mySecretStrategy, cap]
@robinp
robinp / IOTesting.scala
Created May 16, 2012 11:00
How to close safely using Scalaz IO
import java.io.{IOException, InputStream, OutputStream}
import org.mockito.Mockito
import scalaz._
import Scalaz._
import scalaz.effects._
trait Closable[A] {
def close(a: A): IO[Unit]
def closeOrKeep(a: A): IO[Option[A]] =
@robinp
robinp / Futureapplicative.scala
Created June 27, 2012 18:03
Akka Future Applicative typeclass for scalaz-seven
package akkaz
import akka.actor._
import akka.util.duration._
import akka.util.Timeout
import akka.dispatch.{ExecutionContext, Future}
object Futureapplicative extends App {
val system = ActorSystem("Futureapplicative")
@robinp
robinp / rc.local
Created July 10, 2012 19:34
Ubuntu 12.04 for Acer Aspire TimelineX 5820TG
# for SSD
echo deadline > /sys/block/sda/queue/scheduler
echo 0 > /proc/sys/vm/swappiness
# turn off Radeon by default so it doesn't consume battery
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
# turn off bluetooth by default
rfkill block bluetooth
@robinp
robinp / Bakery1.java
Created July 27, 2012 08:31
bakery model using template method
abstract class Bakery1 {
public void produceBread() {
Ingredients ingredients = prepareIngredients();
Bread bread = bakeTheBread(ingredients);
if (checkQuality(bread)) {
putBreadOnDisplay(bread);
}
}
@robinp
robinp / Bakery2.java
Created July 27, 2012 08:37
bakery model using injection
interface BakeBreadStrategy {
Bread bake(Ingredients ingredients);
}
class Bakery2 {
public Bakery2(BakeBreadStrategy bakeStrategy) {
// ...
}
@robinp
robinp / PostprocessingBakery1.java
Created July 27, 2012 08:50
complex bakery model using template methods
abstract class PosprocessingBakery1 {
public void produceBread() {
Ingredients ingredients = prepareIngredients();
Bread bread = bakeTheBread(ingredients);
if (checkQuality(bread)) {
putBreadOnDisplay(postprocess(bread));
}
}