Skip to content

Instantly share code, notes, and snippets.

View okal's full-sized avatar

Okal okal

View GitHub Profile
@okal
okal / MyContract.sol
Created June 23, 2022 18:04
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
pragma solidity ^0.5.11;
contract MyContract {
string public myString = "Hello World";
}
@okal
okal / dynamo-series.md
Last active June 4, 2020 15:46
Amazon Dynamo Paper Study Series
@okal
okal / thamani-part-1.md
Last active June 8, 2020 21:43
Storage

Introduction

I'm currently reading the Amazon Dynamo paper. As an aid to internalising and retaining the concepts, I will attempt to implement them in a piecemeal fashion. The first of these will be a very simple key-value store that I've named Thamani, the Swahili word for "value". It implements a simple API over TCP, consisting of two methods

  1. put(key: byte array, value: byte array) -> timestamp: 64 bit unix timestamp
  2. get(key: byte array) -> value: byte array, timestamp: 64 bit unix timestamp
@okal
okal / handlers.py
Last active February 12, 2018 21:33
Static Analysis Adventures in Python
class Welcome(Handler):
def handle(self, request):
if request.user.is_logged_in:
return request.redirect('Feed')
else:
return request.redirect('SignIn')
class SignIn(Handler):
/* Do stuff here */
next_handler = 'Feed'
@okal
okal / vega-schema.json
Created January 18, 2016 12:53
Vega Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Vega Visualization Specification Language",
"defs": {
"axis": {
"type": "object",
"properties": {
"type": {
"enum": [
"x",
@okal
okal / externs_for_cljs.clj
Last active August 29, 2015 14:26 — forked from Chouser/externs_for_cljs.clj
Generate an externs.js file for arbitrary JS libraries for use in advanced Google Closure compilation, based on the ClojureScript code that uses the libraries.
(ns n01se.externs-for-cljs
(:require [clojure.java.io :as io]
[cljs.compiler :as comp]
[cljs.analyzer :as ana]))
(defn read-file [file]
(let [eof (Object.)]
(with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))]
(vec (take-while #(not= % eof)
(repeatedly #(read stream false eof)))))))
#!/bin/bash
## You should really be using ZSH, but who am I to judge? :-)
quicklispDir="~/libs/clisp/quicklisp" # Replace this with a directory of your choice
mkdir $quicklispDir -p && cd $quicklispDir
wget http://beta.quicklisp.org/quicklisp.lisp
sbcl --load quicklisp.lisp
import re
from hashlib import md5
def gfm(text):
# Extract pre blocks.
extractions = {}
def pre_extraction_callback(matchobj):
digest = md5(matchobj.group(0)).hexdigest()
extractions[digest] = matchobj.group(0)
return "{gfm-extraction-%s}" % digest
@okal
okal / pictures.markdown
Created August 29, 2012 14:22 — forked from sent-hil/pictures.markdown
River (getriver.com): Keep a programming journal.

One of my favorite past times is to look at the notebooks of famous scientists. Da Vinci's notebook is well known, but there plenty others. Worshipping Da Vinci like no other, I bought a Think/Create/Record journal, used it mostly to keep jot down random thoughts and take notes. This was great in the beginning, but the conformity of lines drove me nuts. Only moleskines made blank notebooks, so I had to buy one.

At the same time I started a freelance project. The project itself is irrelevant, but suffice to say it was very complex and spanned several months. It seemed like a perfect opportunity to use the moleskine. Looking back, all my entries fell under few categories:

  • Todo
  • Question
  • Thought
  • Bug
  • Feature