Skip to content

Instantly share code, notes, and snippets.

@hoosteeno
hoosteeno / foo.bash
Last active January 13, 2016 16:36
What Python standard library modules can execute as scripts with -m?
export version=2.7.11 && wget -q https://docs.python.org/2/archives/python-$version-docs-text.zip && unzip -qu python-$version-docs-text.zip && egrep -Ihor "python -m \w+" python-$version-docs-text | sort | uniq
# go here: https://github.com/hoosteeno/tounguescraper/blob/master/tounguescraper.py
@hoosteeno
hoosteeno / tinker_ks.js
Created September 17, 2015 02:32
how to create functions in kumascript
<%
tinker = function(path) {
var text = template('page', '/en-US/docs/Web');
text += "<p>I'M IN UR HTML ADDNG NOO MARKUPZ!</p>";
return text;
}
%>
<%-tinker('/en-US/docs/Web')%>
@hoosteeno
hoosteeno / get_profile_url_bio.sql
Last active August 29, 2015 14:14
get profile_url, url, count of revisions and bio from mdn profiles
select
url, count(wiki_revision.id) as revision_count, bio,
concat('https://developer.mozilla.org/en-US/profiles/', username) as profile_page
from
(select substring(
misc
from (
/* start substring after but not including website key */
locate('"website": ', misc) + 12
)
@hoosteeno
hoosteeno / surbl_lookup.py
Created January 30, 2015 12:58
check url on surbl
from surblclient import surbl
print 'freecreditreportblog.net' in surbl
print 'garagedoorrepairslandolakesfl.com' in surbl
print 'foo.bar.test.surbl.org' in surbl
@hoosteeno
hoosteeno / check_url_on_blocklists.py
Created January 30, 2015 12:47
Check url for presence on IP blocklists
import socket
import dns.resolver
urls = ["freecreditreportblog.net"]
bls = ["zen.spamhaus.org", "spam.abuse.ch", "cbl.abuseat.org", "virbl.dnsbl.bit.nl", "dnsbl.inps.de",
"ix.dnsbl.manitu.net", "dnsbl.sorbs.net", "bl.spamcannibal.org", "bl.spamcop.net",
"xbl.spamhaus.org", "pbl.spamhaus.org", "dnsbl-1.uceprotect.net", "dnsbl-2.uceprotect.net",
"dnsbl-3.uceprotect.net", "db.wpbl.info"]
@hoosteeno
hoosteeno / get_website_from_profile.sql
Last active August 29, 2015 14:14
get the website from the user profile in MDN
select substring(
misc
from (
/* start substring after but not including website key */
locate('"website": ', misc) + 12
)
for (
/* the location of the first " after the website key... */
locate('"', misc, locate('"website": ', misc) + 12)
/* minus the location of the website key plus the length of the website key */
@hoosteeno
hoosteeno / core_contrib_analysis.sql
Last active January 14, 2016 23:47
Get number of contribs, number of revisions per contrib, and percentage of contribution for those contribs using last 3 months activity to identify contribs.
SELECT count(username) AS num_contribs,
group_concat(username, ' (', user_total_revisions, ' revisions)' separator ', ') AS contribs,
sum(user_total_revisions) AS revisions_by_these_contribs,
overall_total_revisions,
(sum(user_total_revisions) / overall_total_revisions * 100) AS percentage_revisions_by_these_contribs
FROM (
/* get usernames WITH X revisions IN ANY month OF the last 3, AND Y revisions overall IN the last 3 */
@hoosteeno
hoosteeno / audit_dotorg_access.bash
Created May 23, 2014 21:49
get some html files from mozilla.org SVN
#!/bin/bash
echo "LOCATION, SVN, # FILES"
for FILE in `find ~/mozilla/mozilla.com/org/access \
-type d -name .svn -prune -o \
-a -type f -name '*.html' -print`
do
SVN=`echo $FILE | perl -pe 's|^.*?org|http://viewvc.svn.mozilla.org/vc/projects/mozilla.org/trunk|'`
LOC=`echo $FILE | perl -pe 's|^.*?org|http://www.mozilla.org|'`
@hoosteeno
hoosteeno / audit_dotorg.bash
Created May 23, 2014 19:40
get some html files from mozilla.org SVN
#!/bin/bash
echo "LOCATION, SVN, # FILES"
for FILE in `find ~/mozilla/mozilla.com/org \
-type d -name .svn -prune -o \
-type d -name access -prune -o \
-type d -name images -prune -o \
-type d -name includes -prune -o \
-type d -name script -prune -o \