Skip to content

Instantly share code, notes, and snippets.

View RichardBronosky's full-sized avatar

Bruno Bronosky RichardBronosky

View GitHub Profile
CT=[
medley.vandelay.apjobs.models.APPhoto,
medley.vandelay.apjobs.models.APStory,
medley.playlist.models.Artist,
medley.list_o_rama.models.AutomaticList,
medley.extensions.models.weblogs.MedleyBlog,
medley.extensions.models.weblogs.MedleyEntry,
medley.extensions.models.document.MedleyDocument,
medley.events.models.MedleyEvent,
medley.list_o_rama.models.ExternalFeed,
@RichardBronosky
RichardBronosky / local_mobile.py
Created October 27, 2011 16:30
A wrapper for the local settings file to simulate apache having detected a URL pattern that is NOT mobile blacklisted.
import os
from storyville.conf.local import *
os.environ['MOBILE_PATTERN'] = 'iphone|ipod|android|blackberry|symbian|nokia|sonyericsson|sie-|opera\ mini|portalmmm/|windows\ ce|up.browser|up.link|802sh|alcatel-|amoi-|attws|au-mic|audiovox|avantgo|benq|cdm-|ericsson|ericy-|gs308|hitachi-p300|htc-|i-2100|inn|kwc-|lg-|lg/u|lge-|lge/u|lowestcd|mo0|mobilephone|mot-|motorola|n5-10|nec-|opwv|owg1|palm|panasonic|pg-c|philips|pls|pm-|pn-215|profile/midp|qci-|rl-|rpt-httpclient|sagem|samsung|sanyo|sch-a|sch-n|scp-|sec-|sendox|sgh|sharp|smartphone|spha|v60t|vi600|vk530|vm4050|vodafone|wapper|wildseed|winwap-pro'
@RichardBronosky
RichardBronosky / backfill.sh
Created November 19, 2011 06:28
setup and use logstash
# A few oneliners to backfill the logstash with logs from all the apache servers
# (there server is running in a screen session in my home directory on "django apache admin 1" aka: djaapaadm1)
# Try searching for error at http://djaapaadm1.ddtc.cmgdigital.com:9292/
# backfill access logs to the listen on port 9293
for n in {1..10}; do ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no djaapaprd$n.ddtc.cmgdigital.com 'tail -n 10000 /localfs/httpd/logs/*-access_log' | sed '/^$/d;/^==> /d'; done | pv | nc djaapaadm1.ddtc.cmgdigital.com 9293
# backfill error logs to the listen on port 9294
for n in {1..10}; do ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no djaapaprd$n.ddtc.cmgdigital.com 'tail -n 10000 /localfs/httpd/logs/*-error_log' | sed '/^$/d;/^==> /d'; done | pv | nc djaapaadm1.ddtc.cmgdigital.com 9294
@RichardBronosky
RichardBronosky / git-flatten
Created November 19, 2011 07:27
How to flatten/squash a gist
git reset --soft $(/usr/local/bin/git log --format=%H | tail -1); git commit --amend --reset-author -m 'initial'
[sxz]$ $ es
[^aeioudgkprt]h$ $ es
[^aeiou]y$ y$ ies
$ $ s
from pylibcurl import curl;
from private_settings import TWITTER_USERNAME, TWITTER_PASSWORD
url='https://stream.twitter.com/1/statuses/filter.json?track=@%s' % (TWITTER_USERNAME)
userpwd='%s:%s' % (TWITTER_USERNAME, TWITTER_PASSWORD)
while True:
c=curl.Curl(url=url, userpwd=userpwd);
c.perform()
@RichardBronosky
RichardBronosky / get_udids.sh
Created March 15, 2012 04:06
A script to generate a spreadsheet of the iOS device UDIDs connected to your developer account
#!/usr/bin/env bash
# A script to generate a spreadsheet of the iOS device UDIDs connected to your developer account
# Copy the Apple Developer Portal cookies with the "cookie.txt export" Chrome plugin, then...
# pbpaste > cookies.txt
# ...then run this script
# The index page has a list of truncated UDIDs with link to a detail page for each.
curl --cookie cookies.txt https://developer.apple.com/ios/manage/devices/index.action | \
@RichardBronosky
RichardBronosky / mobile-redirects.conf
Created March 23, 2012 17:11
/services/apache/conf.d/django/prod/includes/mobile-redirects.conf
# Mobile logic to direct users to mobile or full sites
# Enforce destination to not be origin. Interim hack to allow mobile sites to redirect when returning from Akamai. -MH
RewriteCond %{HTTP_HOST} ^origin\.
RewriteRule ^(.*)$ %{HTTP_HOST}$1 [C]
RewriteRule ^origin\.([^/]+)(/.*)$ $2 [C,E=DEST_HOST:$1,PT]
RequestHeader set Host %{DEST_HOST}e env=DEST_HOST
# Do not apply any further rules to lsp., news. or signin. domains
RewriteCond %{HTTP_HOST} ^(lsp|signin|news|lab)\. [NC]
@RichardBronosky
RichardBronosky / flop.sh
Created March 28, 2012 17:06
move the last line of a file to the beginning IN PLACE
#!/usr/bin/env bash
file=$1
last=$(tail -n 1 $file)
# if you do this in a chmoded file you have to double the backslash as I have in the next line
sed -i -e '$d' -e "1 i\\
$last
" $file
# NOTE: for BSD sed (non-gnu, aka: OSX), use: -i ''
@RichardBronosky
RichardBronosky / cmg_medley_tv_lsn-after.xml
Created April 3, 2012 17:34
Akamai config for TV LSN, before addition of targetUrl magic.
<?xml version="1.0" encoding="UTF-8"?>
<configs xsi:noNamespaceSchemaLocation="../schemas/metadata.xsd" xmlns:cache="uri:akamai.com/metadata/cache/5.0" xmlns:edgeservices="uri:akamai.com/metadata/edgeservices/5.0" xmlns:xalan="http://xml.apache.org/xslt" xmlns:config="uri:akamai.com/metadata/config/5.0" xmlns:network="uri:akamai.com/metadata/network/5.0" xmlns:auth="uri:akamai.com/metadata/auth/5.0" xmlns:match="uri:akamai.com/metadata/match/5.0" xmlns:forward="uri:akamai.com/metadata/forward/5.0" xmlns:comment="uri:akamai.com/metadata/comment/5.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:akamai="uri:akamai.com/metadata/akamai/5.0" xmlns:security="uri:akamai.com/metadata/security/5.0" xmlns:reporting="uri:akamai.com/metadata/reporting/5.0" xmlns:edgecomputing="uri:akamai.com/metadata/edgecomputing/5.0" xmlns:assign="uri:akamai.com/metadata/assign/5.0">
<akamai:edge-config version="5.0">
<comment:advanced_defaults.begin/>
<comment:advanced_defaults.end/>
<comment:quickstart_sec