Skip to content

Instantly share code, notes, and snippets.

@huljas
huljas / flatbuffers_test.go
Created January 24, 2016 17:45
Go flatbuffers test
package flatbuffers
import (
"github.com/ReforgedStudios/legion-gameserver/flatbuffers/messages"
flatbuffers "github.com/google/flatbuffers/go"
"github.com/stretchr/testify/assert"
"testing"
//"log"
)
@huljas
huljas / msgpack_test.go
Created January 24, 2016 17:35
Msgpack Go example
package msgpack
import (
"github.com/ugorji/go/codec"
"log"
//"io"
"bytes"
"testing"
)
@huljas
huljas / README.md
Last active January 24, 2016 17:43
Calling C from Go #1

Calling C from Go

Put all files in ctest directory.

Run test

cd ctest
go test
import org.jose4j.jwk.HttpsJwks;
import org.jose4j.jwt.consumer.InvalidJwtException;
import org.jose4j.jwt.consumer.JwtConsumer;
import org.jose4j.jwt.consumer.JwtConsumerBuilder;
import org.jose4j.jwt.consumer.JwtContext;
import org.jose4j.keys.resolvers.HttpsJwksVerificationKeyResolver;
/**
* Simple authentication that can be used to validate google oauth tokens.
@huljas
huljas / Unzip.java
Created March 30, 2012 19:16
Little unzip utility
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@huljas
huljas / MonitoredSpringBeanAspect.java
Created January 12, 2012 14:19
Aspect for monitoring all @controller spring controllers
import com.jamonapi.Monitor;
import com.jamonapi.MonitorFactory;
import org.apache.commons.lang.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import java.util.regex.Pattern;
@huljas
huljas / Song.java
Created November 27, 2011 18:45
My language song
/**
* My languages song.
*
* Inspired by the Finland song from Monty Python.
*/
public class Song {
public static void main(String[] args) {
String s = "Java, Java, Java\n"
+ "The language I want to be\n"
+ "Debugging or Test Driving\n"
@huljas
huljas / find_slice_width.py
Created November 16, 2011 21:29
Unshredder challenge in python
# Find the slice width that correlates with high distances
def find_slice_width():
dm = sorted( [(x, slice_distance(x,x+1)) for x in range(0,width-1)], key=lambda d: d[1], reverse=True)
for w in range(2,width/2):
m = width / w - 1
p = len( filter(lambda dd: (dd[0]+1) % w == 0, dm[:m]) )
if p / float(m) > 0.6:
return w
return 10
@huljas
huljas / FacebookCookie.java
Created November 15, 2011 17:54
Facebook cookie authentication
package models;
import com.google.gson.Gson;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
@huljas
huljas / fork-me-sun.html
Created October 30, 2011 14:09
Fork Me in GitHub - Sun with canvas
<html>
<head>
<title>ForkMeSun</title>
<link href='http://fonts.googleapis.com/css?family=Dorsa' rel='stylesheet' type='text/css'>
</head>
<body>
<a href="http://huljas.github.com">
<canvas id="forkMe" width="150" height="150">
</canvas>