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
exclusive_boundry = 1000 | |
multiples = [3, 5] | |
sum = 0 | |
for candidate in range(exclusive_boundry): | |
if 0 in [candidate % multiple for multiple in multiples]: | |
sum += candidate | |
print sum |
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 selenium.webdriver.firefox.webdriver import WebDriver | |
from selenium.webdriver.common.action_chains import ActionChains | |
import time, unittest | |
def is_alert_present(wd): | |
try: | |
wd.switch_to_alert().text | |
return True | |
except: | |
return 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
Title: Deprecate tap2deb and tap2rpm | |
Text: | |
tab2deb and tap2rpm are command-line utilities that create a shim over a .tap file, allowing it to be installed as an OS package (.deb or .rpm respectively). | |
Currently, a test (twisted.scripts.test.test_tap2deb.TestTap2DEB.test_basicOperation) fails in some situations, apparently because these utilities don't work properly in some specific OS configurations. For example, see https://twistedmatrix.com/trac/ticket/6920 (closed for other reasons). | |
It is not immediately obvious how widespread their use is, but exarkun advises deprecation. Another developer will need to weigh-in with a deprecation justification is one is to be provided. |
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
''' | |
Mezzanine lets you inject fields on its own stock models using the EXTRA_MODEL_FIELDS setting. | |
However, as the Mezzanine docs point out (http://mezzanine.jupo.org/docs/model-customization.html#field-injection-caveats), there are some "caveats" regarding migrations. | |
Specifically, the migrations need to be placed in a local app even though they're applied to the Mezzanine models. | |
What's the proper way to do this in Django 1.7? I have a solution below that works, but it's obviously ugly. | |
''' |
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 Incident(models.Model): | |
owner = models.ForeignKey(User) | |
class IncidentData(models.Model): | |
key = models.CharField(max_length=255) | |
value = models.CharField(max_length=255) | |
incident = models.ForeignKey(Incident) | |
## Or, if you want to have manager-level control for the IncidentData: |
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 hendrix.contrib.async import do_async | |
def my_view(request): | |
# blah blah blah, Django stuff | |
with do_async(pubsub_id) as reporter: | |
for long_thing in long_things: | |
result_of_long_thing = long_thing() |
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 hendrix.contrib.async import do_async | |
def my_view(request): | |
# blah blah blah, Django stuff | |
@do_async.after_response(pubsub_id): | |
def function_name_that_becomes_thread_name(reporter): | |
for long_thing in long_things: |
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
def tell_me_the_answer(question): | |
if question.determine_truth: | |
return True | |
if not question.determine_truth: | |
return False | |
## Conceptually, why not? | |
if question.dont_know_yet: |
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
# Which is more DRY.. | |
# Option 1 | |
x = 1 | |
y = '1' | |
z = 1.0 | |
# Or option 2 | |
x = 1 | |
y = str(x) |
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 API: | |
class BirthLine(PhoneLine): | |
greeting = "Thanks for calling Chelsea and Justin's birth information line." | |
disposition = [ConferenceHoldingPattern()] | |
features = [BirthCallBlast] | |
nobody_home = Voicemail |
OlderNewer