Skip to content

Instantly share code, notes, and snippets.

from medley.extensions.models.story import MedleyStory
for story in MedleyStory.objects.all():
story.reindex(using='solr4_aws')
[{u'canonical_url': u'www.local.cmgsharedcontent.com:8000/gallery/news/national/photos-mudslide-block-both-directions-roadway-near/gCJnS/',
u'categories': [u'/News/National', u'/News', u'/News/Disasters'],
u'content_created': u'2014-03-22T19:57:12Z',
u'content_modified': datetime.datetime(2014, 3, 27, 7, 9, 4, 404000, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>),
u'details': {u'django_ct': u'photos.medleygallery',
u'django_id': u'118454',
u'id': u'photos.medleygallery.118454',
u'indexed_date': datetime.datetime(2014, 8, 22, 16, 20, 49, 177000, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>),
u'page_title': u'PHOTOS: Deadly mudslide in Washington'},
u'first_created': u'2014-03-22T19:57:12Z',
'''
Project Euler problem 477
url: https://projecteuler.net/problem=477
'''
import sys
def sequence_gen(n):
ret = 0
i = 0
while i < n:
def sequence_gen(n):
ret = 0
i = 0
while i < n:
yield ret
ret = ((ret**2) + 45) % 1000000007
i += 1
def fbgen(n):
for i in n:
if i % 15 == 0: yield 'Fizzbuzz'
elif i % 3 == 0: yield 'Fizz'
elif i % 5 == 0: yield 'Buzz'
else: yield i
if __name__ == '__main__':
for fb in fbgen(range(1,100)):
print fb
def _available_moves(game_state):
#return a list of available moves on the board.
return [i for i, j in enumerate(game_state) if j != 'X' and j != 'O']
function sortByName() {
return function(x, y) {
return ((x.fullname == y.fullname) ? 0 : ((x.fullname > y.fullname) ? 1 : -1 ));
}
}
import sys
if len(sys.argv) == 3:
names = sys.argv[1].split('.')
name_space = '.'.join(names[0:-1])
caller = names[-2]
class_name = names[-1]
method_file = sys.argv[2]
#import from names as strings
test_lib = __import__(name_space)
methods = __import__(method_file)
@dnase
dnase / gist:10748013
Last active August 29, 2015 13:59
Fun with data parsing!
###########################################################
# How many ig'nant people have named their child some #
# version of "Khaleesi" (which is just an honorific, #
# similar to "queen" - her name is Daenerys Targaryen) #
###########################################################
#SPOILER ALERT: It's over 900.
#Commands:
@dnase
dnase / gist:7485105
Last active December 28, 2015 10:19
#define a fibonacci enumerator
fibonacci = Enumerator.new do |yielder|
a = b = 1
loop do
yielder << a
a, b = b, a + b
end
end
#curry cache to infinity