Skip to content

Instantly share code, notes, and snippets.

View hakunin's full-sized avatar

Michal Hantl hakunin

  • Ostrava, Czech Republic
  • 11:39 (UTC -12:00)
View GitHub Profile
# Tohles mi poslal
$r = $db->query($s);
while($res = $r->fetchObject()){
include($res->script_path);
}
$r = $db->query($s);
function tabber($path, $res) {
if(file_exists($path)) {
@hakunin
hakunin / test.mirah
Created May 10, 2011 15:06
macro in mirah
michal@michal-P5Q-PRO:~/Plocha$ cat test.mirah
class Test
def getParam(param:String):String
param
end
macro def [](key)
quote { getParam(`key`) }
end
@hakunin
hakunin / ArrayHelper.mirah
Created April 27, 2011 06:30
My helper classes
import java.util.*
import java.lang.reflect.*
import java.lang.reflect.Method
class ArrayHelper
def self.inspect(l:List)
unless l
"List(nil)"
else
@hakunin
hakunin / email.mirah
Created April 25, 2011 12:06
Simplest Mirah wrapper for AppEngine email API.
/*
Wrapper around AppEngine API that can send a simple email.
Email.from(customer.email, customer.name).
to('michal.hantl@gmail.com', 'Michal Hantl').
subject('UseDriven feedback').
body('Your message').
send
*/
/*
Featuring sexy import & export, VERY unclean code, first iteration
*/
import ext.*
import models.*
import java.util.regex.*
import java.util.ArrayList
import java.util.HashMap
import domain.*
@hakunin
hakunin / app.yaml
Created March 6, 2011 11:07
pretty prints exceptions
# Put this at the end of your app.yaml
# My class's package is ext, you might try putting above files into your models or somewhere
- url: /*
filter: ext.ShowExceptionFilter
# application controller should override this one
def private_exception(ex:Throwable):void
puts ShowException.plain(ex)
out = ShowException.new.pretty(request, ex)
#puts out
params.content = out
end
def public_exception(ex:Throwable):void
puts ShowException.plain(ex)
@hakunin
hakunin / aes_128_in_php_for_java.php
Created February 23, 2011 08:24
This class can encode AES128 that the Mirha/Java class in previous gist can encode.
<h1>Hello</h1>
<pre>
<?php
$measuring = new UseDrivenMeasuring();
echo $measuring->cipher('hello world!');
class UseDrivenMeasuring {
@hakunin
hakunin / aes_for_json.mirah
Created February 23, 2011 08:14
AES 128 in CBC mode in Mirah
/*
This class uses AES 128 in CBC mode, I've torned this from my own code so it not a drop-in solution at all,
but you can see the steps for working with AES in mirah.
It is used to encrypt JSON messages with trailing SHA1 before '{' to make it more secure
(if you add ranadom data like timestamp to your message,
it will generate different ciphered message every time).
*/
import com.google.appengine.ext.mirah.db.*
@hakunin
hakunin / entry_point.mirah
Created February 1, 2011 21:04
middleware.mirah
import javax.servlet.http.*
import javax.servlet.*
import java.lang.reflect.*
import java.util.*
import middleware.*
class EntryPoint < HttpServlet
def initialize