Skip to content

Instantly share code, notes, and snippets.

View kotnik's full-sized avatar

Nikola Kotur kotnik

View GitHub Profile
@kotnik
kotnik / pre-commit.sh
Last active December 15, 2015 19:28 — forked from mxgrn/gist:663933
Trailing whitespace removal git commit hook.
#!/bin/sh
#
# This will abort "git commit" and remove the trailing whitespaces from the files to be committed.
# Simply repeating the last "git commit" command will do the commit then.
#
# Put this into .git/hooks/pre-commit, and chmod +x it.
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
@kotnik
kotnik / mountmon.py
Created April 4, 2013 14:48
Monitors changes in mounts (/proc/mounts file).
import re
import logging
from collections import OrderedDict
import gevent
log = logging.getLogger(__name__)
logging.basicConfig(
format="%(asctime)s %(name)s %(levelname)s %(message)s",
level=logging.INFO
@kotnik
kotnik / pr.md
Created March 25, 2013 12:59 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

class SkipList:
"""Doubly linked non-indexable skip list, providing logarithmic insertion
and deletion. Keys are any orderable Python object.
`maxsize`:
Maximum number of items expected to exist in the list. Performance
will degrade when this number is surpassed.
"""
def __init__(self, maxsize=65535):
self.max_level = int(math.log(maxsize, 2))
diff --git a/commands/core/site_install.drush.inc b/commands/core/site_install.drush.inc
index 4e607ac..d0620b8 100644
--- a/commands/core/site_install.drush.inc
+++ b/commands/core/site_install.drush.inc
@@ -36,10 +36,10 @@ function drush_core_pre_site_install($profile = NULL) {
$msg[] = dt('create a @settingsfile file', array('@settingsfile' => $settingsfile));
}
if (drush_sql_db_exists($db_spec)) {
- $msg[] = dt("DROP all tables in your '@db' database.", array('@db' => $db_spec['database']));
+ //$msg[] = dt("DROP all tables in your '@db' database.", array('@db' => $db_spec['database']));
@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>
@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 / 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 / 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: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) . "...";