Skip to content

Instantly share code, notes, and snippets.

View t0ster's full-sized avatar
🏠
Working from home 🇺🇦

Roman Dolgiy t0ster

🏠
Working from home 🇺🇦
View GitHub Profile
https://docs.google.com/spreadsheets/d/1POnoeD6A0_Z8IBonxp5g_gkzU7QWA3ypQX6KT8uNbRI/edit
from pprint import pprint
import pymongo
client = pymongo.MongoClient()
db = client.test_database
if not db.users.count():
db.users.insert({
def user_validator(obj):
return True
class BaseHandler(object):
validator = None
def post(self, data):
if self.validator(data):
return 'ok'
else:
function load_and_get(content, id) {
var obj = content.get(id);
if (!obj) {
content.load(id);
obj = content.get(id);
}
return obj;
}
function load_track_from_album(album, options) {
try:
import gitinfo as GIT_INFO
GIT_INFO_BRANCH = GIT_INFO.BRANCH
GIT_INFO_REV = GIT_INFO.REV
except ImportError:
GIT_INFO = object()
GIT_INFO_BRANCH = '-1'
GIT_INFO_REV = '-1'
@t0ster
t0ster / tester.py
Created April 9, 2012 20:09
Sublime Create Test File Plugin
import os
import sublime_plugin
#==============================================================================
# Helpers
#==============================================================================
def get_tests_path(filename):
"""
from django import forms
from django.shortcuts import redirect
from django.views.generic import TemplateView
class MyForm(forms.Form):
datafield = forms.CharField(max_length=255)
class MyView(TemplateView):
import sys
import argparse
import Image
import ImageFilter
from numpy import exp, mgrid
def resize(args):
image = Image.open(args.image)
@t0ster
t0ster / gist:792488
Created January 23, 2011 22:02
Python like import in coffee-script
Ti.API.debug "In tango.init"
IMPORTED = []
# Setting sys.path
sys = {}
sys.path = ['site-packages', '.']
class ImportError extends Error
constructor: (@message, @fileName, @lineNumber) ->
class ResultAttr:
attr_names = set((
'_ResultAttr__value', '_ResultAttr__result', 'name'))
def __init__(self, name, value, result):
"""
Proxy class for `Result` attributes
Arguments:
- `name`: attribute name, for example 'user'