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
# ZSH Theme | |
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" | |
if [[ $UID -eq 0 ]]; then | |
local user_host='{%{$terminfo[bold]$fg[red]%}%n@%m%{$reset_color%}}' | |
local user_symbol='#' | |
else | |
local user_host='{%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}}' | |
local user_symbol='$' | |
fi |
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
function toNumber(num) { | |
return Number(String(num).replace(/\./g, ',').replace(/(.+),/g, '$1.').replace(/[^\d.]/g, '').trim()) | |
} |
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
function GroceryList(items){ | |
this.items = items; | |
this.mapItems = (fn) => { | |
let newItems = []; | |
// could use map but it would not fit for this example | |
for (let i = 0; i < this.items.length ; i++){ | |
newItems = [...newItems, fn(this.items[i])]; | |
} | |
this.items = newItems; | |
return this; |
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
function formatCurrency(number) { | |
const [integerPart, decimalPart] = `${number}`.split("."); | |
const chunkSize = 3; | |
const integerPartArray = integerPart.split("").reverse(); | |
const chunks = Math.ceil(integerPartArray.length / chunkSize); | |
const formatedInteger = Array.from(new Array(chunks), (_, idx) => { | |
return integerPartArray | |
.slice(idx * chunkSize, idx * chunkSize + chunkSize) | |
.reverse() | |
.join(""); |
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
function nestedArrayAndObject() { | |
// refactor this to a single line of destructuring... | |
const info = { | |
title: "Once Upon a Time", | |
protagonist: { | |
name: "Emma Swan", | |
enemies: [ | |
{ name: "Regina Mills", title: "Evil Queen" }, | |
{ name: "Cora Mills", title: "Queen of Hearts" }, | |
{ name: "Peter Pan", title: `The boy who wouldn't grow up` }, |
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 sys | |
from subprocess import call, check_output | |
from isort import SortImports | |
def isort_all(): | |
path = sys.argv[1] | |
abs_path = os.path.abspath(path) |
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 pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib | |
import os | |
import datetime | |
% matplotlib inline | |
dir_name = os.path.abspath('./') |
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 WALTER_PRICE = 0.53, | |
TARE_PRICE = 0.08; | |
const tareMoney = (bottles) => { | |
return TARE_PRICE * bottles; | |
}; | |
const round = (f) => { | |
return Math.round(f * Math.pow(10, 2)) / Math.pow(10, 2); | |
}; |
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
''' | |
result: | |
books | |
books / nl | |
books / nl / sf | |
books / nl / ff | |
books / il / sf | |
books / il / ff | |
''' |
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 serial | |
import json | |
import sys | |
ser = serial.Serial( | |
port='/dev/ttyUSB0',\ | |
baudrate=9600,\ | |
parity=serial.PARITY_NONE,\ | |
stopbits=serial.STOPBITS_ONE,\ | |
bytesize=serial.EIGHTBITS,\ |
NewerOlder