Skip to content

Instantly share code, notes, and snippets.

View sunu's full-sized avatar
🏠
Working from home

Tarashish Mishra sunu

🏠
Working from home
View GitHub Profile
@sunu
sunu / _formhelpers.html
Created December 17, 2012 06:24
Flask: Wtform helper
{% macro render_field(field) %}
<dt>{{ field.label }}
<dd>{{ field(**kwargs)|safe }}
{% if field.errors %}
<ul class=errors>
{% for error in field.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
# enable syntax completion
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
@sunu
sunu / gist:4336978
Created December 19, 2012 14:20
MoinMoin: mm crashes on GAE due to introduction of tempfiles in writing.py in whoosh https://bitbucket.org/mchaput/whoosh/commits/c9d30b92bd49843778b1c50cb91b2f912359e31c#chg-src/whoosh/writing.py
Traceback (most recent call last):
File "/home/sunu/moin/support/flask/app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "/home/sunu/moin/support/flask/app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/sunu/moin/support/flask/app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "/home/sunu/moin/support/flask/app.py", line 1344, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/sunu/moin/MoinMoin/apps/frontend/views.py", line 463, in modify_item
#!/usr/bin/env python
import os
import random
import time
import platform
snowflakes = {}
try:
# Windows Support
sunu: /home/sunu/opensource/oppia-django
(oppia-django)⟶ python manage.py test widget
Creating test database for alias 'default'...
...F...
======================================================================
FAIL: test_parameterized_widget (oppia.apps.widget.tests.WidgetUnitTests)
Test that parameterized widgets are correctly handled.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/sunu/opensource/oppia-django/oppia/apps/widget/tests.py", line 141, in test_parameterized_widget
diff --git a/lib/python2.7/site-packages/json_field/fields1.py b/json_field/fields.py
index dbf1c9d..3be8287 100644
--- a/lib/python2.7/site-packages/json_field/fields1.py
+++ b/json_field/fields.py
@@ -24,6 +24,41 @@ TIME_RE = re.compile(r'^\d{2}:\d{2}:\d{2}')
DATE_RE = re.compile(r'^\d{4}-\d{2}-\d{2}(?!T)')
DATETIME_RE = re.compile(r'^\d{4}-\d{2}-\d{2}T')
+
+class Converter():
diff --git a/lib/python2.7/site-packages/json_field/fields1.py b/json_field/fields.py
index dbf1c9d..f14d5ea 100644
--- a/lib/python2.7/site-packages/json_field/fields1.py
+++ b/json_field/fields.py
@@ -24,6 +24,55 @@ TIME_RE = re.compile(r'^\d{2}:\d{2}:\d{2}')
DATE_RE = re.compile(r'^\d{4}-\d{2}-\d{2}(?!T)')
DATETIME_RE = re.compile(r'^\d{4}-\d{2}-\d{2}T')
+
+class Converter():
#!/usr/bin/env python
### We must chdir() up one level.
import os
import os.path
import sys
THIS_FILE=os.path.abspath(__file__)
THIS_DIR=os.path.dirname(THIS_FILE)
UP_ONE_DIR=os.path.join(THIS_DIR, '..')
sys.path.append(UP_ONE_DIR)
# N is the range in which you find all primes
N = 10000
# initialize an array of flags
is_prime = [1 for num in xrange(N)]
is_prime[0] = 0 # this is because indexing starts at zero
is_prime[1] = 0 # one is not a prime, but don't mark all of its multiples!
def set_prime(num):
"num is a prime; set all of its multiples in is_prime to zero"
# coding: utf-8
#
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#