From 574955249b1acb8005b5d52b5cf1b2f6b82d4acd Mon Sep 17 00:00:00 2001 From: Kai Hendry Date: Thu, 1 Oct 2015 22:39:23 +0800 Subject: [PATCH] Mostly working :) ~900mb to ~90mb --- www/fetch-tweets.sh | 11 +++++------ www/grep.php | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/www/fetch-tweets.sh b/www/fetch-tweets.sh index 37e9125..7618ea8 100755 --- a/www/fetch-tweets.sh +++ b/www/fetch-tweets.sh @@ -10,8 +10,8 @@ else mkdir lock fi -temp=$(mktemp "$1.XXXX") -temp2=$(mktemp "$1.XXXX") +temp=$(mktemp) +temp2=$(mktemp) trap 'rm -vrf "${temp}" "${temp2}" lock' EXIT @@ -35,8 +35,8 @@ then test "$2" && since='&max_id='$(tail -n1 "$1.txt" | cut -d'|' -f1) # use max_id to get older tweets fi -while urlargs="screen_name=${1}&count=200&page=${page}${since}&include_rts=1&trim_user=0"; echo "$urlargs"; "$(dirname "$0")"/oauth.php "$urlargs" | -"$(dirname "$0")"/json-to-text.php > "$temp2"; test "$(wc -l < "$temp2")" -gt 0; +while urlargs="screen_name=${1}&count=200&page=${page}${since}&include_rts=1&trim_user=0"; echo "$urlargs"; /srv/http/oauth.php "$urlargs" | +/srv/http/json-to-text.php > "$temp2"; test "$(wc -l < "$temp2")" -gt 0; do #cat temp2 @@ -66,5 +66,4 @@ echo "$1" saved "$saved" tweets test -L "$1.txt.gz" && rm "$1.txt.gz" gzip -v "$1.txt" -ln -sfv "$1.txt.gz" tweets.txt.gz -stat -L tweets.txt 2>/dev/null || rm -f tweets.txt +ln -sfv "$1.txt.gz" tweets.txt diff --git a/www/grep.php b/www/grep.php index 2ea5053..f5fbd2e 100644 --- a/www/grep.php +++ b/www/grep.php @@ -10,7 +10,7 @@ $QUERY=escapeshellarg($_GET['q']); //fwrite($fp, $_GET['q'] . " : " . $QUERY . "\n"); //fclose($fp); -exec("zgrep -Fhi $QUERY tweets.txt", $array); +exec("gunzip -c tweets.txt | grep -Fhi $QUERY", $array); $data = json_encode($array); echo $_GET['jsoncallback'] . '(' . $data . ');'; ?>