Skip to content

Instantly share code, notes, and snippets.

View ZwodahS's full-sized avatar

Eric ZwodahS

View GitHub Profile
@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 / 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 / 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
"""
data_matrix.py
Author: Eric
github: ZwodahS
data_matrix is a simple modules that helps you count on a N-dimension matrix.
terminology:
@ZwodahS
ZwodahS / dict_utils.py
Last active August 29, 2015 14:11
filters dictionary in python.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Author : Eric (github.com/ZwodahS)
# License : Public Domain