Skip to content

Instantly share code, notes, and snippets.

trungly /
Last active Feb 6, 2021
A simple Python HTTP server that supports a GET that echoes some request data and a POST that reads a request body, parses it as JSON and responds with part of the data
from BaseHTTPServer import BaseHTTPRequestHandler
import urlparse, json
class GetHandler(BaseHTTPRequestHandler):
def do_GET(self):
parsed_path = urlparse.urlparse(self.path)
message = '\n'.join([
'client_address=%s (%s)' % (self.client_address,
atenni /
Last active Jul 5, 2021
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.


To return the first file from a gist:[gist_user]/[gist_id]/raw/

To get a file from multi–file gist:[gist_user]/[gist_id]/raw/[file_name]

davidandrzej / regex-unapply.scala
Created Jun 22, 2012
Scala regex unapply magic
View regex-unapply.scala
scala> val myRegex = """Foo=([0-9]+) Bar=([A-Z]+)""".r
myRegex: scala.util.matching.Regex = Foo=([0-9]+) Bar=([A-Z]+)
scala> "Foo=123 Bar=ABC" match {
| case myRegex(foo, bar) =>
| println("foobar looks like %s-%s".format(foo,bar))
| case _ => println("not a match")
| }
foobar looks like 123-ABC