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 xml.etree.ElementTree import Element, SubElement | |
def dict_to_xml(data, root_name='events'): | |
# a list of dictionaries, converted into xml. | |
root = Element(root_name) | |
def _make_xml(i_root, data_dict): | |
for field, val in data_dict.iteritems(): | |
if isinstance(val, dict): | |
i_data = SubElement(i_root, field) |
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
function getSomethingMagicalFromRemote() { | |
var obj = cache.get('obj-key'); | |
if (typeof obj =!="undefined") | |
return obj | |
} | |
// Otherwise init ajax call | |
$.ajax({ .... }) | |
} |
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
function InvalidFieldException(message) { | |
this.message = (message || ""); | |
this.name = 'InvalidFieldException'; | |
this.stack = (new Error()).stack; | |
} | |
InvalidFieldException.prototype = Error.prototype; | |
// throw new InvalidFieldException("...") |
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 nose | |
from nose.plugins.base import Plugin | |
class IntegrationSelector(Plugin): | |
def options(self, parser, env): | |
parser.add_option("--exclude-integration", | |
dest="integration", action="store_false", | |
default=None) | |
parser.add_option("--integration", | |
dest="integration", action="store_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
$el = $("my-input"); | |
var checkLength = function(input) { if (input.length > 40) { return true } return false; } | |
var validateEmailAddress = function(input) { return ... } | |
var rules = [ | |
checkLength, | |
validateEmailAddress | |
]; |
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
{"id": "35921", "href": "https://rest.gadventures.com/promotions/35921", "name": "Last Minute 10% off CRPJ141102", "promotion_code": "LM10CRPJ141102", "discount_amount": null, "discount_percent": "10.00", "commission_rate": null, "min_travellers": 0, "sale_start_date": "2014-09-02", "sale_finish_date": "2014-10-02", "product_start_date": null, "product_finish_date": null, "terms_and_conditions": null, "currencies": ["CAD", "CHF", "EUR", "AUD", "USD", "GBP", "NZD", "ZAR"], "room_codes": null, "flags": ["APPLY_AUTOMATICALLY"], "products": [{"id": "506398", "href": "https://rest.gadventures.com/departures/506398", "type": "departures", "sub_type": "Tour"}]} |
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
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6WH/85Y1ShcZWCq29dLpapwe2q7g3pSScybaJuYGO0gxfCDWEYr8+kadw5GB7vIQJvUcK+XLgurWRtjrVYMIfuWsHW1VG8Aq2GEh3UiWbew8l07xcAQTRhdWboZnYszf+72jkK72do42sp5GblQKp6iFtml6sEgL2BtpJojdkrs8j8wocAmFAgdYKmkcPTGRhxCP7actWd7rNyn0Tc4GW5kQLyzajQoEMLjtzVNniXqIue2/iydoQCCKLGGsWLQ0VQCXzb++30atda4dzdGy0tQBMV4osYcXKNSuroCK29v8vLhtpVrfAY9k3IAxJsyu0Qd7Wr931F5Rqlso0gNKwQ== bartekc@dhcp147.gap.ca |
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
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var request = require('superagent'), | |
_ = require('lodash') | |
function collectResponse(err, resp) { | |
var results = document.getElementById('results') | |
_.each(resp.body.results, function(item) { | |
var child = document.createElement("div") | |
child.innerHTML = item.product_line + " -- " + item.departures_start_date |
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
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var request = require('superagent'), | |
_ = require('lodash') | |
function collectResponse(err, resp) { | |
var results = document.getElementById('results') | |
_.each(resp.body.results, function(item) { | |
var child = document.createElement("div") | |
child.innerHTML = item.product_line + " -- " + item.departures_start_date |
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
# section1.1.7 from SICP written in python .. was just making sure I understood how it all worked. | |
def square(x): | |
return x * x | |
def sqrt_iter(guess, x): | |
if good_enough(guess, x): | |
return guess | |
else: | |
return sqrt_iter(improve(guess, x), x) |
OlderNewer