This file contains hidden or 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 os | |
from os.path import join | |
from tkinter import * | |
from tkinter import messagebox | |
def replace(subdir, string1, string2): | |
cwd = os.getcwd() | |
location = join(cwd, subdir) | |
for file in os.listdir(location): | |
os.rename(join(location, file), join(location, file.replace(string1, string2))) |
This file contains hidden or 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 pickle, os.path, sys | |
filename = "Accounts.picklefile" | |
if os.path.isfile(filename): | |
fileload = open(filename, 'rb') | |
try: | |
database = pickle.load(fileload) | |
except EOFError: | |
print("Error reading file") | |
database = [] |
This file contains hidden or 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 java.util.Scanner; | |
import java.util.InputMismatchException; | |
import java.lang.Math; | |
public class AddNumbers { | |
public static void main(String[] args) { | |
Scanner reader = new Scanner(System.in); | |
System.out.println("Please enter two numbers:"); | |
try{ | |
System.out.print("A: "); |
This file contains hidden or 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 build_edges(x, y): | |
edges = [] | |
for i in range(len(x)): | |
for k in range(len(x)): | |
dist = math.sqrt(((x[i] - x[k]) ** 2) + ((y[i] - y[k]) **2)) | |
edges.append([i, k, dist]) | |
return edges |
This file contains hidden or 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
@counter = 0 | |
def move(n, source, target, spare) | |
print('.') if @counter % 1000000 == 0 # let the user know that we are working for each 1,000,000th call | |
if n > 0 | |
@counter += 1 | |
move(n - 1, source, spare, target) # move it to the spare so it is out of the way | |
target << source.pop() # in place memory manipulation, equivilent to pass by refrence. | |
move(n - 1, spare, target, source) # move the n - 1 disks that we left on spare onto target | |
else | |
return [source, target, spare] |
This file contains hidden or 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 insertionSort(input_list) | |
alist = input_list.clone # copy the array to sort its values. If this is not done it WILL sort in place (modify the list that was passed in) | |
1.upto(alist.size - 1) do |index| # from index 1 to the last do the following | |
current_value = alist[index] # the value of the item we are sorting | |
position = index # its index in the array | |
# while we are not at the begining of the array or the previous value is greater then this one (a.k.a it is in the wrong position) | |
while position > 0 && alist[position - 1] > current_value do | |
alist[position] = alist[position - 1] # move the previous item up one | |
position -= 1 # and move the index of our item back |
This file contains hidden or 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
<# | |
.SYNOPSIS | |
Uses Win32_Fan class to return information about fans in a system. | |
.DESCRIPTION | |
This script first defines some functions to decode various | |
WMI attributed from binary to text. Then the script calls | |
Get-WmiObject to retrieve fan details, then formats that | |
information (using the functions defined at the top of the script. | |
.NOTES |
This file contains hidden or 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 csv | |
cities = dict() | |
counties = dict() | |
hosptials = dict() | |
with open('Healthcare_Associated_Infections.csv', 'r') as f: | |
reader = csv.reader(f, delimiter=",") | |
for i, row in enumerate(reader): | |
This file contains hidden or 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
public class BaseViewEngine : RazorViewEngine | |
{ | |
protected BaseViewEngine() | |
{ | |
this.AreaViewLocationFormats = new string[4] | |
{ | |
"~/Areas/{2}/Views/{1}/{0}.cshtml", | |
"~/Areas/{2}/Views/{1}/{0}.aspx", | |
"~/Areas/{2}/Views/{1}/{0}.ascx", | |
"~/Areas/{2}/Views/Shared/{0}.cshtml", |
This file contains hidden or 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
{ | |
"CORSRules": [ | |
{ | |
"AllowedOrigins": ["*"], | |
"AllowedHeaders": ["Authorization"], | |
"AllowedMethods": ["GET"], | |
"MaxAgeSeconds": 3000 | |
} | |
] | |
} |