Skip to content

Instantly share code, notes, and snippets.

View Ignas's full-sized avatar

Ignas Mikalajūnas Ignas

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ignas on github.
  • I am ignasm (https://keybase.io/ignasm) on keybase.
  • I have a public key ASAOFY6BHCHrpp1R9vahmPOboxhLFhKYdlCXUvoLXOdk8Ao

To claim this, I am signing this object:

@Ignas
Ignas / gist:ad5ca55d6e7e3fb92e11
Last active December 12, 2015 13:20 — forked from anonymous/gist:5cf2b3f0b67661f19a09
What is happeining!
>>> type([1 for i in [1]][0]) is type([1.0 for a in [1]][0])
False
>>> type([1 for i in [1]][0]) is type([1.0 for i in [1]][0]) is int
True
>>> type([1.0 for i in [1]][0]) is type([1 for i in [1]][0]) is float
True
>>> [1 for i in [1]][0] is [1.0 for i in [1]][0]
Python 2.7.8 (default, Aug 24 2014, 21:26:19)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2
>>> urllib2.urlparse.urlsplit("postgresql+psycopg2://usr@/db_name?host=/var/run/postgresql&port=5432")
SplitResult(scheme='postgresql+psycopg2', netloc='use@', path='/db_name', query='host=/var/run/postgresql&port=5432', fragment='')
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
@Ignas
Ignas / Makefile
Created September 15, 2014 04:54
hash_path ?= $(shell md5 -q requirements.txt)
bin/django: var/assets/jquery/bower.json bin/buildout buildout.cfg versions.cfg setup.py .hashes/${hash_path}
find src -type f -iname '*.pyc' -exec rm {} +
bin/buildout
touch -c $@
.hashes/${hash_path}:
mkdir -p .hashes
def hacky_cache(fn):
def caching_runner():
cache_file = '{}.pickle'.format(fn.__name__)
if os.path.exists(cache_file):
with open(cache_file) as f:
return pickle.load(f)
else:
result = fn()
with open(cache_file, 'wb') as f:
pickle.dump(result, f)
indices = [candidate.index(/\b#{this_query_char}/),
candidate.index(this_query_char)]
scores = [1, indices[1] + 1]
indices.zip(scores).map { |index, score_delta|
if index
candidate_remainder = candidate[(index + 1)..-1]
score = score_substring(candidate_remainder, query_remainder)
if score
score + score_delta
@Ignas
Ignas / simple_form_lib.py
Created November 16, 2012 14:01
Simple formencode based form library for mako templates
import formencode
from formencode import htmlfill, variabledecode
from webhelpers.html.builder import literal
from zope.cachedescriptors.property import Lazy
class FormEncodeState(object):
@Ignas
Ignas / exc_log2.py
Created May 14, 2012 12:43
exc_log + Dozer request log handler
from __future__ import absolute_import
import logging
import sys
from dozer.logview import RequestHandler
from pyramid.tweens import EXCVIEW
from pyramid.settings import aslist
from pyramid.util import DottedNameResolver
from pyramid.httpexceptions import WSGIHTTPException
@Ignas
Ignas / postgresql.mk
Created January 25, 2012 13:52
Set up for a local postgresql database using a Makefile
export PGPORT ?= 4488
PG_PATH ?= $(shell if test -d /usr/lib/postgresql/9.1; then echo /usr/lib/postgresql/9.1; else echo /usr/lib/postgresql/8.4; fi)
PG_DIR = ${PWD}/instance/var
PG_DATA = ${PG_DIR}/data
PG_RUN = ${PG_DIR}/run
PG_LOG = ${PG_DIR}/log
PG_SOCKET = ${PG_RUN}/.s.PGSQL.${PGPORT}
PGPARAMS = -D ${PG_DATA} -o "-F -c unix_socket_directory=${PG_RUN} -c custom_variable_classes='busy' -c busy.active_user=0" -l ${PG_LOG}/pg.log