Skip to content

Instantly share code, notes, and snippets.

@sharno
sharno / index.ts
Created June 22, 2024 22:18
TS promises processing pool
const processInPool = async (
tasks: (() => Promise<unknown>)[],
poolSize: number,
) => {
const pool = tasks.toReversed();
const worker = async () => {
while (true) {
const task = pool.pop();
if (task == null) {
return;
@sharno
sharno / setup.cmd
Created April 2, 2024 01:11
Install tools I use on a new windows machine
scoop bucket add main
scoop bucket add java
scoop bucket add extras
scoop install main/git
scoop install main/7zip
scoop install main/python
scoop install main/nodejs-lts
scoop install main/go
scoop install java/corretto17-jdk
@sharno
sharno / youtube-dl-playlist-parallel.ps1
Created June 27, 2022 16:34
Download a youtube playlist in parallel using powershell
Foreach ($v in (youtube-dl --get-id PLAYLIST_URL)) {
Start-Job -ScriptBlock { youtube-dl $using:v }
}
# to extract audio add: -x
# to extract as mp3 add: -x --audio-format mp3
@sharno
sharno / advent_2021_day12.py
Last active December 13, 2021 17:12
Advent of Code 2021 (Day 12) p1
graph = [
("GC", "zi"),
("end", "zv"),
("lk", "ca"),
("lk", "zi"),
("GC", "ky"),
("zi", "ca"),
("end", "FU"),
("iv", "FU"),
("lk", "iv"),
@sharno
sharno / Sum_frequency.py
Last active December 2, 2022 09:55
hackerearth: Sum as per frequency
'''
# Sample code to perform I/O:
name = input() # Reading input from STDIN
print('Hi, %s.' % name) # Writing output to STDOUT
# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
'''
# Write your code here
@sharno
sharno / setup.bat
Created September 18, 2021 03:56
My machine setup (WIP)
scoop install 7zip git vscode googlechrome vlc
@sharno
sharno / anonymous_recursive1.exs
Last active February 2, 2018 16:35
As Elixir doesn't have a way to create an anonymous recursive function yet, we have to do a little trick and pass the function to itself when calling it to get recursion
print = fn f ->
receive do
name -> IO.puts(name)
f.(f)
end
end
server = spawn(fn -> print.(print) end)
send(server, "Sharno")
@sharno
sharno / learnHaskell.hs
Created October 3, 2017 04:45
Lecture notes for Bartosz Milewski's videos on Haskell
:l <filename> -- load
:r -- reload
:q -- quit
:t <expression> -- type
:i -- info
:k <something> -- kind
:sprint <expression> -- prints an expression without evaluation
------------------------------------
-- this is a comment
<!DOCTYPE html>
<meta charset="utf-8">
<style>
text{
font-size:12px;
}
.mainBars rect{
shape-rendering: auto;
fill-opacity: 0;
stroke-width: 0.5px;
@sharno
sharno / recon 2.2 metabolites with only producers or with only consumers
Created November 22, 2016 12:24
recon 2.2 metabolites with only producers or with only consumers
10fthf7glu_e
12RHPET_c
12harachd_r
12ppd_R_c
15HPET_r
17ahprgnlone_m
17ahprgstrn_m
18harachd_r
1a2425thvitd2_m
1a2425thvitd3_m