Skip to content

Instantly share code, notes, and snippets.

@vbo
vbo / manmem.go
Last active November 6, 2016 23:43
// A little experiment to see if manual memory management is possible in Go
package main
import "fmt"
import "unsafe"
import "os"
import "syscall"
var headerSize = unsafe.Sizeof(Header{})
type Header struct {
figure 1
═ ══
3321
═══
figure 2
════
3421
═ ══
//clang++ -I /usr/local/include/ -L /usr/local/lib/ -lboost_regex boost_re_test.cpp -o test && ./test
#include <iostream>
#include <string>
#include <boost/regex.hpp>
int main()
{
std::string input("AAAA-12222-BBBBB-44455");
boost::regex re("(\\w+)-(\\d+)-(\\w+)-(\\d+)");
boost::smatch results;
//clang++ -std=c++11 -stdlib=libc++ c11_regex_test.cpp -o test && ./test
#include <iostream>
#include <string>
#include <regex>
int main()
{
std::string str = "zzxayy--zb";
std::regex re("\\w{0,2}a(.*)?z");
std::smatch m;
//
// Clang build cmdline:
// $ clang++ ./set.cpp -Wall -Werror -Wfatal-errors -std=c++11 -stdlib=libc++ -o set.out
//
#include <iostream>
#include <unordered_set>
struct Point {
int x, y;
@vbo
vbo / find-path-alfred.py
Created July 23, 2013 08:59
Alfred script filter matching the full file path instead of just filename. See http://apple.stackexchange.com/questions/96701/sublime-text-like-fuzzy-filesystem-search-for-mac-os-x.
import os
import re
print """<?xml version="1.0"?>"""
print "<items>"
try:
query = r"{query}"
parts = query.rstrip("/").split("/")
filename = parts.pop()
@vbo
vbo / sa_test.py
Last active December 11, 2015 07:09
SQLAlchemy declarative partial mapping demo. Expected that non-mapped properties will remain intact.
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import sessionmaker
# Set this to True to log all actual sql to stdout
logging_enabled = False
engine = sqlalchemy.create_engine('sqlite:///:memory:', echo=logging_enabled)
Session = sessionmaker(bind=engine)
@vbo
vbo / index.html
Created April 15, 2012 19:48
learnpoetry.com =)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
(function ($) {
$.fn.shuffle = function () {
return this.each(function () {
var items = $(this).children();
@vbo
vbo / notifier.py
Created December 6, 2011 13:10
wrapper for realsync native notifier
#!/usr/bin/env python
import sys
import re
import os
import time
from subprocess import PIPE, Popen
from threading import Timer
from Queue import Queue, Empty
@vbo
vbo / screenshot.cpp
Created October 5, 2011 18:12
Native windows screen capture script
#include <windows.h>
#include <GdiPlus.h>
#pragma comment( lib, "gdiplus" )
using namespace Gdiplus;
void TakeScreenshot(const WCHAR*, const WCHAR*);
bool GetEncoderClsid(const WCHAR*, CLSID*);
int main() {