Skip to content

Instantly share code, notes, and snippets.

@eoftedal
eoftedal / perflog
Created December 9, 2014 19:48
Performance logging in Chrome
function perfLog(fun, context) {
var context = context || this;
var realFun = context[fun.name];
context[fun.name] = function() {
console.time(fun.name);
var result = realFun.apply(context, arguments);
console.timeEnd(fun.name);
return result;
}
}
@eoftedal
eoftedal / keybase.md
Created December 12, 2014 08:31
keybase

Keybase proof

I hereby claim:

  • I am eoftedal on github.
  • I am erlendoftedal (https://keybase.io/erlendoftedal) on keybase.
  • I have a public key whose fingerprint is 1971 4B8D 1365 B742 0C11 3537 E624 182F FB00 B0E6

To claim this, I am signing this object:

@eoftedal
eoftedal / Lottery.java
Last active August 29, 2015 14:19
Crazy stuff
import java.security.SecureRandom;
import java.math.BigInteger;
public class Lottery {
private static SecureRandom random = new SecureRandom();
public static void main(String[] args) {
String lotteryNumber = new BigInteger(130, random).toString(32);
/* Used when testing \u002a\u002f
lotteryNumber = "123";
import java.security.SecureRandom;
import java.math.BigInteger;
public class Lottery {
private static SecureRandom random = new SecureRandom();
public static void main(String[] args) {
/*
****************************************************************************************************************************************
@eoftedal
eoftedal / Puzzle.java
Created April 24, 2015 09:44
What is printed?
public class Puzzle {
public static void main(String[] args) {
String a = "1";
String b = "\u0022\u003b\u0061\u003d\u0022\u0032\u0022\u003b\u002f\u002f";
System.out.println(a);
}
}
@eoftedal
eoftedal / EncryptionPaddingProblem.cs
Created May 18, 2011 17:14 — forked from follesoe/EncryptionPaddingProblem.cs
Padding problem with AesManaged
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Linq;
namespace CryptoTest
{
class Program
{
var txt = "Dette vil slette elevtelling og all tilhørende elevdata. Ønsker du å fortsette?";
function regexSplit(re, txt) {
var reg = new RegExp(re);
var result = [];
var last;
var ar;
while(ar = reg.exec(txt)) {
result.push(ar[1]);
last = reg.lastIndex;
@eoftedal
eoftedal / gist:1178142
Created August 29, 2011 10:21
Simple HTML/Javascript XSS
<html>
<script>
var a = "</script><script>alert(1)</script>";
</script>
</html>
@eoftedal
eoftedal / Person.java
Created September 20, 2011 07:31
Simple java class with public final field instead of getter
public class Person {
public final String navn;
public Person(String navn) {
this.navn = navn;
}
}
@eoftedal
eoftedal / test.rb
Created February 3, 2012 08:22
Test tool needs to support Self-signed cert for non-prod environments. But the first request is horribly slow... (15 seconds) Does not happen in curl or wget
def preflight(uri)
#For some reason this speeds up connect on windows
require 'socket'
context = OpenSSL::SSL::SSLContext.new
tcp_client = TCPSocket.new uri.host, uri.port
ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client, context
ssl_client.connect
end