Skip to content

Instantly share code, notes, and snippets.

@vierbergenlars
vierbergenlars / segv.php
Created November 20, 2012 16:49
Get a PHP segfault

First, clone git clone git@github.com:vierbergenlars/gihp.git Check out git checkout 08dc6abfdbf90b1e1a8b10cd7064601fb820d950 And then insert the file above and run with php segv.php

@vierbergenlars
vierbergenlars / build.sh
Last active December 12, 2015 03:28
UglifyJS bug report attachment
uglifyjs original.js -c -b --comments all -o commented.js
uglifyjs original.js -c -m -o min.js
def and(bits1, bits2):
"""
Executes AND operation on 2 binary numbers, like it is done internally when using & operator
"""
bits_out = []
while True:
if i > len(bits1) && i > len(bits2):
# We have past all bits in both numbers, break out of the loop now
break
if i < len(bits1):
@vierbergenlars
vierbergenlars / bogosort.py
Created March 12, 2013 11:18
Fastest sorting algorithm ever! Introducing BogoSort
#!/usr/bin/env python
"""
http://acm.zhihua-lai.com
BogoSort.py
Bogo Sorting Algorithm
30/May/2012
https://raw.github.com/DoctorLai/Algorithms/master/Sorting/BogoSort.py
"""
from random import *
#deb cdrom:[Ubuntu-GNOME 13.04 _Raring Ringtail_ - Release amd64 (20130424)]/ raring main multiverse restricted universe
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://be.archive.ubuntu.com/ubuntu/ raring main restricted
deb-src http://be.archive.ubuntu.com/ubuntu/ raring main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://be.archive.ubuntu.com/ubuntu/ raring-updates main restricted
@vierbergenlars
vierbergenlars / install.sh
Last active December 16, 2015 18:59
Kotnet login script. Just run sudo ./install.sh
apt-get install -y perl libwww-mechanize-perl
mv kotnet_login.pl /etc/NetworkManager/dispatcher.d/02kotnet
ln -s /etc/NetworkManager/dispatcher.d/02kotnet /etc/init.d/kotnet
update-rc.d kotnet defaults
def count(lst, elem):
if len(lst) == 1:
return lst[0] == elem
else:
return count(lst[1:], elem) + (lst[0] == elem)
@vierbergenlars
vierbergenlars / .conkyrc
Last active December 18, 2015 00:08
Installation instructions: Install fonts (move to /usr/share/fonts/); Move files as indicated
# About this gist: http://vierbergenlars.wordpress.com/2013/06/07/tweaking-ubuntu-gnome-with-conky/
# Conky settings #
background no
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
if_up_strictness address
@vierbergenlars
vierbergenlars / vid2mp3.php
Last active December 18, 2015 00:39
Convert video files to mp3 audio. Processes some videos simultaneous for better use of multi-core systems. Requires avconv.
#!/usr/bin/env php
<?php
// ##### START config
$files = glob('*.{mp4,flv}', GLOB_BRACE); // File types to convert to mp3 (video only)
$worker_num = 3; // number of cores +1
// ##### END config
$len = count($files);
$worker_pids = array();
function pr($s) {
#include <glob.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#define NUM_WORKERS 3