This file contains hidden or 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 sys | |
| def e(a, b, px, py, d=0): | |
| print(" " * d, f"e({a}, {b}, {px[1]}, {py[1]})") | |
| if b == 0: | |
| px[0] = 1 | |
| py[0] = 0 | |
| print(" " * d, f"{px[1]} <- 1, {py[1]} <- 0") |
This file contains hidden or 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 colorsys | |
| print "<style>" | |
| for i in xrange(30): | |
| h = 1.0 / 10 * (i % 10) | |
| if i / 10 == 0: | |
| s = 0.12 | |
| v = 1.0 | |
| elif i / 10 == 1: |
This file contains hidden or 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 logging | |
| def main(): | |
| class Filter(object): | |
| def filter(self, record): | |
| msg = record.getMessage() | |
| a = msg.startswith("Calling ") and msg.endswith(':Basic.GetEmpty"') | |
| b = msg.startswith("Processing ") and msg.endswith(":Basic.GetEmpty") | |
| return not (a or b) | |
| logging.basicConfig(level= logging.DEBUG) |
This file contains hidden or 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 EvernoteOAuthHandler extends Controller { | |
| val KEY = ConsumerKey("xxx", "yyyzzz") | |
| val EVERNOTE = OAuth(ServiceInfo( | |
| "https://sandbox.evernote.com/oauth", | |
| "https://sandbox.evernote.com/oauth", | |
| "https://sandbox.evernote.com/OAuth.action", | |
| KEY)) | |
| def authenticate(callbackUrl: String) = Action { implicit request => |
This file contains hidden or 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 datetime import datetime; (lambda dt: (lambda y, m, d, *_: "%2d%s%2d" % (2099 - y, "ABCDEFGHIJKL"[12 - m], 99 - d))(*dt.timetuple()))(datetime.today()) |
This file contains hidden or 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 bottle import route, run, default_app | |
| @route("/") | |
| def index(): | |
| return "Hello" | |
| if __name__ == "main": | |
| run() |
This file contains hidden or 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
| val mongo_article = mongo_articles.findOne(MongoDBObject("_id" -> new ObjectId(vector(i)._1))).getOrElse(null) | |
| println(mongo_article.getAs[String]("title").getOrElse(null)) |
This file contains hidden or 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 django.conf import settings | |
| from authhacks import username_length | |
| USERNAME_MAXLENGTH = getattr(settings, 'USERNAME_MAXLENGTH', 75) | |
| username_length.hack_models(USERNAME_MAXLENGTH) | |
| username_length.hack_forms(USERNAME_MAXLENGTH) |
This file contains hidden or 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
| <interface type='bridge'> | |
| <mac address='52:54:00:39:0e:db'/> | |
| <source bridge='br0'/> | |
| <model type='virtio'/> | |
| <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> | |
| </interface> |
This file contains hidden or 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 argparse | |
| import sys | |
| parser = argparse.ArgumentParser() | |
| g = parser.add_mutually_exclusive_group(required= True) | |
| g.add_argument('--a', action= 'store_const', const='a', dest= 'subcommand') | |
| g.add_argument('--b', action= 'store_const', const='b', dest= 'subcommand') | |
| parser.add_argument('bar', nargs= '*') | |
| print parser.parse_args(sys.argv[1:]) |
NewerOlder