Skip to content

Instantly share code, notes, and snippets.

View h0rn3t's full-sized avatar
🏠
Working from home

Eugene h0rn3t

🏠
Working from home
  • Ukraine
View GitHub Profile
@h0rn3t
h0rn3t / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@h0rn3t
h0rn3t / javascript_resources.md
Last active August 29, 2015 14:06 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@h0rn3t
h0rn3t / python_resources.md
Last active August 29, 2015 14:06 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

$("#foo")[0].selectize.addOption({
//id: 35,// I use IDs instead
name: "Some User",
score: 1
});
$("#foo")[0].selectize.addItem( 'Some User' ); // If using IDs it should be 35 instead
@h0rn3t
h0rn3t / gist:c0e7bda9e390f44a2e4c
Created July 12, 2015 08:24
fluent decorator
from functools import wraps
from copy import deepcopy
def fluent(method):
"""Used to define fluent API class methods"""
@wraps(method)
def wrapped(self, *args, **kwargs):
dupe = deepcopy(self)
method(dupe, *args, **kwargs)
return dupe
@h0rn3t
h0rn3t / gist:269f50c622d4132ef267
Created September 9, 2015 07:06
mysql db wrapper
#!/usr/bin/env python
################################################################
# simpledb: a simple mysql db wrapper module with auto connect
#
# Author: Curu Wong
# Date: 2014-08-25
# License: GPL v3
##########################################################
import sys,time
import MySQLdb
@h0rn3t
h0rn3t / gist:d10bff33dc10ddb20e78
Created January 18, 2016 10:40
MONGODB & PYTHON
###Ubuntu Install
```
sudo apt-get install mongodb
pip install pymongo
```
Table - Collection
Column - Property
Row - Document
@h0rn3t
h0rn3t / gist:c51f41e210fbc753941b
Created February 12, 2016 13:38
gevent multicore WSGIServer
import sys
from gevent import server
from gevent.baseserver import _tcp_listener
from gevent import pywsgi
from gevent.monkey import patch_all; patch_all()
from multiprocessing import Process, current_process, cpu_count
def hello_world(env, start_response):
if env['PATH_INFO'] == '/':
start_response('200 OK', [('Content-Type', 'text/html')])
@h0rn3t
h0rn3t / gist:cb57364889874e2fac96
Created February 12, 2016 14:14
multiprocessing gevent
import sys
from gevent import server
from gevent.monkey import patch_all; patch_all()
from multiprocessing import Process, current_process, cpu_count
def note(format, *args):
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args))
def echo(socket, address):
#---------------------------------------------
# TINT2 CONFIG FILE
#---------------------------------------------
# For more information about tint2, see:
# http://code.google.com/p/tint2/wiki/Welcome
#
# For more config file examples, see:
# http://bunsenlabs.org/topic/3232/my-tint2-config/
# Background definitions