Skip to content

Instantly share code, notes, and snippets.

View gergelypolonkai's full-sized avatar

Gergely Polonkai gergelypolonkai

View GitHub Profile
#! /bin/bash
#
# A generalised converter to convert all files of
# a given extension in a directory to another
# type.
#
# I simply assume that yourConverter can detect
# the input files' type, and figure out the
# destination type from $ext_out
@gergelypolonkai
gergelypolonkai / Makefile
Created July 31, 2014 22:16
GdauiDataStore strangeness
all:
sqlite3 test.db "CREATE TABLE IF NOT EXISTS test (id integer not null primary key, name varchar(20) not null)"
sqlite3 test.db "DELETE FROM test"
sqlite3 test.db "INSERT INTO test VALUES (1, 'a')"
gcc -o test -Wall -g -O2 `pkg-config --cflags --libs gtk+-3.0 libgda-ui-5.0 libgda-sqlite-5.0` test.c
@gergelypolonkai
gergelypolonkai / git-branches-with-tracking.sh
Last active August 29, 2015 14:04
List git branches and their remote tracking branch, if any
#! /bin/sh
COLUMN=`which column 2> /dev/null`
if test -z $COLUMN
then
echo "\`column' is not found in PATH. Cannot continue."
exit 1
fi
current_branch=`git rev-parse --abbrev-ref HEAD`
@gergelypolonkai
gergelypolonkai / gergelypolonkai.modules
Created October 13, 2014 22:52
My JHBuild moduleset
<?xml version="1.0" standalone="no"?><!--*- mode: nxml -*-->
<?xml-stylesheet type="text/xsl" href="moduleset.xsl"?>
<moduleset>
<repository type="git" name="github.com"
href="git://github.com/"/>
<autotools id="gnome-break-timer">
<branch repo="github.com" module="GNOME/gnome-break-timer"/>
</autotools>
[alias]
bisect-fixed = bisect bad
bisect-unfixed = bisect good
@gergelypolonkai
gergelypolonkai / round-to-n-decimals.el
Created April 27, 2015 07:50
Round number to N decimals
(defun get-number-at-point ()
(interactive)
(skip-chars-backward "0123456789.-")
(or (looking-at "[0123456789.-]+")
(error "No number at point"))
(string-to-number (match-string 0)))
(defun round-number-at-point-to-decimals (decimal-count)
(interactive "NDecimal count: ")
(let ((mult (expt 10 decimal-count)))
@gergelypolonkai
gergelypolonkai / config.yml
Created April 27, 2015 07:55
Site specific session name with Symfony 2
session:
name: SiteSpecificSessionName
lifetime: 3600
@gergelypolonkai
gergelypolonkai / haversine.sql
Created April 27, 2015 07:59
MySQL Haversine function
DELIMITER $$
CREATE FUNCTION `haversine` (lng1 FLOAT, lat1 FLOAT, lng2 FLOAT, lat2 FLOAT)
RETURNS float NO SQL DETERMINISTIC
BEGIN
SET @a = ABS(POWER(SIN(RADIANS(lat1 - lat2)) / 2, 2) + COS(RADIANS(lat1)) * COS(RADIANS(lat2)) * POWER(SIN(RADIANS(lng1 - lng2)) / 2, 2));
RETURN 12756.200 * ATAN2(SQRT(@a), SQRT(1 - @a));
END$$
@gergelypolonkai
gergelypolonkai / DynarrayConfiguration.php
Created April 27, 2015 08:22
Symfony 2 configuration: array of dynamic associative arrays
<?php
$rootNode
->children()
->arrayNode('state_machine')
->requiresAtLeastOneElement()
->beforeNormalization()
->ifArray()
->then(function($values) {
$ret = array();
@gergelypolonkai
gergelypolonkai / redirect-non-existing.conf
Created April 27, 2015 08:28
Redirect only non-existing files with Apache
RewriteEngine on
RewriteRule ^/$ http://172.16.72.131:8080/ [QSA,L,P]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*) http://172.16.72.131:8080/$1 [QSA,L,P]
Order allow,deny
Allow from all