This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.URL | |
import javax.sound.sampled.{AudioSystem, LineListener, LineEvent} | |
import scala.concurrent.{Promise, Future, Await} | |
import scala.concurrent.duration.Duration | |
object PlayAudio extends App { | |
val f = playUrl( | |
new URL("http://www.wavsource.com/snds_2014-05-05_4169601282614752/movies/airplane/wrong_week4.wav") | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.{URL, InetSocketAddress} | |
import javax.sound.sampled.{AudioSystem, LineListener, LineEvent} | |
import scala.concurrent.{Promise, Future, Await} | |
import scala.concurrent.duration.Duration | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import akkasmpp.actors.{SmppClient, SmppClientConfig} | |
import akkasmpp.protocol.{Pdu, BindTransceiverResp, CommandStatus, COctetString, DeliverSm, DeliverSmResp} | |
import akka.actor.ActorSystem | |
import akka.pattern.ask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A command ID for SMPP | |
*/ | |
trait FieldHelpers { | |
val className = getClass.getName.dropRight(1) | |
val missingLabel = "unknown" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for scope in path_scopes: | |
filter_constraints = cgi.parse_qs(scope.params.get('params', '')) | |
filter_keys = set(request.args.keys()) & set(filter_constraints.keys()) | |
def arg_satisfies_filter(f): | |
return set(request.args[f]).issubset(set(filter_constraints[f])) | |
if all(arg_satisfies_filter(f) for f in filter_keys): | |
# if for every parameter, the values are a subset of allowed params, we good! | |
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
requests uses a singleton AuthManager, which when used with gevent's monkey patching | |
(or presumably, the threading module) can be set by one thread, and read by another. | |
The AuthManager maps urls to credentials which assumes for any url you will always | |
request it with the same credentials. This turned out to be false for us, and thus, | |
the bug. Here's code to reliably reproduce it. | |
""" | |
import base64 | |
import gevent.monkey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
import flask | |
from gevent.pywsgi import WSGIServer | |
app = Flask(__name__) | |
app.debug = True | |
color = 'green' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
from wsgiref.simple_server import make_server | |
from mylongtask import progress_status, run_task | |
# simple wsgi app; could replace with one from flask with templates, | |
# url dispatching, etc. | |
def simple_app(environ, start_response): | |
start_response('200 OK', [('Content-Type', 'text/plain')]) | |
return [str(progress_status)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -u | |
from twilio.rest import TwilioRestClient | |
import sys | |
import time | |
import threading | |
import argparse | |
total = 0 | |
class Reporter(threading.Thread): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* SCALA!! | |
*/ | |
object DisjointGraphs extends App { | |
val disjoints = findThem(List((1,2), (2,3), (5,6), (7,8), (1,8))) | |
println(disjoints) | |
def findThem(edges: List[(Int, Int)]) = { | |
val initial = List[Set[Int]]() // empty list of int sets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Test extends App { | |
trait BitPrinter[B <: BitDescription] { | |
def printBits(value: Long): (List[String], Long) | |
} | |
trait BitDescription | |
trait BitField extends BitDescription |
OlderNewer