Skip to content

Instantly share code, notes, and snippets.

View ZwodahS's full-sized avatar

Eric ZwodahS

View GitHub Profile
@ZwodahS
ZwodahS / copy_redis_key.sh
Created March 1, 2016 06:07
copy a redis db key to another place (use MIGRATE COPY for v3.0<= redis)
#!/bin/bash
# source http://stackoverflow.com/questions/23222616/copy-all-keys-from-one-db-to-another-in-redis
#set connection data accordingly
source_host=localhost
source_port=6379
source_db=1
target_host=localhost
target_port=6379
target_db=2
@ZwodahS
ZwodahS / how_to_build_for_mac_haxe_heap.md
Last active July 6, 2022 07:37
How to build .app for Haxe/Heaps

How to build .app for Haxe/Heaps

Preparing your game

Normally you would load your resources from the same directory as your binary, but when building for Mac, you will have to do it slightly differently. Instead of loading your res from ., your should load it from ../Resources/.

Mac .app structure

Game.app
|_Contents
  |_Info.plist
@ZwodahS
ZwodahS / Curse cheatsheet
Created June 12, 2014 17:26
Curse cheatsheet (ncurses, pdcurses etc)
//// General stuffs ////
initscr(); // "start curses"
endwin() ; // "end curses"
//// Windowing ////
WINDOW* window = newwin(height, width, startY, startX)
//// Draw ///
refresh()
wrefresh(window)
@ZwodahS
ZwodahS / tornadoes_multiconn.py
Last active October 30, 2017 09:44
tornadoes wrapper for multiple connections
"""
This tornadoes wrappers wraps around ESConnection from tornadoes
This allow us to provide multiple host
"""
import tornado.gen
import tornadoes
import re
import random
@ZwodahS
ZwodahS / batch_cursor.py
Last active July 4, 2017 12:54
Batch cursor for motor
import tornado.gen
import motor
"""
Deals with cursor timeout in case it happens while looping.
Only use this if you ARE DAMN sure that the data don't change while you are iterating.
"""
class BatchCursor(object):
@ZwodahS
ZwodahS / dict_hasher.py
Created May 22, 2017 12:40
Hashing dictionary
import reprlib
import hashlib
import base64
# Idea taken from http://stackoverflow.com/questions/5884066/hashing-a-dictionary
class DictHasher(object):
def __init__(self):
self._repr_funcs = [
([int, str, float, bool], lambda data: data),
@ZwodahS
ZwodahS / options_parser.py
Last active February 16, 2017 09:28
A better options_parser for tornado
import os
import sys
import logging
from tornado.options import OptionParser, Error
def define_config_file_settings(parser, option_name="config_file"):
parser.define(option_name, type=str, help="config file to load",
callback=lambda path:parser.parse_config_file(path, fail_silently=True, final=False))
@ZwodahS
ZwodahS / quad_tree.py
Created June 14, 2016 14:29
Simple quad tree for searching points inside polygon
import json
from shapely.geometry.polygon import Polygon
from shapely.geometry import Point, box as Box
class _Quad(object):
def __init__(self, quad_tree, parent):
self.quad_tree = quad_tree
#!/bin/bash
# git + ls
C_RED=$(tput setaf 1)
C_GREEN=$(tput setaf 2)
C_YELLOW=$(tput setaf 3)
C_BLUE=$(tput setaf 4)
C_MAGENTA=$(tput setaf 5)
C_CYAN=$(tput setaf 6)
C_WHITE=$(tput setaf 7)
C_CLEAR=$(tput sgr0)
@ZwodahS
ZwodahS / gist:6638137
Created September 20, 2013 14:09
git branch display and coloring of path in terminal
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')