Skip to content

Instantly share code, notes, and snippets.

View ORBAT's full-sized avatar

Tom Eklöf ORBAT

  • Helsinki, Finland
View GitHub Profile
@ORBAT
ORBAT / wat.scala
Last active December 20, 2015 02:08
I have no idea.
def produceFibList(count: Int, minLen: Int = 16, padding: Char = 'X') = {
import math.BigInt
// lazy so that this'll work in the REPL or a worksheet, too
lazy val fib: Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: fib.zip(fib.tail).map(tup => tup._1 + tup._2)
def bigIntToStr(b: BigInt): String = {
def pad(s: String): String = {
val paddingLen = minLen - s.length
if(paddingLen > 0)
(padding.toString) * paddingLen + s
@ORBAT
ORBAT / gist:6221181
Last active December 21, 2015 00:38
AS3 XML example
var teksti: String = "hurr durr";
var attribuutti: String = "id";
var arvo: int = 5;
var xml: XML = <derp {attribuutti}={arvo}>{teksti}</derp>
// --> <derp id="5">hurr durr</derp>
class Derp {
private var _lol:Boolean = false;
public function lolWut():Boolean {
return _lol;
}
public function Derp(lol: Boolean) {
_lol = lol;
}
@ORBAT
ORBAT / ClippedSprite.as
Last active December 22, 2015 00:39 — forked from PrimaryFeather/ClippedSprite.as
Starling ClippedSprite but with local coordinates for the clipRect;
package starling.extensions
{
import flash.display3D.Context3D;
import flash.geom.Point;
import flash.geom.Rectangle;
import starling.core.RenderSupport;
import starling.core.Starling;
import starling.display.DisplayObject;
#!/bin/bash
unload() {
kextstat | grep "org.virtualbox.kext.VBoxUSB" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxUSB
kextstat | grep "org.virtualbox.kext.VBoxNetFlt" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetFlt
kextstat | grep "org.virtualbox.kext.VBoxNetAdp" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetAdp
kextstat | grep "org.virtualbox.kext.VBoxDrv" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxDrv
}
load() {

A standardized formulation of the UserID and session token would fix that.

We could actually just use the existing HTTP Auth protocol and provide end to end security.

This uses a challenge and response between server and client -- It's used on password protected pages and calls up that browser popup. I'll link to a protected page of my own so you can see it.

This has the benefit of coming up OUTSIDE the browser page, so that it's potentially far less spoofable when paired with a "remember account" system as in all major browsers. A spoofed page wouldn't be remembered and wouldn't auto populate. Hint: if you are typing in a login on a browser page, it's too late. You need to put in your password BEFORE the page ever comes up if security is requested.

The client and server could exchange nonce values, perform the HMAC( password, nonce1+nonce2 ) = A1; or similar to create the A1 proof of knowledge. Now, instead of using A1 i

@ORBAT
ORBAT / functional_test_promise.go
Last active August 29, 2015 14:09
Multipartition topic produce test
func TestFuncMultiPartitionProduce(t *testing.T) {
checkKafkaAvailability(t)
Logger = log.New(os.Stderr, "[Sarama] ", log.Lmicroseconds|log.Lshortfile)
client, err := NewClient("functional_test", []string{kafkaAddr}, nil)
if err != nil {
t.Fatal(err)
}
defer safeClose(t, client)
config := newProdConf()
@ORBAT
ORBAT / rsanalysis.sql
Created June 12, 2015 14:20
Redshift table analysis
DROP TABLE IF EXISTS temp_staging_tables_1;
DROP TABLE IF EXISTS temp_staging_tables_2;
DROP TABLE IF EXISTS temp_tables_report;
CREATE TEMP TABLE temp_staging_tables_1
(schemaname TEXT,
tablename TEXT,
tableid BIGINT,
size_in_megabytes BIGINT);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ORBAT
ORBAT / http-kafka.go
Last active September 22, 2015 20:32
HTTP -> Kafka server
package main
import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"