Skip to content

Instantly share code, notes, and snippets.

View kotnik's full-sized avatar

Nikola Kotur kotnik

View GitHub Profile
@kotnik
kotnik / gist:1183650
Created August 31, 2011 14:18 — forked from ngmaloney/gist:981766
my.drush.inc
<?php
/**
* @file My Drush Commands
*/
/**
* Implementation of hook_drush_help()
*/
function my_drush_help($section) {
switch ($section) {
@kotnik
kotnik / kotnik_rsa.pub
Created January 9, 2012 10:55
Kotnik public key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAv11JtNqeqxnonQelyHWzNiJMckYaZ8bgpBun8ZpFHs3+ZMEGmzxh2EkSUCfZ6guOMDlA9DrYchUTgzfwvkrQ05Bz+XHIO1c8a3aoNww1JZj7E6mYchOT7GnLS7Yq7Waj+sBvEDmbmh1s3I1jHC4Im/NJO+BwsMvmJskP/sG3WVM= kotnik@agnus
@kotnik
kotnik / pre-commit
Created February 1, 2012 14:23
Drupal pre-commit hook
#!/bin/bash
# Author: Remigijus Jarmalavičius <remigijus@jarmalavicius.lt>
# Author: Vytautas Povilaitis <php-checker@vytux.lt>
# Modifications: Nikola Kotur <kotnick@gmail.com>
ROOT_DIR="$(pwd)/"
LIST=$(git status | grep -e '\#.*\(modified\|added\)')
ERRORS_BUFFER=""
for file in $LIST
do
@kotnik
kotnik / gist:1986671
Created March 6, 2012 14:54 — forked from voxpelli/gist:1069596
OAuth Connector setup for OAuth Login provider
<?php
$provider = new stdClass;
$provider->disabled = FALSE; /* Edit this to true to make a default provider disabled initially */
$provider->name = 'sso1';
$provider->title = 'sso1';
$provider->url = 'http://sso1.loc/';
$provider->consumer_advanced = array(
'signature method' => 'HMAC-SHA512',
'request token endpoint' => '/oauth/request_token',
'authorization endpoint' => '/oauth/authorize',
@kotnik
kotnik / static.php
Created March 16, 2012 09:08
PHP Fail
<?php
class LeClass {
private static $_thing = array(
'path' => BASE_PATH . '/tmp',
);
}
@kotnik
kotnik / gist:3539733
Created August 30, 2012 20:12
Skrati naslov
<?php
// Skrati na ovoliko znakova:
$max_duzina = 10;
// ukoliko je title duzi od:
$max_limit = 20;
$label_id = $this->get_field_id('title');
$short_title = esc_attr($title);
if (strlen($short_title) >= $max_limit) {
$short_title = substr($short_title, 0, $max_duzina) . "...";
@kotnik
kotnik / gist:4001902
Created November 2, 2012 15:08
Redmine Yauib hook
#!/usr/bin/env python2
import re
import sys
import urllib
import urllib2
from urlparse import urlparse
from xml.dom import minidom, getDOMImplementation
class Redmine:
@kotnik
kotnik / gist:4320073
Created December 17, 2012 17:24
Drush entity info. Name as entity.drush.inc and put in ~/.drush/.
<?php
/**
* @file
* Drush support for entities.
*/
/**
* Define how a print out needs to be
*/
define('DRUSH_ENTITY_SEPARATED_SPACE', 'space-separated');
@kotnik
kotnik / gol.c
Created December 27, 2012 11:19
Game of Life in C.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define for_x for (int x = 0; x < w; x++)
#define for_y for (int y = 0; y < h; y++)
#define for_xy for_x for_y
void show(void *u, int w, int h)
{
int (*univ)[w] = u;
@kotnik
kotnik / sigint.c
Created March 9, 2013 10:24
SIGINT wrapper for lighttpd graceful restart feature under runit.
/* SIGINT.c */
/* Errors */
#define RC_TARGET 13
#define RC_SIGNAL_HANDLER 15
#define RC_EXEC 23
#define RC_BAD_OPTION 24
/* INC */
#include <stdio.h>