Skip to content

Instantly share code, notes, and snippets.

View gergelypolonkai's full-sized avatar

Gergely Polonkai gergelypolonkai

View GitHub Profile
@gergelypolonkai
gergelypolonkai / WhatEver.php
Created April 27, 2015 08:40
Role and class based ACLs with Symfony 2
<?php
$this->get('security.context')->isGranted('ROLE_ADMIN');
@gergelypolonkai
gergelypolonkai / client-state.c
Created April 27, 2015 08:47
Registering a GLib ENumType
#include "wmudclientstate.h"
GType
wmud_client_state_get_type (void)
{
static volatile gsize g_define_type_id__volatile = 0;
if (g_once_init_enter(&g_define_type_id__volatile)) {
static const GEnumValue values[] = {
{ WMUD_CLIENT_STATE_FRESH, "WMUD_CLIENT_STATE_FRESH", "fresh" },
@gergelypolonkai
gergelypolonkai / Makefile
Created April 27, 2015 08:54
Registering a GLib EnumType using glib-mkenums and GNU Autotools
gswe_enum_headers = headers-that-contain-enums.h
gswe-enumtypes.h: $(gswe_enum_headers) gswe-enumtypes.h.template
$(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
gswe-enumtypes.h.tmp && mv gswe-enumtypes.h.tmp gswe-enumtypes.h
gswe-enumtypes.c: $(gswe_enum_headers) gswe-enumtypes.h gswe-enumtypes.c.template
$(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
gswe-enumtypes.c.tmp && mv gswe-enumtypes.c.tmp gswe-enumtypes.c
@gergelypolonkai
gergelypolonkai / border-radius.sass
Created April 27, 2015 20:19
Cross-browser border radius mixin in SASS with variable parameters
=border-width($t, $r: $t, $b: $t, $l: $r)
border-top-width: $t
border-right-width: $r
border-bottom-width: $b
border-left-width: $l
=border-top-right-radius($value)
border-top-right-radius: $value
-moz-border-top-right-radius: $value
-webkit-border-top-right-radius: $value
@gergelypolonkai
gergelypolonkai / helper.py
Last active August 29, 2015 14:22
@ParamConverter à la Django
# -*- coding: utf-8 -*-
import re
from django.shortcuts import get_object_or_404
from django.db import models
def convert_params(*params_to_convert, **options):
"""
Convert parameters to objects. Each parameter to this decorator
@gergelypolonkai
gergelypolonkai / output.log
Created December 2, 2012 14:23
db:schema:load error without minitest in Gemfile
$ RAILS_ENV=production bundle exec rake db:schema:load --trace
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Invoke rails_admin:disable_initializer (first_time)
** Execute rails_admin:disable_initializer
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
** Execute environment
rake aborted!
cannot load such file -- minitest/unit
/home/polesz/.gem/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
@gergelypolonkai
gergelypolonkai / backtrace.txt
Created December 13, 2012 10:28
debug_backtrace() for symfony/symfony #6203
array(8) {
[0] =>
array(5) {
'function' =>
string(11) "unserialize"
'class' =>
string(46) "Symfony\Component\Config\Resource\FileResource"
'object' =>
class Symfony\Component\Config\Resource\FileResource#558 (1) {
private $resource =>
@gergelypolonkai
gergelypolonkai / README.md
Last active November 10, 2015 08:18
Expandable Widget for Dashing.io

An expandable widget base type for Dashing.io

Usage

Add data-expsizex and data-expsizey to the widget <li> tag:

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1" data-expsizex="2" data-expsizey="2">
@gergelypolonkai
gergelypolonkai / README.md
Created November 30, 2015 14:15
gcov-blame

gcov-blame

A bash/zsh function to visualise coverage data for projects built with GNU libtool.

Usage

gcov-blame src/source-file.c

This will generate the appropriate .gcov file and display it in the terminal. The coverage data should be generated by whatever means first (e.g. make check).

@gergelypolonkai
gergelypolonkai / composer.json
Created February 21, 2013 16:11
Composer files for error reporting
{
"name": "brokernetgroup/intranet",
"description": "BROKERNETGroup Tanácsadói Portál",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",