Skip to content

Instantly share code, notes, and snippets.

View pfote's full-sized avatar

Andreas Pfotenhauer pfote

  • Ypsilon.NET AG
  • Frankfurt
View GitHub Profile
<?php
$list = array(
array('page_id' => '3',
'url' => '/johtamisjarjestelma/yritys',
'title' => 'Yritys'),
array(
'page_id' => '4',
'url' => '/johtamisjarjestelma/yritys/historia',
'title' => 'Historia'),
#!/usr/bin/env python
"""
statistics for netstat tcp
"""
from pprint import pformat
from optparse import OptionParser,OptionGroup
import re
import socket
import sys
@pfote
pfote / gist:3655665
Created September 6, 2012 12:18
postgres .. unique index on two fields
test=# create table j (id1 int, id2 int);
CREATE TABLE
test=*# create unique index idx_j on j(greatest(id1, id2), least(id1, id2));
CREATE INDEX
test=*# insert into j values (1,2);
INSERT 0 1
test=*# insert into j values (2,1);
ERROR:  duplicate key violates unique constraint "idx_j"
@pfote
pfote / bot.py
Created November 23, 2012 08:41
my old bot.py
#!/usr/bin/env python
##################################################
# little programming exercise using twisted irc
# ibot is a infobot which whole purpose is to
# autorespond to a defined set of keywords with
# a stored phrase
# $Id: bot.py,v 1.4 2003/12/14 13:38:29 pfote Exp $
##################################################
#!/usr/bin/env python
# whats mysql? MySQLdb?
from mysql.connector import errorcode, connect, Error
class JobQueue:
"""docstrings are missing"""
def __init__(self, dbConfig):
"""docstrings for methods as well"""
@pfote
pfote / gist:5057323
Created February 28, 2013 14:55
sample CI monolog log
[2013-02-28 15:53:39] codeigniter.DEBUG: Monolog replacement logger initialized
[2013-02-28 15:53:39] codeigniter.DEBUG: Config Class Initialized
[2013-02-28 15:53:39] codeigniter.DEBUG: Hooks Class Initialized
[2013-02-28 15:53:39] codeigniter.DEBUG: Utf8 Class Initialized
[2013-02-28 15:53:39] codeigniter.DEBUG: UTF-8 Support Enabled
[2013-02-28 15:53:39] codeigniter.DEBUG: URI Class Initialized
[2013-02-28 15:53:39] codeigniter.DEBUG: Router Class Initialized
[2013-02-28 15:53:39] codeigniter.DEBUG: No URI present. Default controller set.
[2013-02-28 15:53:39] codeigniter.DEBUG: Output Class Initialized
[2013-02-28 15:53:39] codeigniter.DEBUG: Security Class Initialized
@pfote
pfote / gist:5444238
Created April 23, 2013 14:55
sample deploy script
#!/bin/sh
# script zum lifestellen
cd /var/www/ypsilon_git
revision=$1
host=`hostname`
if [ x$revision == 'x' ]; then
revision='master'
fi
@pfote
pfote / gist:5452297
Created April 24, 2013 13:54
mod_php conf
<IfModule mod_php5.c>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
function is_write_type($sql)
{
if (( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql))
AND
( ! preg_match('/^\s*INSERT.*RETURNING\s+[\w\*,]+$/i', $sql))
)
{
return FALSE;
}
return TRUE;
@pfote
pfote / gist:4960286
Created February 15, 2013 13:11
sample selenium webdriver test
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
class FlwebBookingWebdriver(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)