Skip to content

Instantly share code, notes, and snippets.

View redspider's full-sized avatar

Richard Clark redspider

  • Red Spider Limited
  • Wellington, New Zealand
View GitHub Profile
@redspider
redspider / piss_me_off.txt
Created November 18, 2010 00:03
Things that have pissed me off about sendgrid so far
1. Pricing page does not actually say you're being charged per month. I assumed, but still.
2. Signup page asks for pointlessly unnecessary details. What do you care what my address is?
3. Signup page asks for a Username (in email format). What is that? WHAT IS THAT? HOW DID IT GET PAST YOUR UI QA?
4. After signing up, I received no less than 3 emails. A registration confirmation, an automatic payment notification, and a payment confirmation. Buried in one of these is a link I have to click to confirm my email address works, but nowhere on the dashboard does it say that (I clicked around on the dash for ages before I looked at my email)
5. When I clicked the link to confirm my email address works, the only message I got was "You have already logged in"
6. All the documentation is in a vanilla mediawiki. Seriously unprofessional.
7. The issues system is a third-party provider, that requires that I log in all over again. Tell me, how are you going to figure out which real account my twitter account relates to s
@redspider
redspider / model_session.php
Created December 7, 2010 05:12
Model session example rewrite
<?php
/* Model class for Sessions
A session represents an independent teaching segment. The following rules
definitely apply:
1. A session has one single owner, the expert.
2. A session has the following properties associated directly with it:
2.1. A title, indicating the topic of the segment.
2.2. A level rating, indicating the difficulty
#!/bin/bash
cd /my/virtual/env
./bin/activate
exec bin/python $*
word_count = dict()
word_file = open('text.txt',r)
for line in word_file:
for word in line.split(' '):
word_count[word] = word_count.get(word,0)+1
words = word_count.keys()
words.sort(lambda a,b: cmp(word_count[a],word_count[b]))
print words.join('\n')
var sys = require("sys");
var class = function () {
var V = 0;
var method = function (i) {
V+=i;
}
}
>>> import bcrypt
>>> password = "kitten"
>>> salt = bcrypt.gensalt()
>>> salt
'$2a$12$yqUmgo2jguH0dsoH5m6JWe'
>>> hashed = bcrypt.hashpw(password, salt)
>>> hashed
'$2a$12$yqUmgo2jguH0dsoH5m6JWeFYBfSqGjVQ26llCDhg/tYmpC14EUJyS'
>>> hashed[:29] == salt
True
@redspider
redspider / perf.js
Created January 14, 2011 02:13
Performance test for object creation
/**
* Performance test for object creation
*
* See: http://javascriptweblog.wordpress.com/2010/03/16/five-ways-to-create-objects/
*/
// 4. Simple constructor for new
var TInScope = function () {
this.test_prop = "4. Simple constructor for new";
def normalise(s):
s = s.replace(r'RT @[^ ]+','')
s = s.lower()
s = s.strip()
return md5(s).hexdigest()
This review set is targeted at small-team PHP developers, and is intended to act in concert with an SPOJ code review.
Databases
When should an index be used?
What is the difference between varchar and text (mysql, postgres)
Define ACID
Describe an SQL injection and how to defend against it
How would you store a password in a database?
The app has a need for a search page, how would you search for a keyword?
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPForbidden
@view_config(name='login.login', renderer='login/login.jinja2', context=HTTPForbidden)
def login(request):
return {}
@view_config(route_name='login.test', renderer='login/login.jinja2')
def login_test(request):
return {}