Skip to content

Instantly share code, notes, and snippets.

View jaymzcd's full-sized avatar
🍜
Maybe cooking some pad thai

jaymz campbell jaymzcd

🍜
Maybe cooking some pad thai
View GitHub Profile
@simonw
simonw / setting-up-sublime-text-2.txt
Created July 11, 2012 12:35
Setting up Sublime Text 2
First, install it from http://www.sublimetext.com/2
Next, install the package control extension from here:
http://wbond.net/sublime_packages/package_control
Installation instructions here: http://wbond.net/sublime_packages/package_control/installation
Restart Sublime, then hit Shift+Apple+P and search for "Package Control: Install Package"
@henrik
henrik / ocr.markdown
Created March 3, 2012 17:07
OCR on OS X with tesseract

Install ImageMagick for image conversion:

brew install imagemagick

Install tesseract for OCR:

brew install tesseract --all-languages

Or install without --all-languages and install them manually as needed.

@jaymzcd
jaymzcd / mod_table.py
Created January 24, 2012 23:43
use sage & pylab to plot a finite field's multiplication table for given f_size prime
#!/usr/bin/env sage
import pickle
from math import *
from pylab import *
"""
See: http://goo.gl/y2A78 for information
and how this was put together/concepted
@dnouri
dnouri / gist:1600408
Created January 12, 2012 13:06
Use pyquery to search zope.testbrowser contents
from zope.testbrowser.browser import Browser
def _zope_testbrowser_pyquery(self):
from pyquery import PyQuery
return PyQuery(self.contents)
Browser.pyquery = property(_zope_testbrowser_pyquery)
# This will allow you to do in your tests:
# >>> "Home" in browser.pyquery('#navigation').text()
@jaymzcd
jaymzcd / gist:1433676
Created December 5, 2011 14:06
log uptime via bash, plot results via pylab
# Bash command in a loop:
while true; do uptime >> /tmp/uptime.log; sleep 5; done
# Use awk to strip it out and grab 1min figure
awk -F\ '{print $9}' la.txt | tr "," " " > uptime_1min.csv
# In pylab (via:) run:
ipython --pyab
d = numpy.genfromtext('uptime_1min.csv')
plot(d)
@jaymzcd
jaymzcd / git_tips.md
Created September 22, 2011 09:42
Few git things for pushing remotes/setting up on centos/rhel

Git things internally

Installation of Git on RHEL/CentOS

first, and you probably wont really ever need this unless you're doing a bare bones install of a cent/rhel box, the webtactic repo maintains a decently up to date git install that will cleaning go onto such a box:

sudo rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
sudo yum install --enablerepo=webtatic git-all

Now you have working git!

@tomviner
tomviner / q1.py
Created September 16, 2011 08:47
Anagram of Palindrome
# -*- coding: utf-8 -*-
"""
1) A string is a palindrome if it reads the same from left-to-right as it does right-to-left.
e.g “nolemonnomelon”, “racecar” & “neveroddoreven” are all palindromes.
A string is an anagram of another string if it consists of exactly the same characters but in another order.
e.g The string “carrace” is an anagram of “racecar”.
Write a function `def is_anagram_of_palindrome(str):`
such that it returns True if the string str is an anagram of a palindrome, and otherwise returns False.
You may assume that str contains only lowercase characters a-z and is not empty.
e.g Given str = “carrace” the function should return True as it is an anagram of the palindrome “racecar”.
@jaymzcd
jaymzcd / mail.cfg
Created August 22, 2011 12:48
Logs into an smtp server using the data in the config and reads and sends HTML email
[global]
server: smtp.gmail.com
port: 587
user: jaymzcd@gmail.com
password: ???????
[message]
text: /tmp/email/plain.txt
html: /tmp/email/index.html
from: jaymzcd@gmail.com
@jaymzcd
jaymzcd / assign_file.py
Created July 13, 2011 11:23
Assign slugs and images based on a models fields - commands to use with a django shell
def assign_file_to_model(module, model_class=None, file_field='main_image', source_field='body', skip_existing=True, verbose=False):
""" We tend to have "main image" fields on models that hold a primary image used
across the sites for things like list pages and headers. Often on import of
existing data we have images mangled within copy or lists. """
import urllib2
from posixpath import basename
from BeautifulSoup import BeautifulSoup as Soup
from django.db import IntegrityError
@jaymzcd
jaymzcd / plugin.js
Created May 17, 2011 15:07
Filter table in HTML via JS on keyup
<script type="text/javascript">
/* Can't remember where I saw this but it's quite handy/cool for tables to do filtering without posts */
$(document).ready(function(){
//add index column with all content.
$(".filterable tr:has(td)").each(function(){
var t = $(this).text().toLowerCase(); //all row text
$("<td class='indexColumn'></td>")
.hide().text(t).appendTo(this);
});//each tr
$("#FilterTextBox").keyup(function(){