This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(d){ | |
var tbox, text, len = 140, ii = 0; | |
tbox = d.getElementById('tweet-box-global'); | |
if (!tbox) return; | |
if (!(tbox = tbox.firstChild)) return; | |
if (!(text = tbox.innerHTML)) return; | |
while (true) { | |
len -= encodeURI(text[ii]).replace(/%[A-F\d]{2}/g, 'U').length; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(d){ | |
var cls, ii, cl, ct = 0; | |
cls = d.getElementsByClassName('discussion-bubble'); | |
for (ii = 0; ii < cls.length; ii++) { | |
cl = cls[ii]; | |
if (/IETF/i.test(cl.innerHTML)) { | |
cl.style.display = 'none'; | |
ct++; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
repo=$1 | |
project=$2 | |
curl -sL https://api.github.com/repos/$1/$2/issues | perl -e '$nc=0; while(<>) { if(/"comments": (\d+)/ && ($nc < ($c=int($1)))) { $nc=$c; } } print "$nc\n";' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Fluent | |
class TwitterStreamInput < Fluent::Input | |
# Register plugin | |
Plugin.register_input('twitterstream', self) | |
# required auth params | |
config_param :consumer_key, :string | |
config_param :consumer_secret, :string | |
config_param :access_token_key, :string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# to parse Adium conversation | |
regex = /^[\d:]+ [AP]M (?<name>[^:]+): (?<msg>.*)$/ | |
for line in STDIN | |
m = regex.match(line) | |
next if not m | |
name = m['name'] | |
msg = m['msg'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Query 1: Counting Harsh, Generous and Lazy | |
td query -w -d book_crossing_dataset " | |
SELECT rating_type, COUNT(*) As cnt | |
FROM | |
( | |
SELECT user_id, MIN(book_rating) AS stat, COUNT(book_rating) AS cnt, 'Generous' AS rating_type | |
FROM ratings | |
WHERE 0 < book_rating | |
GROUP BY user_id | |
HAVING 5 < COUNT(book_rating) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Queries 1 | |
td query -w -d book_crossing_dataset " | |
SELECT t AS type, cnt | |
FROM | |
( | |
SELECT COUNT(*) AS cnt, 'only in users' AS t | |
FROM | |
( | |
SELECT user_id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1.1.1 all users v. active users -- | |
td query -w -d book_crossing_dataset " | |
SELECT t1.cnt AS all_users, t2.cnt AS active_users, ROUND(t2.cnt/t1.cnt*100) AS active_rate | |
FROM | |
( | |
SELECT COUNT(distinct user_id) as cnt, 1 AS one | |
FROM users | |
) t1 | |
JOIN | |
( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function random_array(&$current) { | |
foreach ($current as $k => &$v) { | |
if ((rand() % 10) / 10 >= 0.68) { | |
$v = array(0, 'aoiyu', 1337); | |
random_array($v); | |
} | |
} | |
unset($v); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
HN_FILE='hn.html' | |
HN="http://news.ycombinator.com" | |
rm -f $HN_FILE | |
wget "$HN" -O $HN_FILE | |
if [ -f $HN_FILE ] | |
then | |
perl -ne 'while (m!<td class="title"><a href="(http[^"]+)">(?:.*?)</a><span class="comhead"> \(([^)]+)\) </span></td></tr><tr><td colspan=2></td>(?:<td class="subtext"><span id=score_\d+>(\d+) points</span> by <a href="user\?id=[^"]+">(?:.*?)</a> (\d+) (minute|hour|day)s? ago \| <a href="item\?id=\d+">(\d+) comments?</a>)?!g) { print "$1 $2"; if (defined $3) { print " $3 $4 $5 $6"; } print "\n"; }' < $HN_FILE | |
else |