Skip to content

Instantly share code, notes, and snippets.

🐹
Just a mouse on a wheel running fast to charge his laptop

Frank Wiles frankwiles

🐹
Just a mouse on a wheel running fast to charge his laptop
Block or report user

Report or block frankwiles

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@frankwiles
frankwiles / Usage in Ipython
Created Jul 12, 2019
Keeping Django Models Ordered Example
View Usage in Ipython
from tasks.models import *
t = Task.objects.create(name="Test1")
s1 = Step.objects.create(task=t, name="Testing1")
s2 = Step.objects.create(task=t, name="Testing2")
s3 = Step.objects.create(task=t, name="Testing3")
s4 = Step.objects.create(task=t, name="Testing4")
# Show the existing numbers/structure
View keybase.md

Keybase proof

I hereby claim:

  • I am frankwiles on github.
  • I am frankwiles (https://keybase.io/frankwiles) on keybase.
  • I have a public key whose fingerprint is 782D A1E3 A547 E219 FD44 C7A0 BDE8 83DD D590 08CA

To claim this, I am signing this object:

View logbook-file-example.py
from logbook import Logger, FileHandler
FileHandler('./output.log').push_application()
log = Logger('my-example-logger')
log.info("Testing")
# Output in ./output.log
# [2016-05-19 20:53:53.095826] INFO: my-example-logger: Testing
@frankwiles
frankwiles / blocks.py
Created May 17, 2015
Code and Markdown blocks for Wagtail 1.0 StreamField
View blocks.py
from django.utils.safestring import mark_safe
from markdown import markdown
from pygments import highlight
from pygments.formatters import get_formatter_by_name
from pygments.lexers import get_lexer_by_name
from wagtail.wagtailcore import blocks
class CodeBlock(blocks.StructBlock):
@frankwiles
frankwiles / gist:5101648
Created Mar 6, 2013
AWS CORS configuration
View gist:5101648
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
@frankwiles
frankwiles / gist:4024500
Created Nov 6, 2012
Rebuild a broken Python virtualenv on heroku
View gist:4024500
# Execute these commands in order to rebuild a virtualenv from scratch
$ heroku labs:enable user-env-compile
$ heroku config:set CLEAN_VIRTUALENV=yes
$ heroku config:set VIRTUALENV_DIRS=.heroku/venv
$ git push heroku master
$ heroku config:unset CLEAN_VIRTUALENV
$ heroku config:unset VIRTUALENV_DIRS
$ heroku labs:disable user-env-compile
@frankwiles
frankwiles / first-five.sql
Created Sep 14, 2012
Index on first 5 characters of a column
View first-five.sql
CREATE TABLE song (
title varchar(20),
);
CREATE INDEX firstfive_idx ON song WHERE substring(title, 0, 6);
SELECT * FROM song WHERE substring(title, 0, 6) = 'foobar1' AND title='foobar1bazbazwheeheee!';
@frankwiles
frankwiles / gist:3531321
Created Aug 30, 2012
vim trailing whitespace
View gist:3531321
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
@frankwiles
frankwiles / gist:2051463
Created Mar 16, 2012
RFC valid E-mail address regular expression
View gist:2051463
[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\
xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xf
f\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\x
ff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015
"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\
xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80
-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*
)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\
\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\
x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x8
@frankwiles
frankwiles / chris.py
Created Aug 29, 2011
Awk is horrible, use Python
View chris.py
#!/usr/bin/env python
import re
import fileinput
good_match = re.compile(r'sip:\+?[0-9]+@')
for line in fileinput.input():
parts = line.split('|')
You can’t perform that action at this time.