Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / SelfVerify.java
Created October 29, 2013 20:42
Self-verification using base64 encoded X509 cert
package no.posten.dpost.sosm;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.security.AccessController;
import java.security.CodeSigner;
import java.security.CodeSource;
import java.security.PrivilegedAction;
@eoftedal
eoftedal / DI-Dog
Created October 16, 2013 20:10
DI-løs, men likevel testbar kode
public class Dog {
private Tail tail;
private Head head;
public Dog() {
this(new TailImpl(), new HeadImpl())
}
public Dog(Tail tail, Head head) {
this.tail = tail;
this.head = head;
@eoftedal
eoftedal / step1
Last active December 24, 2015 06:59
var oldCreateElement = document.createElement;
document.createElement = function() {
var element = oldCreateElement.apply(document, arguments);
var oldSetAttribute = element.setAttribute;
console.log(arguments, element);
element.setAttribute = function(name, value) {
if (name == "onsubmit") {
console.log(arguments.callee.caller.toString());
}
oldSetAttribute.apply(element, arguments);
@eoftedal
eoftedal / regex.rb
Created May 23, 2012 12:16
Based on @homakov's work
a = "javascript:evil();\nhttp://www.vg.no"
if a =~ /^https?/ then
puts "This is a safe url starting with http or https"
end
@eoftedal
eoftedal / gist:2046582
Created March 15, 2012 20:11 — forked from thomaseggum/gist:2044229
attempt
var mynamespace = mynamespace || {};
(function(){
var counter = { count: 0 };
function incrementCounter(){
counter.count++;
}
mynamespace.someobject = {
counter : counter,
@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
@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 / gist:1178142
Created August 29, 2011 10:21
Simple HTML/Javascript XSS
<html>
<script>
var a = "</script><script>alert(1)</script>";
</script>
</html>