Skip to content

Instantly share code, notes, and snippets.

kiyoto kiyoto

Block or report user

Report or block kiyoto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View php-bug-60668.diff
diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c
index a7ec5d7..89b1287 100644
--- a/Zend/zend_ini.c
+++ b/Zend/zend_ini.c
@@ -83,6 +83,23 @@ static int zend_restore_ini_entry_wrapper(zend_ini_entry **ini_entry TSRMLS_DC)
}
/* }}} */
+static uint zend_trim_after_carriage_return(char *value, uint value_length) /* {{{ */
+{
@kiyoto
kiyoto / gist:1857431
Created Feb 18, 2012
openssl_decrypt bug patch
View gist:1857431
Index: ext/openssl/openssl.c
===================================================================
--- ext/openssl/openssl.c (revision 323312)
+++ ext/openssl/openssl.c (working copy)
@@ -4801,6 +4801,11 @@
base64_str = (char*)php_base64_decode((unsigned char*)data, data_len, &base64_str_len);
data_len = base64_str_len;
data = base64_str;
+
+ if (data == NULL) {
@kiyoto
kiyoto / github-scraper.php
Created Mar 28, 2012
github scraper. get user info for the users watching a particular repo
View github-scraper.php
#!/usr/bin/env php
<?php
function get_watchers($login, $repo) {
$per_page = 100; // this is the max set by github http://developer.github.com/v3/#pagination
$page_number = 1;
$watchers = array();
while (1) {
$ch = curl_init(sprintf('https://api.github.com/repos/%s/%s/watchers?page=%d&per_page=%d',
@kiyoto
kiyoto / hn-stats
Created Jun 2, 2012
Just a random script to scrape info from HN's top page.
View hn-stats
#!/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
@kiyoto
kiyoto / random_array.php
Created Jun 15, 2012
creating random associative arrays
View random_array.php
<?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);
View basic_information.sql
-- 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
(
@kiyoto
kiyoto / book_crossing_status_query.sql
Created Jul 16, 2012
Book Crossing Dataset Status Queries
View book_crossing_status_query.sql
-- 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
@kiyoto
kiyoto / book_crossing_action_query.sql
Created Jul 23, 2012
Book Crossing Dataset Action Queries
View book_crossing_action_query.sql
-- 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)
@kiyoto
kiyoto / anonconvo.rb
Created Oct 10, 2012
anonymize/filter out timestamps from Adium chat logs
View anonconvo.rb
#!/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']
@kiyoto
kiyoto / in_twitterstream.rb
Created Nov 2, 2012
TD-agent input plugin to get data from Twitter (thanks so jyuan)
View in_twitterstream.rb
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
You can’t perform that action at this time.