diff options
| author | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2014-05-14 12:02:39 -0400 |
|---|---|---|
| committer | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2014-05-14 12:02:39 -0400 |
| commit | 101c0be26573b6cc20a8542d378592fd0eec2ba5 (patch) | |
| tree | 98a17d4ff252b4c5c3937eb16db1c10d63a142ce | |
| parent | 7a62c03ebe5c36a47274d170ce8c39957cdf437c (diff) | |
scripts to fix redis when it crashes
| -rw-r--r-- | scripts/fix_fav_counts.py | 99 | ||||
| -rwxr-xr-x | scripts/sort_faves.sh | 20 | ||||
| -rw-r--r-- | src/site.clj | 3 | ||||
| -rwxr-xr-x | static/css/dump.css | 10 | ||||
| -rw-r--r-- | static/js/pichat.js | 18 | ||||
| -rw-r--r-- | static/js/pichat2.js | 18 | ||||
| -rwxr-xr-x | static/js/register.js | 8 | ||||
| -rw-r--r-- | static/js/src/fun.js | 10 | ||||
| -rw-r--r-- | static/js/src/messages.js | 4 | ||||
| -rw-r--r-- | static/js/src/util.js | 4 | ||||
| -rw-r--r-- | static/super/index.html | 8 | ||||
| -rw-r--r-- | template/banner.st | 5 | ||||
| -rw-r--r-- | template/fullscreen.st | 7 |
13 files changed, 202 insertions, 12 deletions
diff --git a/scripts/fix_fav_counts.py b/scripts/fix_fav_counts.py new file mode 100644 index 0000000..00e8d0f --- /dev/null +++ b/scripts/fix_fav_counts.py @@ -0,0 +1,99 @@ +""" + this needs python 3 due to py-postgresql... + + before running this command, please run the following SQL, which tallies the faves per post: + + COPY (SELECT messages.user_id, tags.message_id, COUNT(tags.message_id) AS mycount, TO_CHAR(messages.created_on, 'YYYYMMDD') + FROM tags, messages + WHERE tags.message_id = messages.message_id AND tags.tag = 'favorite' + GROUP BY tags.message_id, messages.user_id, messages.created_on) + TO '/tmp/fav_counts2.csv' WITH CSV; + + then run ./sort_faves.sh which will pre-sort the data for this script. +""" + +import re +import sys +import postgresql +import redis +import csv + +db = postgresql.open("pq://postgres:root@localhost/dumpfm") +db.execute("SET CLIENT_ENCODING to 'UNICODE'") + +r = redis.Redis("192.168.156.111") + +def fetch_users(): + statement = """SELECT user_id, nick FROM users""" + + ps = db.prepare(statement) + return ps.chunks + +# by_date.csv by_user.csv counts_sorted.csv hall.csv +# field order: user_id, message_id, score, date + +def load_faves_by_user(): + nicks = load_nicks() + counter = 0 + user_counter = 0 + score = 0 + user_id = 0 + key = "" + with open('faves/by_user.csv', 'r') as csvfile: + reader = csv.reader(csvfile) + for row in reader: + if row[0] != user_id: + if score != 0: + r.zadd("favscores", nicks[user_id], score) + counter = 0 + user_counter += 1 + score = 0 + user_id = row[0] + key = "popular:" + nicks[user_id] + if (user_counter % 1000) == 0: + print(str(user_counter) + " ...") + score += int(row[2]) + if counter > 30: + continue + r.zadd(key, row[1], int(row[2])) + counter += 1 + +def load_faves_by_date(): + date_counter = 0 + counter = 0 + date = "" + key = "" + with open('faves/by_date.csv', 'r') as csvfile: + reader = csv.reader(csvfile) + for row in reader: + if row[3] != date: + counter = 0 + date_counter += 1 + date = row[3] + key = "hall:daily:" + row[3] + if (int(date) % 100) == 1: + print(key) + if counter > 30: + continue + r.zadd(key, row[1], int(row[2])) + counter += 1 + +def load_hall(): + with open('faves/hall.csv', 'r') as csvfile: + reader = csv.reader(csvfile) + for row in reader: + r.zadd('hall', row[1], int(row[2])) + +def load_nicks(): + nicks = {} + chunks = fetch_users() + for rowset in chunks(): + for row in rowset: + nicks[str(row[0])] = row[1] + return nicks + +if __name__ == "__main__": + # load_hall() + # load_faves_by_user() + load_faves_by_date() + diff --git a/scripts/sort_faves.sh b/scripts/sort_faves.sh new file mode 100755 index 0000000..eb28a39 --- /dev/null +++ b/scripts/sort_faves.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ ! -n "$1" ] +then + echo "Usage: `basename $0` fav_scores.csv" + exit +fi + +mkdir -p faves + +echo "Get the top 50 faves for the Hall of Fame" +sort -t, -k3,3 -rn $1 | head -50 > faves/hall.csv + +echo "Group faves by user for popular pages, total fave scores" +sort -t, -k1,1 -r -k3,3 -n faves/counts_sorted.csv > faves/by_user.csv + +echo "Group faves by date for daily tallies" +sort -t, -k4,4 -r -k3,3 -n faves/counts_sorted.csv > faves/by_date.csv + + diff --git a/src/site.clj b/src/site.clj index 4db093f..b322738 100644 --- a/src/site.clj +++ b/src/site.clj @@ -1196,6 +1196,9 @@ WHERE user_id IN (GET "/images/*" (serve-static *image-directory* (params :*))) (GET "/avatars/*" (serve-static *avatar-directory* (params :*))) ;; irl + (GET "/soccer/*" (redirect-to "/")) + (GET "/soccer/" (redirect-to "/")) + (GET "/soccer" (redirect-to "/")) (GET "/irl" (redirect-to "/irl/")) (GET "/irl/" (serve-static "static/319" "index.html")) (GET "/irl/*" (serve-static "static/319" (params :*))) diff --git a/static/css/dump.css b/static/css/dump.css index 5ae714f..0b6055e 100755 --- a/static/css/dump.css +++ b/static/css/dump.css @@ -2506,3 +2506,13 @@ a#disregister:hover { color: green; } +.rainbow { + background-image:-webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) ); + color:transparent; + -webkit-background-clip: text; +} + +.nick_aids_enoch { opacity: 0.3; color: transparent; text-shadow: 0 0 5px #857E96; } + +.bigimage { max-width: none!important; max-height: none!important;width:100% } + diff --git a/static/js/pichat.js b/static/js/pichat.js index 5fd0de8..61489c0 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -787,6 +787,16 @@ function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } + +$(function(){ + var d = new Date() + var mon = (d.getMonth()+1) + var day = d.getDate() + mon = mon < 10 ? "0" + mon : mon + day = day < 10 ? "0" + day : day + $("#hall-link").attr("href", "/top/" + (d.getFullYear()) + "" + mon + day) +}) + // Growl function buildGrowlDataAndPopDatShit(msg) { @@ -1066,7 +1076,9 @@ function submitMessage() { div.remove(); handleMsgError(resp); }; - + + if (Nick == "lmstupid" || Nick == "frederika" || Nick == "deluge") return; + $.ajax({ type: 'POST', timeout: 15000, @@ -2363,6 +2375,10 @@ window.requestAnimFrame = (function(){ }; })(); +function text_off(){ + setTextEnable.call( $("#textbutton input").attr("checked",false) ) +} + Youtube = { "timer": 0, diff --git a/static/js/pichat2.js b/static/js/pichat2.js index 5fd0de8..61489c0 100644 --- a/static/js/pichat2.js +++ b/static/js/pichat2.js @@ -787,6 +787,16 @@ function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } + +$(function(){ + var d = new Date() + var mon = (d.getMonth()+1) + var day = d.getDate() + mon = mon < 10 ? "0" + mon : mon + day = day < 10 ? "0" + day : day + $("#hall-link").attr("href", "/top/" + (d.getFullYear()) + "" + mon + day) +}) + // Growl function buildGrowlDataAndPopDatShit(msg) { @@ -1066,7 +1076,9 @@ function submitMessage() { div.remove(); handleMsgError(resp); }; - + + if (Nick == "lmstupid" || Nick == "frederika" || Nick == "deluge") return; + $.ajax({ type: 'POST', timeout: 15000, @@ -2363,6 +2375,10 @@ window.requestAnimFrame = (function(){ }; })(); +function text_off(){ + setTextEnable.call( $("#textbutton input").attr("checked",false) ) +} + Youtube = { "timer": 0, diff --git a/static/js/register.js b/static/js/register.js index ff93b0b..d2d513d 100755 --- a/static/js/register.js +++ b/static/js/register.js @@ -31,10 +31,10 @@ function submitRegistration() { if (typeof pageTracker !== 'undefined') { pageTracker._trackEvent('User', 'Register', nick); } - if (window.history && history.length > 1) - history.go(-1); - else - location.href = 'http://dump.fm/'; + // if (window.history && history.length > 1) + // history.go(-1); + // else + window.location.href = 'http://dump.fm/'; }; var onError = function(resp) { diff --git a/static/js/src/fun.js b/static/js/src/fun.js index 1188678..c57a774 100644 --- a/static/js/src/fun.js +++ b/static/js/src/fun.js @@ -108,3 +108,13 @@ function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } + +$(function(){ + var d = new Date() + var mon = (d.getMonth()+1) + var day = d.getDate() + mon = mon < 10 ? "0" + mon : mon + day = day < 10 ? "0" + day : day + $("#hall-link").attr("href", "/top/" + (d.getFullYear()) + "" + mon + day) +}) + diff --git a/static/js/src/messages.js b/static/js/src/messages.js index be54b6b..f7d0877 100644 --- a/static/js/src/messages.js +++ b/static/js/src/messages.js @@ -69,7 +69,9 @@ function submitMessage() { div.remove(); handleMsgError(resp); }; - + + if (Nick == "lmstupid" || Nick == "frederika" || Nick == "deluge") return; + $.ajax({ type: 'POST', timeout: 15000, diff --git a/static/js/src/util.js b/static/js/src/util.js index 814c81b..e8d1107 100644 --- a/static/js/src/util.js +++ b/static/js/src/util.js @@ -90,3 +90,7 @@ window.requestAnimFrame = (function(){ }; })(); +function text_off(){ + setTextEnable.call( $("#textbutton input").attr("checked",false) ) +} + diff --git a/static/super/index.html b/static/super/index.html index 0382d56..b035b9b 100644 --- a/static/super/index.html +++ b/static/super/index.html @@ -27,17 +27,17 @@ <a href="/"><img src="/static/img/dumppixellarge3.png"></a> <div align="center"> <label style="text-align:left;margin-bottom:-8px;">username</label> - <input type="text" class="field"id="nickInput" /> + <input type="text" class="field"id="regNickInput" /> <br> <label style="text-align:left;margin-bottom:-8px;">password</label> - <input type="password" class="field" id="passwordInput" /> + <input type="password" class="field" id="regPasswordInput" /> <br> <label style="text-align:left;margin-bottom:-8px;">password2x</label> - <input type="password" class="field" id="passwordInput2" /> + <input type="password" class="field" id="regPasswordInput2" /> <label style="text-align:left;margin-bottom:-8px;">email</label> - <input type="text" class="field"id="emailInput" /> + <input type="text" class="field"id="regEmailInput" /> </h1> </form> diff --git a/template/banner.st b/template/banner.st index 0ab1a7b..5cca522 100644 --- a/template/banner.st +++ b/template/banner.st @@ -19,7 +19,7 @@ <a href="$domain$/directory" onclick="pageTracker._trackEvent('button', 'banner-directory'); return true;"> <img src="$domain$/static/img/thumbs/directorybaricon.png"/> Directory </a> - <a href="$domain$/hall" onclick="pageTracker._trackEvent('button', 'banner-hall'); return true;"> + <a href="$domain$/" onclick="pageTracker._trackEvent('button', 'banner-hall'); return true;" id="hall-link"> <img src="$domain$/static/img/thumbs/halloffamebaricon.png"/> Hall of Fame </a> </div> @@ -35,6 +35,8 @@ <select class="toolsmenu" name="menu" onChange="if (document.Tools.menu.selectedIndex != 0) { location=document.Tools.menu.options[document.Tools.menu.selectedIndex].value; } "> <option>Tools</option> <option value="http://bon.gs/tile/" target="_blank">Tile Tool</option> + <option value="http://asdf.us/im/">Photoblaster</option> + <option value="http://csh.bz/gifmelter/">Gifmelter</option> <option value="http://dump.fm/m/oie">Online Image Editor</option> <option value="http://dump.fm/m/3frames">3fram.es</option> <option value="http://dump.fm/m/dwi">Deal With It Maker</option> @@ -74,6 +76,7 @@ $if(user_nick)$ <a href="http://dump.fm/fullscreen">checkout dump.fm in full-screen </a> - <a href="http://abcdef4.dump.fm/">MYSTERY ROOM!!!!!!!! </a> + - <a href="http://www.zazzle.com/ppshoppe/gifts">CHECK OUT THE PP SHOPPE!!!!!</a> $else$ <style>#dumplist{z-index:-1!important;}</style> $endif$ $if(isadmin)$ - <a href="http://vip.dump.fm/">NAUGHTY GIRLS/AND-OR/BOYS DELIGHT </a> $endif$ diff --git a/template/fullscreen.st b/template/fullscreen.st index 79c3934..08cf74d 100644 --- a/template/fullscreen.st +++ b/template/fullscreen.st @@ -184,6 +184,12 @@ <div id="registerbox" class="box"> <a href="/"><img src="/static/img/dumppixellarge3.png"></a> <p> + registration is closed ;-( + </p> + <p> + maybe ask a friend? + </p> + <!-- <label style="text-align:left;margin-bottom:-8px;">username</label> <input type="text" class="field" id="regNickInput" tabindex="5" /> </p><p> @@ -198,6 +204,7 @@ </p><p> <input type="submit" class="submit" id="submit" value="Register!" tabindex="9" /> </p> + --> </div> $endif$ |
