Skip to content

Instantly share code, notes, and snippets.

@paulosman
paulosman / badgelab.json
Created November 25, 2010 22:00
Strawman JSON schema for federated badge system
{
"schema": "https://example.com/badge/1",
"mustSupport": [],
"title": "School of Webcraft Responder",
"description": "This badge is in recognition of the helpful responses you have provided to fellow members of the School of Webcraft.",
"timestamp": "1288882617",
"expires": "8462729988",
"badgeURL": "https://badger.mozilla.com/badges/asdf1234",
"issuer": "https://badger.mozilla.com/",
"issuerName": "P2PU School of Webcraft",
@paulosman
paulosman / .emacs
Created April 19, 2011 18:50
Shell script that runs pyflakes and pep8
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pychecker.sh" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
@paulosman
paulosman / gist:974470
Created May 16, 2011 13:48
Threaded runserver for Django
#!/usr/bin/env python
#
# Mostly taken from:
# http://nedbatchelder.com/blog/201103/quick_and_dirty_multithreaded_django_dev_server.html
import os
import site
from django.core.management import execute_manager
@paulosman
paulosman / home_controller.rb
Created February 10, 2012 22:01
Problem posting multipart form data to Rails app.
# Rails 3.0.3 Controller. Just return the parameters as a string.
class HomeController < ApplicationController
protect_from_forgery :except => :upload
def upload
render :text => params.to_s
end
end
@paulosman
paulosman / main.py
Created March 6, 2012 16:30
Python SDK Example
import soundcloud
# Create a new client that uses the user credentials oauth flow
client = soundcloud.Client(client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET',
username='YOUR_USERNAME',
password='YOUR_PASSWORD')
# print the username of the authorized user
print client.get('/me').username
@paulosman
paulosman / bottleapp.py
Created March 27, 2012 20:54
Quick untested bottle example
import soundcloud
from bottle import get, post, redirect, request
def soundcloud_client():
return soundcloud.Client(
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET',
redirect_uri='http://localhost:3000/soundcloud/connected'
)
@paulosman
paulosman / set_artwork.php
Created September 7, 2012 03:56
Create set with artwork - PHP SDK Example
<?php
require_once 'Services/Soundcloud.php';
$client = new Services_Soundcloud('client_id', 'client_secret');
$client->setAccessToken('access_token');
$playlist = array(
'playlist[title]' => 'My Playlist',
'playlist[artwork_data]' => '@/path/to/file.jpg'
@paulosman
paulosman / recruiter.txt
Created September 22, 2012 03:02
Recruiter Reply
Hi [Name],
Thanks for reaching out. It sounds like it could be an interesting position, but I'm very happy with my current position at SoundCloud.
Best of luck finding the right candidate!
Cheers,
Paul
@paulosman
paulosman / index.html
Created December 18, 2012 22:51
JavaScript SDK streaming
<!doctype html>
<html>
<head>
<script src="http://connect.soundcloud.com/sdk.js"></script>
<script>
window.onload = function() {
SC.initialize({
client_id: 'YOUR_CLIENT_ID'
});
from django.db import models
class Author(models.Model):
name = models.CharField(max_length=255)
class Book(models.Model):
title = models.CharField(max_length=255)
author = models.ForeignKey(Author)