Skip to content

Instantly share code, notes, and snippets.

View lavie's full-sized avatar

assaf lavie

View GitHub Profile
@lavie
lavie / snagurl.py
Created February 14, 2012 18:19
Upload image to imgurl and copy remote URL into clipboard
import sys
import urllib2
from json import loads
from urllib import urlencode
import base64
print sys.argv
LOG_FILE = 'uploads.log'
DEV_KEY = 'YOUR KEY HERE' # from http://imgur.com/register/api_anon
@lavie
lavie / KeyCodeNames.as
Created August 6, 2012 09:29
A mapping from key-code to key-names in ActionScript 3
package com.gigantt.utils
{
public class KeyCodeNames
{
protected var m : Array = new Array(256);
// This map is based on http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001136.html
public function KeyCodeNames()
{
@lavie
lavie / gist:6111229
Created July 30, 2013 08:24
Possibly the strangest email I ever got from a start-up...
Hello,
This is a message from theoldreader whom you have flattred.
Hi!
As you could have read in our blog - http://blog.theoldreader.com/ - if nobody takes over The Old Reader in two weeks, we will be closing the website for general public. Obviously, we will still run a much, much smaller site for ourselves and our friends, and we will be migrating accounts of all users who helped us keep the project running.
Unfortunately there is no way we can identify The Old Reader accounts based on Flattr usernames. Therefore, if you would like to get transferred to the private The Old Reader, we kindly ask you to submit your account information using this form: [link]
We are very excited about this change. During past several months we proved that two friends with full-time jobs can reasonably well run a popular website for hundreds of thousands of users. However, "reasonably well" is not how we want to do things. We would rather have an awesome reader for several thousands of our friends.
@lavie
lavie / build.bat
Last active December 23, 2015 21:39
Building Sikuli Script on Windows
call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"
set JAVA_HOME=c:\java\Java\jdk1.7.0_40
cmake -G "NMake Makefiles" -D JAVA_BIN_PATH=c:\java\Java\jdk1.7.0_40\bin -D CMAKE_BUILD_TYPE=Release -D OpenCV_DIR=c:\dev\opencv21 -D SWIG_DIR=c:\Users\assaf\Dropbox\Dev\kbcult\swig -D TESSERACT_SRC_DIR=c:\Users\assaf\Dropbox\Dev\kbcult\tesseract-2.04 -D OPENCV_INCLUDE_DIR=c:\dev\opencv21\include\opencv -D SWIG_EXECUTABLE=c:\Users\assaf\Dropbox\Dev\kbcult\swig\swig.exe -D TESSERACT_DATA_DIR=c:\Users\assaf\Dropbox\Dev\kbcult\tesseract-2.04\tessdata c:\Users\assaf\Dropbox\Dev\kbcult\sikuli\sikuli-script
@lavie
lavie / IBackgroundWorker.as
Created November 22, 2013 06:42
Idle Worker ("background" processing) in Flex. This code is not self contained and relies on some internal libraries, but those aren't important for the understanding of this pattern, which is the aim of this gist.
package com.gigantt.utils
{
import flash.events.Event;
public interface IBackgroundWorker
{
// Do stuff before running - Optional
function prepare() : void;
// Post processing work - Optional. Returns event to be raised by CPU.
@lavie
lavie / launch.bat
Last active December 29, 2015 19:09
Launches cgminer only if it's not already running.
set GPU_USE_SYNC_OBJECTS=1
set GPU_MAX_ALLOC_PERCENT=100
cd "c:\Program Files (x86)\ltc\gui\cgminer"
tasklist | grep cgminer
echo %ERRORLEVEL%
IF ERRORLEVEL 1 call cgminer
@lavie
lavie / snagurl.py
Last active August 29, 2015 14:02
SnagURL uploads any file to S3 or imgur and puts a HTTP link to it in the clipboard
"""
Dependecies:
1. Install BOTO ("pip install boto")
2. Set the values for S3_BUCKET, BUCKET_WEB_PREFIX
3. Set the Amazon IAM access keys
"""
import sys
import subprocess
@lavie
lavie / ec2hosts.py
Created June 15, 2014 18:05
List all EC2 instances in a region and their public IPs (handy for populating hosts file)
from boto.ec2 import *
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("access_key", help = "AWS Access Key")
parser.add_argument("secret_key", help = "AWS Secret Key")
parser.add_argument("--region", help = "AWS Region", default = "us-east-1")
parser.add_argument("--all", help = "show not just running instances", action = "store_true")
args = parser.parse_args()
@lavie
lavie / settings.py
Created September 9, 2014 08:17
Django Settings Dev vs. Production Pattern
# This file contains PRODUCTION setting values. If you want to run this locally, or on a different environment than production, edit the settings_local.py file, instead.
# Mongo related settings
MONGO_RS = ["mongo1", "mongo2", "mongo3"]
DB_USER = "myuser"
DB_PASSWORD = "mypawd"
DB_TIMEOUT_MS = 3000
REPLICA_SET = "replica"
# General application settings
#!/bin/bash
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim