Skip to content

Instantly share code, notes, and snippets.

View Kronuz's full-sized avatar

Germán Méndez Bravo Kronuz

View GitHub Profile
#include <iostream>
// c++ -std=c++14 -fsanitize=address -Wall -Wextra -g -o tst test_stash.cpp && ./tst
#include <array> // for array
#include <atomic> // for atomic
class StashException { };
class StashContinue : public StashException { };
class StashEmptyBin : public StashContinue { };
@Kronuz
Kronuz / ev.cpp
Last active December 16, 2020 03:29
// The following code can be extended to multiple threads
//This program is demo for using pthreads with libev.
//Try using Timeout values as large as 1.0 and as small as 0.000001
//and notice the difference in the output
//(c) 2009 debuguo
//(c) 2013 enthusiasticgeek for stack overflow
//Free to distribute and improve the code. Leave credits intact
@Kronuz
Kronuz / Multi-table inheritance in django-denorm
Last active December 14, 2015 13:09
This adds some multi-table inheritance to django-denorm
--- django-denorm/denorm/dependencies.py
+++ django-denorm/denorm/dependencies.py
@@ -260,7 +260,7 @@ class CallbackDependOnRelated(DependOnRelated):
model=DirtyInstance,
columns=("content_type_id", "object_id"),
values=triggers.TriggerNestedSelect(
- self.this_model._meta.db_table,
+ self.this_model._meta.pk.model._meta.db_table,
(content_type,
self.this_model._meta.pk.get_attname_column()[1]),
@Kronuz
Kronuz / gist:3923320
Created October 20, 2012 13:48
gnuplot formula not depending on x11
--- a/Library/Formula/gnuplot.rb
+++ b/Library/Formula/gnuplot.rb
@@ -19,8 +19,8 @@ class Gnuplot < Formula
depends_on 'pkg-config' => :build
depends_on 'readline'
- depends_on 'pango'
- depends_on :x11
+ # depends_on 'pango'
+ # depends_on :x11
@Kronuz
Kronuz / gist:3923317
Created October 20, 2012 13:47
pil formula not depending on x11
--- a/Library/Formula/pil.rb
+++ b/Library/Formula/pil.rb
@@ -5,7 +5,7 @@ class Pil < Formula
homepage 'http://www.pythonware.com/products/pil/'
sha1 '76c37504251171fda8da8e63ecb8bc42a69a5c81'
- depends_on :x11
+ # depends_on :x11
depends_on 'jpeg' => :recommended
depends_on 'little-cms' => :optional
#!/bin/sh
#
# This takes the first rule and makes it randomly active across the day in several rules
#
# For tomato router
# http://infinilogix.com/wordpress/category/network-programming
#
# 1|540|1140|62|||block-site.com$|0|New Rule 1
# Let us take a closer look at what each of these nine fields separated by pipe (|) means.
# The first field shows whether the rule is currently enabled or disabled – 1 means enabled, 0 means disabled.
@Kronuz
Kronuz / geospatial-to-1.2.12.diff
Created September 12, 2012 20:48
Geospatial support backported from 1.3.0 (only python bindings tested/work atm)
diff --git a/xapian-bindings/xapian.i b/xapian-bindings/xapian.i
index 7b608e4..25ea850 100644
--- a/xapian-bindings/xapian.i
+++ b/xapian-bindings/xapian.i
@@ -202,6 +202,7 @@ class ValueIterator {
%ignore Xapian::PostingSource::clone;
%ignore Xapian::PostingSource::serialise;
%ignore Xapian::PostingSource::unserialise;
+%ignore Xapian::PostingSource::unserialise_with_registry;
%ignore Xapian::PostingSource::register_matcher_;
@Kronuz
Kronuz / gist:3666938
Created September 7, 2012 15:03
Xapian 1.3.0 homebrew formula
require 'formula'
class XapianBindings < Formula
homepage 'http://xapian.org'
# url 'http://oligarchy.co.uk/xapian/1.2.12/xapian-bindings-1.2.12.tar.gz'
# sha1 'f75921b43041e6e672821c51fe29dbbaee491791'
url 'http://oligarchy.co.uk/xapian/1.3.0/xapian-bindings-1.3.0.tar.gz'
sha1 'bfb4639e968b012e5780c2a3d673963afa90b6fe'
end
@Kronuz
Kronuz / gist:3383270
Created August 17, 2012 22:32
Celery 3.0 and "Stale pidfile exists. Removing it." message
--- celery/apps/beat.py
+++ celery/apps/beat.py
@@ -12,6 +12,7 @@
"""
from __future__ import absolute_import
+import atexit
import socket
import sys
@Kronuz
Kronuz / gist:2663040
Created May 11, 2012 23:15
ImageSpecFieldFile error
Traceback (most recent call last):
File "../libs/celery/concurrency/processes/pool.py", line 239, in run
return self.body()
File "../libs/celery/concurrency/processes/pool.py", line 288, in body
put(task)
File "/Library/Python/2.7/site-packages/django/db/models/fields/files.py", line 134, in __getstate__
return {'name': self.name, 'closed': False, '_committed': True, '_file': None}
File "../apps-ext/imagekit/models/fields/files.py", line 114, in name
filename = self.source_file.name
File "../apps-ext/imagekit/models/fields/files.py", line 18, in source_file