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
""" | |
Python Script Manager | |
allows user to select a python (.py) script from directory and run it. | |
the script may be selected from a list and run in a command window or opened using a text editor | |
user can navigate folders in ROOT_DIRECTORY | |
TO DO: | |
add 'troubleshoot' to open python intepreter in a separate cmd window |
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
""" | |
Test GUI | |
""" | |
from Tkinter import * | |
import os | |
import subprocess | |
def main(): | |
""" starts up GUI """ |
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 __future__ import print_function # Ignore this | |
# Example 1 - Function with argument | |
def say_hello(name): | |
# Prints 'Hello {name}!' to the screen | |
print("Hello {}!".format(name)) | |
# We 'invoke' / 'call' a function using the ()s | |
say_hello('Nick') |
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 say_hello(): | |
print("Hello") | |
def say_bye(): | |
print("Bye") | |
def say_sup(): | |
print("Sup?") | |
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
# This works fine | |
print("hey " + "you!") | |
# This causes an error because "hey" is a string and 1 is an integer | |
print("hey " + 1) | |
foo = "hey " + 1 # This is an error too | |
print(foo) | |
# This works fine - the argument is an integer |
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 hashlib import sha256 | |
def get_sha256_hash(text): | |
text_bytes = text.encode('utf-8') | |
text_hash = sha256(text_bytes) | |
return text_hash.hexdigest() | |
password_1 = 'hunter2' | |
password_2 = 'hunter2' |
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 hashlib | |
user_password = 'hunter12' | |
database_password = '6618f892842dcbc32f7968cc8f73b5b0065ec04e' | |
salt = '#&@#DH@HDHUUS' | |
user_password_hashed = hashlib.sha1(user_password + salt).hexdigest() | |
print(user_password_hashed == user_password_hashed) |
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 { Component } from 'react'; | |
const { AtomicBlockUtils, EditorState, SelectionState, Modifier } = window.DraftJS | |
// The source gathers data for new entities that are being added in the Draftail editor | |
// It is invoked only when an new embed is inserted by the user | |
export class TextSource extends Component { | |
componentDidMount() { | |
const { editorState, entityType, onComplete } = this.props; |
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
# models.py | |
from wagtail.core.fields import RichTextField | |
from wagtail.core.models import Page | |
class MyModel(Page): | |
# ... | |
body = RichTextField(features=[ | |
# ... | |
'subscript', | |
'superscript', |
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 ArticlePage(Page): | |
pass | |
class SectionPage(Page): | |
# ... | |
def route(self, request, path_components): | |
""" | |
Perform ORM optimisations on ArticlePage to speed up article load times | |
""" | |
try: |
OlderNewer