Skip to content

Instantly share code, notes, and snippets.

View kissgyorgy's full-sized avatar

György Kiss kissgyorgy

View GitHub Profile
@zzzeek
zzzeek / gist:0cec9a5bbf0256f77faf
Created July 9, 2014 19:17
stupidly simple way to integrate setup.py test with pytest
# as opposed to setuptools-dependent http://pytest.org/latest/goodpractises.html#integration-with-setuptools-test-commands
# or non-OSS and incredibly verbose http://pytest.org/latest/goodpractises.html#integrating-with-distutils-python-setup-py-test
# just call this "mypackage.run_disutils" and then
# test_suite="mypackage.run_distutils"
import unittest
import pytest
class TestSuite(unittest.TestCase):
def test_sqlalchemy(self):
@SeanJA
SeanJA / is_prime.php
Created April 4, 2011 12:58
Overkill prime checker
<?php
function is_prime_overkill($int){
static $ints;
if(!$ints){
//quick skips
$ints = array(0=>false, 1=>false, 2=>true, 3=>true, 4=>false, 5=>true);
}
$index = strval($int);
if(!isset($ints[$index])){
$ints[$index] = true;
from django import template
from django.core.urlresolvers import reverse
def do_if_active_url(parser, token):
try:
tag_name, request, urls = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError, ("%r tag requires exactly two arguments, received" %
token.contents.split()[0], len(token.contents.split()[0]))
if not (urls[0] == urls[-1] and urls[0] in ('"', "'")):
@jackkinsella
jackkinsella / autoclose_janus
Created September 4, 2011 18:48
How to add autoclose to Janus
#~/.janus.rake file
vim_plugin_task "autoclose", "git://github.com/Townk/vim-autoclose.git"
#~/vimrc.local file
let g:AutoClosePairs = {'(': ')', '{': '}', '[': ']', '"': '"', "'": "'", '#{': '}', '|':'|' }
let g:AutoCloseProtectedRegions = ["Character"]
from django.http import HttpResponseRedirect
from django.conf import settings
from re import compile
EXEMPT_URLS = [compile(settings.LOGIN_URL.lstrip('/'))]
if hasattr(settings, 'LOGIN_EXEMPT_URLS'):
EXEMPT_URLS += [compile(expr) for expr in settings.LOGIN_EXEMPT_URLS]
class LoginRequiredMiddleware:
"""
@tuco86
tuco86 / Dockerfile
Last active May 30, 2019 21:05
Build packages as wheels, then install in small container.
FROM python:3.7-slim-stretch AS build
RUN \
apt-get -q update \
&& apt-get -q install -y --no-install-recommends \
build-essential \
libssl-dev \
&& rm -rf /var/lib/apt/lists/* \
&& pip install -U pip
@stevensacks
stevensacks / README.md
Last active November 23, 2019 01:47
FontAwesomeIcon without using 'as'

FontAwesomeIcon without using as

To avoid dealing with duplicate names from different icon styles (solid, regular, etc.), just use apply!

@zikani03
zikani03 / index.js
Created April 22, 2017 11:37
Rust + Node via Postgres notify/listen
var pg = require('pg');
var client = new pg.Client('postgresql://username:password@localhost:5432/labs');
client.connect();
client.query('LISTEN events', function(err, msg) {
if (err) throw err;
});
@HugoPresents
HugoPresents / set_cookiejar.go
Created December 29, 2014 08:37
golang set cookieJar example
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
)
@zzzeek
zzzeek / plain_asyncio.py
Last active November 13, 2021 00:01
An asyncio program that runs rows into a Postgresql database
"""A plain asyncio program that uses asyncpg to run some rows into a table and
select them.
This is a "control" program which we will compare to the one which uses calls
from an implicit IO greenlet at
https://gist.github.com/zzzeek/4e89ce6226826e7a8df13e1b573ad354.
Performance against a PG database over a wired network
Ran 40000 records in 40 concurrent requests, Total time 5.560306