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 MySQLdb | |
import time | |
def get_connection(): | |
return MySQLdb.connect(host='localhost', | |
user='your_username', | |
passwd='your_password', | |
db='your_database') | |
def query(conn, sql): |
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
python3 /Users/cop/Downloads/mypy-master/scripts/mypy --use-python-path core/api.py ()(master⚡) | |
/Users/cop/.pyenv/versions/3.5.0/lib/python3.5/importlib/util.py:3: note: In module imported here, | |
/Users/cop/.pyenv/versions/3.5.0/lib/python3.5/site-packages/django/utils/module_loading.py:67: note: ... from here, | |
/Users/cop/.pyenv/versions/3.5.0/lib/python3.5/site-packages/django/apps/config.py:6: note: ... from here, | |
/Users/cop/.pyenv/versions/3.5.0/lib/python3.5/site-packages/django/apps/__init__.py:1: note: ... from here, | |
/Users/cop/.pyenv/versions/3.5.0/lib/python3.5/site-packages/django/__init__.py:13: note: ... from here, | |
core/models.py:1: note: ... from here, | |
core/api.py:8: note: ... from here: | |
/Users/cop/.pyenv/versions/3.5.0/lib/python3.5/importlib/_bootstrap.py:1140: error: No module named '_frozen_importlib_external' | |
/Users/cop/.pyenv/versions/3.5.0/lib/python3.5/importlib |
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 Test1: | |
def create(self, a:int, b:str) -> None: | |
print("hello") | |
class Test2: | |
def create(self): | |
""" No error or warning generated even if first argument is a string here""" | |
a = "abc" # should've complained here! | |
b = "def" | |
Test1().create(a, b) |
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 copy_table(self, table_name, source_conn, target_conn): | |
""" copies all records from table_name from source to target db """ | |
scursor = source_conn.cursor() | |
tcursor = target_conn.cursor() | |
scursor.execute("SELECT * from "+table_name) | |
desc = scursor.description | |
columns = ",".join([col[0] for col in desc]) |
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
form_widget = forms.ChoiceField(label=disp_entity.label, widget=forms.CheckboxSelectMultiple(), required=disp_entity.is_required, choices=choices) | |
#We also created some custom widgets to display custom arbitrary HTML: | |
form_widget = forms.CharField(label='',widget=CustomHTMLWidget(attrs={'html':html}), required=False) | |
#Next we define a dynamic Django form by subclassing the original django.Forms then assign our custom display fields to this form. | |
class DynamicForm(forms.Form): | |
def __init__(self, display_fields): |
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
$(document).ready(function() { | |
$("#{{attrs.rule_webparam}}_li").hide(); | |
{% ifequal attrs.init_state "visible" %} | |
$("#{{attrs.toggle}}_li").show(); | |
$("#{{attrs.toggle}}_li").css("cssText","display:block !important;"); | |
{% else %} | |
$("#{{attrs.toggle}}_li").hide(); | |
$("#{{attrs.toggle}}_li").css("cssText","display:none !important;"); | |
{% endifequal %} |