Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name HN Toolkit
// @namespace http://news.ycombinator.com
// @description Version 1.8 - Various useful things (blacklist/style, saved links, searchyc, splitview, PRE-fix, new preview, title rename) for Hacker News
// @include http://news.ycombinator.com/*
// ==/UserScript==
/*
Written by Xichekolas ... License: 'do whatever you want with it'.
http://news.ycombinator.com/user?id=Xichekolas
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
/**
* List ALSA pcm plugins.
*
* This code is based on code I saw in PortAudio, which is under the MIT license.
* http://portaudio.com/trac/browser/portaudio/trunk/src/hostapi/alsa/pa_linux_alsa.c
*
* Note that the method used here is quite different to detecting hw devices,
* which iterates over cards, devices and subdevices.
*
* gcc -o pcm_plugins pcm_plugins.c -lasound
@tung
tung / shadow.rb
Created September 18, 2010 03:17
# Sample usage of Ruby recursive shadowcasting implementation:
# http://roguebasin.roguelikedevelopment.org/index.php?title=Ruby_shadowcasting_implementation
require "ShadowcastingFieldOfView"
class Map
def initialize(map)
@map = map
@view = Array.new(map.length)
@view.length.times do |y|
@tung
tung / nh343-defername-unix-tty.diff
Created April 12, 2011 03:11
Unix/TTY-specific NetHack patch to allow choosing a name after picking a role. Made because Michael Lehotay's patch (http://bilious.homelinux.org/?68) was unavailable, until yesterday.
diff -r -U 3 -x '*.o' -x nethack -x nhdat -x date.h vanilla/include/extern.h nethack-3.4.3/include/extern.h
--- vanilla/include/extern.h 2011-04-09 00:08:56.000000000 +1000
+++ nethack-3.4.3/include/extern.h 2011-04-12 03:28:47.000000000 +1000
@@ -638,6 +638,7 @@
E int NDECL(open_savefile);
E int NDECL(delete_savefile);
E int NDECL(restore_saved_game);
+E int NDECL(saved_game_exists);
E void FDECL(compress, (const char *));
E void FDECL(uncompress, (const char *));
@tung
tung / nh343-decgraphics-fix.diff
Created April 12, 2011 03:16
NetHack patch to fix the DECgraphics file option not working due to my own over-patching.
diff -U 3 -r nethack-3.4.3-pre-defername/sys/unix/unixmain.c nethack-3.4.3/sys/unix/unixmain.c
--- nethack-3.4.3-pre-defername/sys/unix/unixmain.c 2011-04-09 15:33:59.000000000 +1000
+++ nethack-3.4.3/sys/unix/unixmain.c 2011-04-11 00:39:42.000000000 +1000
@@ -160,6 +160,12 @@
#endif
/*
+ * Set DECgraphics again in case option loading didn't set it.
+ */
+ if(iflags.DECgraphics)
@tung
tung / defername343.diff
Created April 12, 2011 03:20
Gist mirror of Michael Lehotay's TTY-only Defer Name v1.0 NetHack patch (see http://bilious.homelinux.org/?68).
diff -r -u nethack-3.4.3/src/allmain.c defername/src/allmain.c
--- nethack-3.4.3/src/allmain.c 2003-12-07 18:39:14.000000000 +0000
+++ defername/src/allmain.c 2003-12-14 18:58:28.000000000 +0000
@@ -450,6 +450,9 @@
void
display_gamewindows()
{
+ if(WIN_MESSAGE != WIN_ERR)
+ return;
+
@tung
tung / ban.js
Created June 25, 2011 11:24
jsshell script to ban a user on an SMF-based forum
// Ban a spambot
$('th:contains("Reason:") + td > input').val("Spambot");
$('#main_ip_check').attr('checked', true);
$('#email_check').attr('checked', true);
$('#user_check').attr('checked', true);
$(':submit[name="add_ban"]').css('fontSize', '30pt');
@tung
tung / tag-list.php
Created September 23, 2011 08:18
Tag list block for Drupal 6.x
<?php
/**
* Abstraction-breaking custom tag lister.
* This block lists all tags under the given taxonomy vocabulary,
* in order of frequency, and then name. The tags are hyperlinked.
*/
$vocabulary_id = 8;
$cutoff = 15; // don't show results that don't pass the threshold
$threshold = 5; // after cutoff, don't show tags with counts less than this
$tag_query = "SELECT td.tid, td.name, COUNT(DISTINCT tn.nid) as num " .
@tung
tung / clean-youtube-front-page.css
Created December 2, 2011 04:19
Clean YouTube front page
/* Hide the homepage's sidebar. */
.guide-container { display: none !important; }
.guide-background { display: none !important; }
/* Hide recommended/promoted videos on the right. */
#video-sidebar { display: none !important; }
/* Widen the subscription feed for our newly-freed space. */
#feed {
margin-left: 0 !important;