🤷♂️
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
// Flattening | |
let arrays = [[1, 2, 3], [4, 5], [6]]; | |
const data = arrays.reduce((acc, item) => acc.concat(item)); | |
console.log(data); | |
// Your own loop | |
// Everything | |
// Dominant writing direction |
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 range = (start, end, step=1) => { | |
const data = []; | |
for(let i=start; i <= end; i=i+step) { | |
data.push(i); | |
} | |
return data; | |
}; | |
console.log(range(3,6)); | |
console.log(range(1,100,10)); |
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
// minimum | |
function min(arg1, arg2) { | |
return (arg1 < arg2) ? arg1 : arg2; | |
} | |
console.log(min(0, 10)); | |
console.log(min(0, -10)); | |
// recursion |
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
// looping a triangle | |
for(var i=0; i < 8; i++) { | |
console.log('#'.repeat(i)); | |
} | |
// fizzbuzz | |
for(var i=1; i < 101; i++) { | |
if(i % 3 == 0 && i % 5 == 0) { | |
console.log(i + ' FizzBuzz'); | |
} else if(i % 3 == 0) { |
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 html.parser import HTMLParser | |
import urllib.request | |
class LinkParser(HTMLParser): | |
def __init__(self, *, convert_charrefs=True): | |
super().__init__(convert_charrefs=convert_charrefs) | |
self.links = [] | |
def handle_starttag(self, tag, attrs): |
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
languages: | |
en: | |
menu: | |
main: | |
- identifier: menu_home | |
name: "Home" | |
url: "/home/" | |
weight: 10 | |
- identifier: menu_about | |
name: "About" |
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
#!/usr/bin/env bash | |
# image magick extract image from gif | |
convert Collaboration.gif[4] collaboration-static.gif | |
# ffmpeg extract image from timestamp | |
ffmpeg -ss 00:00:04 -i Collaboration.mp4 -vframes 1 collaboration.png | |
ffmpeg -ss 00:00:12 -i Alerts.mp4 -vframes 1 alerts.png | |
ffmpeg -ss 00:00:09 -i API.mp4 -vframes 1 api.png | |
ffmpeg -ss 00:00:07 -i APM.mp4 -vframes 1 apm.png |
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
#!/usr/bin/env bash | |
# color pick the homepage | |
image_filename="public/$(sed -n 's/.*data-color="\([^"]*\).*/\1/p' public/index.html)" | |
echo "Picking color from : ${image_filename}" | |
if type "colorific" > /dev/null && [ -f $image_filename ]; then | |
picked_color=$(echo $image_filename | colorific | cut -d# -f7) | |
echo "Picked color : ${picked_color}" | |
sed -i "/^[[:space:]]*.home-blog-bg/,/}$/ s/background-color:.*/background-color: #$picked_color;}/g" public/index.html | |
else |
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
#!/usr/bin/env bash | |
# grep | |
# -i case insensitive | |
# -l output file names only | |
# | |
# Any line that begins with zero or more spaces | |
# followed by word "featured" | |
# followed by zero or more spaces | |
# followed by ":" |
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 requests | |
import tarfile | |
def download_github_repo_tar(token, org, repo, branch, to_path): | |
""" | |
Downloads a stream tar.gz file from github of a certain organisation/branch/repo | |
and extracts csv files to tmp directory for parsing |