Skip to content

Instantly share code, notes, and snippets.

@matovitch
matovitch / getpwd.py
Created December 17, 2012 18:38
Allow to get password in sublime text input panel. (ugly hack) First gist...first python day...How I lived before ?
import sublime, sublime_plugin
import subprocess
pwd = ""
class MePasswordCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.show_input_panel("password", "", self.on_input, self.getpwd, None)
def getpwd(self, password):
@matovitch
matovitch / Makefile
Last active December 18, 2015 00:59 — forked from wolfiestyle/Makefile
# basic makefile for D language - made by darkstalker slightly modified by matovitch
DCC=dmd
DFLAGS= -w
LIBS=
SRC= $(wildcard *.d)
OBJ= $(SRC:.d=.o)
INT= $(SRC:.d=.di)
DOC= $(SRC:.d=.html)
OUT= $(shell basename `pwd`)
@matovitch
matovitch / mylsh.h
Last active December 21, 2015 14:49
Home made locality sensitive hashing
#ifndef MYLSH_H
#define MYLSH_H
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
static const uint8_t uint_shuf[256] = {0x7f,0x87,0x95,0x7e,0xf1,0x0c,0x2c,0xc5,
0x8f,0xba,0xf3,0xcd,0x09,0xa2,0x5b,0x8e,
0xd7,0xf0,0x39,0x85,0x3c,0xe7,0xd4,0x7a,
@matovitch
matovitch / mylsh_test.c
Last active December 21, 2015 14:49
Home made locality sensitive hashing : test.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mylsh.h"
int main(int argc, char** argv) {
if (argc != 3)
return EXIT_FAILURE;
#include <queue>
#include <cstdlib>
#include <iostream>
static const int n_log2 = 3; //length of the array log2
static const int n = 1 << n_log2; //length of the array
static const int ker = 3; //length of the kernel
int abs(int x)
{
#ifndef __KMEANS_H__
#define __KMEANS_H__
#include <ctime>
#include <vector>
#include <limits>
#include <cstddef>
namespace kmeans
{
#include <ctime>
#include <cstddef>
#include <algorithm>
#include <iostream>
#include "kmeans.hpp"
static const std::size_t nPoints = 50000;
static const std::size_t nClusters = 100;
struct Point
#ifndef __VISITOR_HPP__
#define __VISITOR_HPP__
template<typename... Types>
struct Visitor;
template<typename... Visitors>
struct Visitable;
template<typename T>
#include "visitor.hpp"
#include <iostream>
class OtherTypeAsteroid;
class ExplodingAsteroid;
class ApolloSpacecraft;
class OthersSpacecraft;
class SpaceShip {};
class Asteroid : public Visitor<ApolloSpacecraft, OthersSpacecraft>{};
mode ASSEMBLER
{
"iadd" => TKN_IADD;
"isub" => TKN_ISUB;
"imul" => TKN_IMUL;
"idiv" => TKN_IDIV;
"imod" => TKN_IMOD;
"ineg" => TKN_INEG;