Skip to content

Instantly share code, notes, and snippets.

View kovagoz's full-sized avatar

Zoltan Kovago kovagoz

  • IBM Budapest Lab
  • Budapest
View GitHub Profile
@kovagoz
kovagoz / gist:6937508
Created October 11, 2013 16:09
logstash nginx access log backfill
input {
tcp {
type => "nginx"
port => 3333
}
}
filter {
grok {
type => "nginx"
@kovagoz
kovagoz / storage_image_extension
Last active December 29, 2015 21:49
Brainstorm
class File
__construct($filename)
$this->workingCopy = new WorkingCopy($filename)
hasWorkingCopy()
return $this->workingCopy && $this->workingCopy->exists()
getWorkingCopy()
if (!$this->hasWorkingCopy())
$this->workingCopy = new WorkingCopy(Storage::download($this->id))
return $this->workingCopy
alias codecept='() { vagrant ssh -c "cd /vagrant/www && vendor/bin/codecept $*" }'
alias composer='() { vagrant ssh -c "cd /vagrant/www && composer $*" }'
@kovagoz
kovagoz / doctrine-geo.php
Created January 9, 2014 22:57
Doctrine MongoDB geospatial query example
<?php
$city = DB::createQueryBuilder('Ni\City')
->field('coordinates')->geoNear(46.1643154116, 18.9664363861)
->spherical(true)
->distanceMultiplier(6378.137) // rad => km
->limit(1)
->getQuery()
->getSingleResult();
@kovagoz
kovagoz / doctrine-geojson.php
Created January 10, 2014 14:55
Doctrine geospatial query with GeoJson
<?php
use GeoJson\Geometry\Point;
$city = new City;
$city->name = 'Budapest';
$city->coordinates = new Coordinates(47.51, 19.03);
$city->save();
$city = DB::createQueryBuilder('City')
@kovagoz
kovagoz / post-checkout
Created August 25, 2014 09:14
Composer install on git checkout
#!/bin/bash
old_head="$1"
new_head="$2"
branch_switch="$3"
git_root=$(git rev-parse --show-toplevel)
git diff --name-only $new_head $old_head | grep composer.lock > /dev/null
@kovagoz
kovagoz / vim_tig
Created September 5, 2014 14:56
Call "tig status" from Vim
function! TigStatus()
silent !tig status
redraw!
endfunction
nnoremap <silent> gs :call TigStatus()<CR>
@kovagoz
kovagoz / c64
Created December 12, 2014 09:57
If the secondary address isn't specified or is specified as 0 (e.g. LOAD "FILE",8), the file is saved/loaded from the BASIC memory area (which, on the C64, starts by default at $0801). If the secondary address is specified as a non-zero value (e.g. LOAD "FILE",8,1), the program is loaded starting from the address specified by the file itself (the PRG header, which is the first two bytes of the file)—this form of command is more common when loading machine code programs.
@kovagoz
kovagoz / bug.php
Last active August 29, 2015 14:14
Image rotation bug
<?php
$img = imagecreatetruecolor(640, 480);
$rot = imagerotate($img, -90, 0);
var_dump(imagesy($rot));
@kovagoz
kovagoz / count_calendars.php
Created August 9, 2016 15:09
Count Google Calendars
<?php
require __DIR__ . '/vendor/autoload.php';
$credentials_path = __DIR__ . '/credentials.json';
putenv("GOOGLE_APPLICATION_CREDENTIALS=$credentials_path");
$client = new Google_Client;
$client->useApplicationDefaultCredentials();