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
String get docPath => '${parent.docPath}/${key}'; | |
@property | |
def docPath(self): | |
return '%s/%s' % (self.parent.docPath, self.key) |
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
# Goal, to make it easy to define common get/set operations on wrapper classes. | |
# The implementation has no state of itself, and is constantly proxying the | |
# "raw" data in the background. | |
# | |
# A descriptor is used to automate the process of creating properties. It would | |
# be extremely easy to generate the File code. | |
class ApiAttribute(object): | |
def __init__(self, name, default=None, wrapper=None, read_only=False): |
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
main = print $ sum $ filter isEven $ takeWhile (\x -> x < 4000000) fiblist | |
where fiblist = 0 : 1 : zipWith (+) fiblist (tail fiblist) |
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
module Main where | |
digits x = digits' $ reverse $ show x | |
where | |
digits' [] = [] | |
digits' (x:xs) = (read [x]:digits' xs) | |
x2alt [] = [] | |
x2alt (x:y:xs) = (x*2 : y : x2alt xs) | |
x2alt (x:xs) = (x*2 : x2alt xs) |
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
err = check_args({'lat', 'long'}) | |
if err is not None: | |
return err |
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
# The following 2 lines should never be seen together. Yet here they are. | |
import httplib2 | |
import requests |
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
# The following 2 lines should never be seen together. Yet here they are. | |
import httplib2 | |
import requests | |
class CredentialsAuthorizer(requests.auth.AuthBase): | |
"""Uses oauth2client credentials to authorize requests requests.""" | |
#: How many times we will retry a request that might need refreshing | |
retries = 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
class Monad m where | |
return :: a -> m a | |
(>>=) :: m a -> (a -> m b) -> m b | |
(>>) :: m a -> m b -> m b | |
x >> y = x >>= \_ -> y | |
fail :: String -> m a | |
fail msg = error msg |
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 gcloud import dns | |
>>> z = dns.create_zone('my-test-zone', PROJECT, EMAIL, PRIVATE_KEY) | |
>>> z | |
<Zone:my-test-zone> | |
>>> z.add_record('aliafshar.org.', 'A', 60, '1.2.3.4') | |
<Change:...> |
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 apiclient import errors | |
# ... | |
# XXX Auth | |
# XXX Build a service | |
## | |
# Addition of records | |
# | |
BODY = { | |
'additions' : [{ |
OlderNewer