Skip to content

Instantly share code, notes, and snippets.

@paulosman
paulosman / app.py
Created October 14, 2020 16:51
github stats
import os
import datetime
import libhoney
from github import Github
g = Github(os.getenv('GH_ACCESS_TOKEN'))
libhoney.init(
writekey=os.getenv('HONEYCOMB_WRITE_KEY'),
dataset=os.getenv('HONEYCOMB_DATASET'),
@paulosman
paulosman / client.py
Created November 9, 2013 01:17
SoundCloud API client that uses a circuit breaker
import pybreaker
import soundcloud
import requests
sc_breaker = pybreaker.CircuitBreaker(fail_max=3, reset_timeout=30)
class LogListener(pybreaker.CircuitBreakerListener):
def before_call(self, cb, func, *args, **kwargs):
print "Before calling %s" % func
@paulosman
paulosman / password_auth.php
Created January 26, 2013 22:08
Using the password auth flow with the PHP SDK
<?php
require_once 'Services/Soundcloud.php';
$client = new Services_Soundcloud('A_VALID_CLIENT_ID', 'A_VALID_CLIENT_SECRET', 'REDIRECT_URI');
// manually construct URL-encoded request body. Note that if you use an email address
// as the username, you'll need to pass it through urlencode().
$options = "grant_type=password&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&username=<username>&password=<password>";
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)
@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'
});
@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 / 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 / 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 / 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 / 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