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
# -*- coding: utf-8 -*- | |
from collections import Iterator, Sequence, MutableSequence | |
class MyLinkedList(MutableSequence): | |
def __init__(self, *value): | |
''' | |
>>> l = MyLinkedList(1,2,3) |
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 | |
import sys,re | |
from optparse import OptionParser | |
def dec2bin(target): | |
result = [] | |
mask = 1 | |
shift = 0 | |
while mask <= target: |
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
fizzbuzz = lambda i: ("fizz" * (not i % 3) + "buzz" * (not i % 5)) or str(i) |
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 scala.collection.mutable.Queue | |
import scala.collection.mutable.ListBuffer | |
object RecursiveListing { | |
def main(args: Array[String]) { | |
val result = listing("/path/to/somewhere", Queue[String](), ListBuffer[String](), ".svn") | |
print(result.size) | |
} |
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 os | |
def recursive_listing(root, ignoredirs=None, ignorefiles=None): | |
result = [] | |
ignoredirs = ignoredirs or [] | |
ignorefiles = ignorefiles or [] | |
for dir, subdirs, fnames in os.walk(root): | |
if all(map(lambda d: d not in dir, ignoredirs)): | |
for name in fnames: | |
if all(map(lambda f: f not in name, ignorefiles)): |
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 CardComplete { | |
def main(args: Array[String]) { | |
val calcargs = inquiry() | |
//val calcargs = (1000000,15,525) | |
val start = System.currentTimeMillis | |
calculate(calcargs._1, calcargs._2, calcargs._3) | |
val end = System.currentTimeMillis | |
println("(in %s sec)".format((end - start) / 1000.0)) | |
} |
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/env python3 | |
"""git-svnでリビジョン番号かチケット番号でデプロイファイルの一覧を出力する | |
python gitsvn.py -d /path/to/repos -r 1 2 3 | |
python gitsvn.py -d /path/to/repos -t 1000 | |
""" | |
import re |
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 UIKit | |
import Foundation | |
class ChromeActivity: UIActivity { | |
private var url: NSURL? | |
static var isAvailable: Bool { | |
if let chromeURL = NSURL(string: "googlechrome-x-callback://") { | |
return UIApplication.sharedApplication().canOpenURL(chromeURL) |
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 Cocoa | |
let nc = NSDistributedNotificationCenter.defaultCenter() | |
nc.addObserverForName(nil, object: nil, queue: nil) { notification in | |
if let info = notification.userInfo where notification.name == "com.apple.iTunes.playerInfo" { | |
print(info) | |
} | |
} | |
NSRunLoop.mainRunLoop().run() |
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
func reverseGeocoding(location: CLLocation) { | |
let geocoder = CLGeocoder() | |
geocoder.reverseGeocodeLocation(location) { (placemarks, _) -> Void in | |
guard let placemarks = placemarks, !placemarks.isEmpty else { return } | |
if let placemark = placemarks.first { | |
log.debug(placemark) | |
} | |
} | |
/* |
OlderNewer