Skip to content

Instantly share code, notes, and snippets.

View kotnik's full-sized avatar

Nikola Kotur kotnik

View GitHub Profile
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']));
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))
@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:

@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 / 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 / pastebin.sh
Created April 8, 2013 14:49
Self-hosted pastebin. Pipe code/text to be automatically uploaded to your server for sharing.
#!/bin/bash
USER=YOUR_USERNAME
HOST=YOUR_SERVER_HOSTNAME
WEBPATH=PATH_TO_WEBSERVER_ROOT
WEBURL=YOUR_URL
BACKUP_DIR=DIR_FOR_BACKUP
file=$(mktemp $BACKUP_DIR/XXXXXX)
mv $file $file.html
@kotnik
kotnik / git-commit.py
Last active December 16, 2015 02:39
Parse git commit in Python.
def parse_commit(commit):
r = {}
info, diffstat = commit.split("ENDOFOUTPUTGITMESSAGEHERE")
info = info.strip()
lines = info.split('\n')
r["sha1"] = lines[0]
r["parent"] = lines[1]
r["author"] = lines[2]
r["commiter"] = lines[3]
r["timestamp"] = lines[4]
@kotnik
kotnik / json-me.py
Last active December 16, 2015 07:09
Flask app that always return the same JSON, regardless of the path.
import json
from flask import Flask, Response
app = Flask(__name__)
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
ret = {
"something": 1,
@kotnik
kotnik / small-dns-server.py
Created June 6, 2013 14:51
Example of how to create a DNS server in Python, based on Twisted libraries.
from collections import Mapping
from twisted.names import dns, server, client, cache
from twisted.application import service, internet
class MapResolver(client.Resolver):
def __init__(self, mapping, servers):
client.Resolver.__init__(self, servers=servers)
@kotnik
kotnik / transitive.php
Created July 3, 2013 08:47
Beware of ==
<?php
// == is not transitive
if (0 == FALSE) {
echo "0 == FALSE\n";
}
if ("string" == TRUE) {
echo "'string' is TRUE\n";