Skip to content

Instantly share code, notes, and snippets.

@mildocjr
mildocjr / install3.sh
Created July 18, 2019 04:28
install3.sh
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@mildocjr
mildocjr / install2.sh
Created July 18, 2019 04:28
install2.sh
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
@mildocjr
mildocjr / install1.sh
Created July 18, 2019 04:27
install1.sh
xcode-select --install
@mildocjr
mildocjr / tests3.py
Created July 13, 2019 20:31
tests3.py
import unittest
import os
def read_file(name):
with open(name, 'r') as file:
return file.read()
class TestCreateDeleteFile(unittest.TestCase):
def setUp(self) -> None:
@mildocjr
mildocjr / tests2.py
Created July 13, 2019 20:30
tests2.py
import unittest
def add(x, y):
return x + y
class TestAddFunction(unittest.TestCase):
def test_add_numbers(self):
result = add(2, 2)
self.assertEqual(result, 4, "Bad Number")
@mildocjr
mildocjr / tests1.py
Created July 13, 2019 20:30
tests1.py
import unittest
def add(x, y):
return x + y
class TestAddFunction(unittest.TestCase):
def test_add_numbers(self):
result = add(2, 2)
self.assertEqual(result, 4, "Whoops")
@mildocjr
mildocjr / multiprocessing4.py
Created June 29, 2019 20:19
multiprocessing4.py
from multiprocessing import Process, Queue, current_process
def count(min, max, queue):
print(f"Started {current_process().name}")
this_list = []
index = 0
for i in range(min, max):
this_list.insert(index, i)
@mildocjr
mildocjr / multiprocessing3.py
Created June 29, 2019 20:16
multiprocessing3.py
import multiprocessing
import time
numbers = range(100000, 1000000, 10000)
lock = multiprocessing.Lock()
def task(number):
global lock
print(f"Executing new Task with process {multiprocessing.current_process().pid}")
@mildocjr
mildocjr / multiprocessing2.py
Created June 29, 2019 20:14
multiprocessing2.py
cpus_to_use = 8
num_cpus = os.cpu_count()
if cpus_to_use > num_cpus:
cpus_to_use = num_cpus
pool = multiprocessing.pool(cpus_to_use)
@mildocjr
mildocjr / multiprocessing1.py
Created June 29, 2019 20:13
multiprocessing1.py
import multiprocessing
import time
numbers = range(100000, 1000000, 10000)
def task(number):
print(f"Executing new Task with process {multiprocessing.current_process().pid}")