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
// sleep / wait function | |
function sleep(milliseconds) { | |
var start = new Date().getTime(); | |
for (var i = 0; i < 1e7; i++) { | |
if ((new Date().getTime() - start) > milliseconds) { | |
break; | |
} | |
} | |
} |
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
; Autohotkey Capslock Remapping Script | |
; Danik | |
; More info at http://danikgames.com/blog/?p=714 | |
; danikgames.com | |
; | |
; Functionality: | |
; - Deactivates capslock for normal (accidental) use. | |
; - Hold Capslock and drag anywhere in a window to move it (not just the title bar). | |
; - Access the following functions when pressing Capslock: | |
; Cursor keys - J, K, L, I |
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
matrix = [[1, 3, 5], [6, 7, 8], [10, 11, 12], [13, 14, 15]] | |
[[row[i] for row in matrix] for i in range(3)] |
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 or operator can return a default value if the requested return value is "None": | |
def test_func(): | |
var_value = 'some value which could be none' | |
return var_value or "No value received" | |
# if var_value is None, the user will receive "No value received" |
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
# in a file called 'digits.py': | |
def last_digit(n1, n2): | |
''' | |
Define a function that takes in two non-negative integers a and b and | |
returns the last decimal digit of a^b | |
''' | |
return pow(n1, n2, 10) | |
# in a file called 'test_digits.py': |
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 pymssql | |
host = "hostname" | |
username = "username" | |
password = "password" | |
database = "database" | |
conn = pymssql.connect(host, username, password, database) | |
cursor = conn.cursor() | |
cursor.execute("SELECT * FROM table") |
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
# must pip install tkinter and pip install ttkthemes | |
# list of themes & theme reference: | |
# https://ttkthemes.readthedocs.io/en/latest/themes.html | |
import tkinter as tk | |
from tkinter import ttk | |
from ttkthemes import ThemedTk | |
window = ThemedTk(theme="arc") | |
ttk.Button(window, text="Quit", command=window.destroy).pack() |
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
mydict = Counter(map(str.lower, mylist)) |
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 string | |
listOfWords = [''.join(c for c in s if c not in string.punctuation) | |
for s in listOfWords] |
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 django.contrib import admin | |
from django.urls import path | |
from django.conf import settings | |
from django.conf.urls.static import static | |
urlpatterns = [ | |
path('admin/', admin.site.urls), | |
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) | |
#Things to change in settings first: |
OlderNewer