Skip to content

Instantly share code, notes, and snippets.

@zrxq
zrxq / ZKCGHelpers.c
Created May 9, 2012 09:34
Left side rounded and right side rounded rectangles using Quartz 2D
//
// ZKCGHelpers.c
// Quartz 2D Helpers
//
// Created by Zoreslav Khimich on 5/9/12.
// Copyright (c) 2012 Zoreslav Khimich. All rights reserved.
//
#include "ZKCGHelpers.h"
@zrxq
zrxq / unshred.py
Created February 10, 2012 10:17
The Unshredder (Instagram Engineering Challenge)
#!/usr/bin/python
# This script unshreds a shredded image (visit http://bit.ly/sCMAD5 for details)
# author: Zoreslav Khimich <zoreslav.khimich@gmail.com>
from PIL import Image, ImageChops, ImageStat
from argparse import ArgumentParser
import sys, heapq
MAGIC_THRESHOLD = 11 # carefully handpicked to work with your reference input
@zrxq
zrxq / Python.sublime-build
Created November 15, 2011 09:52
Sublime Text python build system which respects environment variables set in ~/.profile (e.g. $PYTHONPATH)
{
"cmd": ["bash", "--login", "-c", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
@zrxq
zrxq / DetectFaces.cs
Created July 30, 2011 13:22
Face detection in C# using OpenCV with P/Invoke
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace OpenCVFaceDetector
{
class DllPaths
@zrxq
zrxq / uuid1.py
Created June 30, 2011 08:11
Sublime Text 2 plugin for inserting UUID 1 (host- and time-based)
import sublime, sublime_plugin
from uuid import uuid1
class generate_uuid1Command(sublime_plugin.TextCommand):
def insert_text(self, edit, what):
[self.view.replace(edit, reg, what) for reg in self.view.sel()]
def run(self, edit):
self.insert_text(edit, str(uuid1()))