Skip to content

Instantly share code, notes, and snippets.

View nullren's full-sized avatar

Renning Bruns nullren

View GitHub Profile
@nullren
nullren / small_fart.c
Created March 3, 2013 03:42
anonymous function loses its place in memory and causes a segfault
#include <stdio.h>
#include <stdlib.h>
#define lambda(return_type, function_body) \
({ return_type __fn__ function_body; \
__fn__; \
})
#define RANDBL ((double)random()/(double)RAND_MAX)
@nullren
nullren / fart.c
Last active December 14, 2015 10:48
something that is kind of silly
#include <stdio.h>
#include <stdlib.h>
#define RANDBL ((double)random()/(double)RAND_MAX)
#define SEED 4
#define FLEN 1024
typedef double (*double_func)(double input);
@nullren
nullren / bs4_is_good_again.py
Created February 21, 2013 23:02
bs works good again. small example.
import urllib.request as r
from bs4 import BeautifulSoup
def grab(url):
f = r.urlopen(url)
doc = f.read().decode()
f.close()
return doc
html_doc = grab("http://omgren.com")
@nullren
nullren / json_dump.php
Created February 21, 2013 23:01
need quotes around json names
<?php
$str = '[{"schema": "mods", "field": "title", "css": "font-size: 14pt;"}]';
$j = json_decode($str);
var_dump($j);
@nullren
nullren / lamc.c
Created February 6, 2013 23:40
solve a problem i did not want to think about
#include <stdio.h>
int main()
{
int n, m, r;
int match=0;
for(n=2; ;n++)
@nullren
nullren / bzr.diff
Last active December 11, 2015 09:38
=== modified file '.bzrignore'
--- .bzrignore 2012-03-26 22:43:38 +0000
+++ .bzrignore 2013-01-13 21:14:56 +0000
@@ -23,3 +23,5 @@
bitlbee.exe
.depend
DEADJOE
+.git
+.bzr
@nullren
nullren / bitlbee_changes.diff
Last active December 11, 2015 02:08
changes i needed to make to bitlbee to use my plugin
=== modified file 'lib/ssl_client.h'
--- lib/ssl_client.h 2011-12-23 22:40:17 +0000
+++ lib/ssl_client.h 2013-01-20 19:00:01 +0000
@@ -49,19 +49,39 @@
#define VERIFY_CERT_EXPIRED 256
#define VERIFY_CERT_WRONG_HOSTNAME 512
+#include <gnutls/gnutls.h>
+
extern int ssl_errno;
@nullren
nullren / gdb.out
Created January 13, 2013 10:47
02:40 <@root> smsgcm - Error: Connection timeout 02:40 <@root> smsgcm - Signing off..
(gdb) bt
#0 0x00005555555885c2 in ?? ()
#1 0x00007ffff77213cb in ?? () from /usr/lib/libglib-2.0.so.0
#2 0x00007ffff7720845 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#3 0x00007ffff7720b78 in ?? () from /usr/lib/libglib-2.0.so.0
#4 0x00007ffff7720f72 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#5 0x00005555555673af in main ()
(gdb)
@nullren
nullren / smsgcm.c
Created January 13, 2013 10:31
getting stuck at `b_input_add`
gboolean smsgcm_ssl_read_cb(gpointer data, gint fd, b_input_condition cond)
{
struct im_connection *ic = data;
struct smsgcm_data *sd = ic->proto_data;
imcb_log(ic, "ssl data to be read");
char buf[1024];
if(sd == NULL || sd->fd == -1)
@nullren
nullren / gdb.out
Created January 13, 2013 04:41
i get a seg fault in this loop
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x0000555555587466 in bee_user_by_handle ()
#2 0x0000555555587685 in imcb_buddy_status ()
#3 0x000055555558793b in bee_user_new ()
#4 0x0000555555588740 in imcb_add_buddy ()
#5 0x00007ffff5253e51 in smsgcm_main_loop (data=0x5555558441c0, fd=<optimized out>, cond=<optimized out>) at smsgcm.c:19
#6 0x00007ffff77213cb in ?? () from /usr/lib/libglib-2.0.so.0
#7 0x00007ffff7720845 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#8 0x00007ffff7720b78 in ?? () from /usr/lib/libglib-2.0.so.0