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
# install Homebrew, visit: https://brew.sh/ | |
# check current user | |
$ echo $(whoami) | |
# optional - uninstall brew ruby | |
$ brew uninstall ruby | |
# install rbenv | |
$ brew update |
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 sys | |
def main(args): | |
n = int(args[1]) | |
print(f"start = {n}") | |
while not n == 1: | |
n = problem(n) | |
print(f"{n}") | |
def problem(n): |
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
const sleepPromise = async function(timeType, timeValue) { | |
const timeModifier = { 'ms': null, 's': 1000, 'm': 60, 'h': 60 } | |
const timeTypes = ['ms', 's', 'm', 'h'] | |
for (let i = 1; i < timeTypes.length; i++) { | |
let key = timeTypes[i] | |
timeValue = timeValue * timeModifier[key] | |
if (timeType === key) { | |
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
START "" "start-ssh-agent" ^&^& EXIT | |
code | exit |
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 datetime import datetime | |
import time | |
# minute, second, millisecond to a string and split into list | |
min_sec = datetime.now().strftime("%M %S .%f").split(" ") | |
# calculate minutes to wait for the next whole quart hour | |
# explanation of m calculation: e.g. time = 12:33 : min = 33 | |
# 33 % 15 = 3 : find out minutes since last quart | |
# 15 - 3 = 12 : whole minutes to wait for next quart |
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 threading # import threading | |
class escape: | |
"""Object status() to return false when "enter" key is pressed""" | |
def __init__(self): | |
self.run = True # should code run? | |
self.get_key = threading.Thread(target=self.escape_wait) # init thread | |
self.get_key.start() # start input thread | |
def status(self): # return False if "enter key" is pressed. otherwise ,True |
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 main(): | |
number = 0 # starting number | |
while True: | |
prime = True # assumes number is prime initially | |
t = 0 # test for number of divisions | |
number += 1 # increment number (as must be positive) | |
for i in range(1, number + 1): # iterate all numbers between 1 and "number". | |
if (number / i).is_integer(): # test for whole number division | |
if i == 1 or i == number: |
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 time | |
from random import randrange, choice | |
def main(): | |
print("\n") | |
str_len = 100 | |
list_len = 10000 | |
dummy_list = mk_random_list(str_len, list_len) | |
test = [] # test list |
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 os | |
import random | |
import time as Time | |
"""an efficiency visualisation: indexing dict keys and randomly choosing | |
one to change its value until all are changed | |
-removes key from index after value change: no collisions | |
-100 dict key value pairs""" | |
def main(): |
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 os | |
from random import randrange | |
import time as Time | |
"""an efficiency visualisation: randomly picking dict key and changing values until all are changed | |
-the loop passes on collisions | |
-100 dict key pairs""" | |
def main(): | |
number_grid = {} # empty grid for numbers |