Skip to content

Instantly share code, notes, and snippets.

@worr
worr / 0.py
Created August 4, 2012 04:45
GAME
import random
import sys
import pygame
from pygame.locals import *
num = 0
def win():
pygame.display.set_mode((2048, 480))
@worr
worr / russian_roulette.pl
Created August 7, 2012 19:55
Russian Roulette
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
my $char = chr(int(rand(26) + 97));
open(my $fh, ">", "/proc/sysrq-trigger");
say $fh $char;
close($fh);
@worr
worr / broke.c
Created February 20, 2013 01:18
static void check_if_need_to_close(struct cmd_data* cmd_data) {
if (cmd_data->cmd_exited && cmd_data->in_closed && cmd_data->out_closed && cmd_data->err_closed)
g_main_loop_quit(cmd_data->loop);
}
static void check_exit_status(GPid pid, gint status, gpointer user_data) {
wsh_cmd_res_t* res = ((struct cmd_data*)user_data)->res;
wsh_cmd_req_t* req = ((struct cmd_data*)user_data)->req;
res->exit_status = WEXITSTATUS(status);
@worr
worr / bad.pl
Created February 26, 2013 01:41
This code is dangerous
#!/usr/bin/env perl
use strict;
use warnings;
use v5.10;
open(my $fh, $ARGV[0]) or die "$!";
foreach (<$fh>) {
Executing pretend actions: 14 of 73
systemd-200> /usr/libexec/paludis/utils/canonicalise: line 4: /usr/bin/readlink: No such file or directory
systemd-200> is not a directory
45 of 73, 1 failed
icedtea7-2.3.8> /usr/libexec/paludis/ebuild.bash: line 103: /usr/bin/dirname: Not a directory
icedtea7-2.3.8> /usr/libexec/paludis/utils/canonicalise: line 4: /usr/bin/readlink: No such file or directory
icedtea7-2.3.8> is not a directory
46 of 73, 2 failed
#!/usr/bin/env perl
use strict;
use warnings;
use v5.10;
use JSON::Any;
use LWP::UserAgent;
use constant GITHUB_URI => "https://api.github.com/meta";
@worr
worr / autopoke.js
Last active December 16, 2015 18:29
(function() {
function pokeAll() {
var list = document.querySelectorAll("a[ajaxify*=pokeback]");
for (var i =0; i < list.length; i++) {
list[i].click();
}
}
setInterval( pokeAll, 100 );
})();
@worr
worr / fixed gcc command
Last active December 17, 2015 06:28
eventd gmake output
# Doesn't work
gcc -shared -fPIC -DPIC -o .libs/libeventc.so.0.0 -pthread -std=gnu99 -fvisibility=hidden -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -D G_LOG_DOMAIN="libeventc" -I/usr/local/include/gio-unix-2.0/ -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include -g -O2 -Wl,--no-undefined -shared client/libeventc/src/.libs/libeventc_la-libeventc.o -Wl,-whole-archive /home/will/eventd/.libs/libeventd-evp.a -Wl,-no-whole-archive -L.libs -leventd-event -lgio-2.0 -lgmodule-2.0 -lz -lgthread-2.0 -lffi -lpcre -lgobject-2.0 -lglib-2.0 -lintl -liconv
# Does work
gcc -shared -fPIC -DPIC -o .libs/libeventc.so.0.0 -pthread -std=gnu99 -fvisibility=hidden -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -D G_LOG_DOMAIN="libeventc" -I/usr/local/include/gio-unix-2.0/ -I/usr/local
Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/metaauto/Makefile,v
retrieving revision 1.17
diff -u -r1.17 Makefile
--- Makefile 11 Mar 2013 10:50:11 -0000 1.17
+++ Makefile 7 May 2013 23:06:22 -0000
@@ -3,9 +3,10 @@
COMMENT = wrapper for gnu auto*
@worr
worr / date.pl
Created July 5, 2013 18:11
matches some dates
my $mos = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ];
my $now = localtime;
my ($prev_month, $cur_month, $cur_day) = ($mos->[($now->mon() - 1) % 12], $mos->[$now->mon()], $now->mday());
map { print $out_fh $_ } grep { /(?:$cur_month|(?(?{$cur_day == 1})($prev_month)|$cur_month))\s+(?(1)(?:(?(?<=Feb\s)(?:28|29))30|31)|(?:$cur_day|(??{$cur_day - 1})))\b/ } <$in_fh>;