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 itertools | |
from memory_profiler import profile | |
@profile | |
def my_func(): | |
a = [1] * (10 ** 6) | |
# A generator adds nothing to memory as each index is loaded | |
# on the fly | |
b = (2 for _ in range(2 * 10 ** 7)) | |
# we discard the first 199999 from the generator using itertools |
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
package main | |
import ( | |
"math" | |
"github.com/pkg/profile" | |
) | |
func makeArray(num int, size float64) []int { | |
arr := make([]int, int(size)) | |
for ind := range arr { |
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 memory_profiler import profile | |
@profile | |
def my_func(): | |
a = [1] * (10 ** 6) | |
b = [2] * (2 * 10 ** 7) | |
c = b[200000] | |
del b | |
return a.append(c) |
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 memory_profiler import profile | |
@profile | |
def my_func(): | |
a = [1] * (10 ** 6) | |
b = [2] * (2 * 10 ** 7) | |
return a.append(b[200000]) | |
if __name__ == '__main__': | |
my_func() |
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
# pull official base image | |
FROM node:13.12.0-alpine | |
# set working directory to /app | |
WORKDIR /app | |
# add `/app/node_modules/.bin` to $PATH | |
ENV PATH /app/node_modules/.bin:$PATH | |
# copy package files to /app and install |
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
# pull official base image | |
FROM node:13.12.0-alpine | |
# set working directory to /app | |
WORKDIR /app | |
# add `/app/node_modules/.bin` to $PATH | |
ENV PATH /app/node_modules/.bin:$PATH | |
# copy project to /app |
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
#!/bin/bash | |
# replaces the $x variable | |
# e.g replaceVariable first_locked 7777 ~/.bashrc | |
# will replace any export first_locked=* with export first_locked=7777 directly in ~/.bashrc | |
# and then proceed to source the script if it is an rc file | |
function replaceVariableInFile { | |
sed -i -e "s/^export\ $1=.*/export\ $1=$2/g" $3 | |
# matches .bashrc and .zshrc files | |
if [[ "$3" =~ .*"rc" ]]; then |
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
#!/bin/bash | |
# check if slack.sh exists else download it | |
# using curl | |
function checkSlackUtilityExists { | |
if [ -f "./slack.sh" ]; then | |
chmod +x ./slack.sh | |
else | |
echo -e "Downloading slack utility..." && | |
curl -o ./slack.sh https://gist.githubusercontent.com/andkirby/67a774513215d7ba06384186dd441d9e/raw/c8a47aec0f08ca6dc64201ba40f09ff8c79f735e/slack.sh -s && chmod +x ./slack.sh && |
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
#!/bin/bash | |
# Generate a random number using date | |
RANDOM=$(date +%s) | |
EXCUSESARRAY=( | |
"to visit Nosarobumeh in the hospital" | |
"for some away screen time" | |
"as I have a slight headache" | |
"to take a rest" | |
"for the next one hour" | |
"for a bit to run some errands" |
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
#!/bin/bash | |
# run function passed to this if we are in work period | |
# e.g runIfWorkPeriod echo "Hello there" will only | |
# output "Hello there" if currenttime is within work period | |
function runIfWorkPeriod { | |
start_time="09:00" | |
end_time="17:00" | |
currenttime=$(date +%H:%M) | |
if [[ "$currenttime" > "$start_time" ]] && [[ "$currenttime" < "$end_time" ]]; then |
NewerOlder