Skip to content

Instantly share code, notes, and snippets.

View ihabunek's full-sized avatar

Ivan Habunek ihabunek

View GitHub Profile
@ihabunek
ihabunek / gist:3504123
Created August 28, 2012 20:45
A quick checker for hashes
from os.path import join, splitext, basename
import os
import sys
import hashlib
def file_get_contents(path):
with open(path, 'rb') as file:
return file.read()
for root, dirs, files in os.walk('.'):
@ihabunek
ihabunek / table_dump.php
Created September 7, 2012 09:43
table_dump(): One of my favourite PHP debug functions.
<?php
/** Number of spaces to leave between columns. */
define('TABLE_DUMP_COLUMN_PADDING', 3);
/** Maximum number of chars in a column. Longer values will be trucnated. */
define('TABLE_DUMP_COLUMN_MAX_LENGTH', 50);
/**
* Takes an array of arrays, such as table data from a database and
@ihabunek
ihabunek / gist:3714740
Created September 13, 2012 14:42
Cross-compiling subsurface for Windows on Fedora 17
#
# Cross-compiling subsurface for windows, starting with a clean install
# of Fedora 17.
#
# Before starting create a user and add him to /etc/sudoers.
#
# Basic tools
sudo yum install vim git tar
@ihabunek
ihabunek / rolling.php
Created October 11, 2012 19:34
Testing rolling appender
<?php
include('../src/main/php/Logger.php');
Logger::configure(array(
'appenders' => array(
'default' => array(
'class' => 'LoggerAppenderRollingFile',
'layout' => array(
'class' => 'LoggerLayoutPattern',
@ihabunek
ihabunek / gist:3957832
Created October 26, 2012 09:27
Install Apache log4php using Composer

Install Apache log4php using Composer

First, install Composer if you don't yet have it:

php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"

Create a composer.json file with the following content:

{

For a person who prefers Flask so much, @gperetin sure does talk a lot about Django.

import urllib2
import re

url = "https://api.twitter.com/1/statuses/user_timeline.json?screen_name=gperetin&count=200"
data = urllib2.urlopen(url).read()

print len(re.findall('django', data, re.I))
<?php
require 'vendor/autoload.php';
Logger::configure(array(
'appenders' => array(
'default' => array(
'class' => 'LoggerAppenderFile',
'layout' => array(
'class' => 'LoggerLayoutSimple',
@ihabunek
ihabunek / gist:5964568
Created July 10, 2013 08:48
List of phormium limitations to be incorporated into the documentation
* table columns should be only lowercase, mixed case can be problematic for PDO
@ihabunek
ihabunek / reproduce.md
Last active September 2, 2016 05:46
How to crash Informix 11.70.UC7GE

Create the following stored procedure:

CREATE DBA PROCEDURE foo
(
    foo01 NVARCHAR(255),
    foo02 NCHAR(50),
    foo03 NCHAR(100),
    foo04 NCHAR(12),
    foo05 NCHAR(8),
@ihabunek
ihabunek / slowref.md
Last active November 12, 2018 22:54
PHP: Passing a large referenced array into a function is slow

PHP: Passing a large referenced array into a function is slow

This is interesting.

<?php 

define ('ITEMS', 1000);
define ('REPEAT', 10000);