Skip to content

Instantly share code, notes, and snippets.

@portiss
portiss / reverseString.js
Created February 5, 2024 09:14
Reverse a string
function reverseString(str) {
return str.split('').reverse().join('');
}
@portiss
portiss / isBalancedTree.js
Created February 5, 2024 09:12
isBalancedTree
function isBalancedTree(node) {
if (node) {
const keepSearch = h(node.right) - h(node.left) <= 1
if (keepSearch) {
return balancedTree(node.right) && balancedTree(node.left)
}
else return false
}
}
@portiss
portiss / flattenArrays.js
Created February 5, 2024 09:11
Implement JS flatMap
function flatten(ary, ret = []) {
return ary.reduce((ret, entry) => {
(Array.isArray(entry))? flatten(entry, ret) : ret.push(entry)
return ret
}, ret)
}
console.log(flatten([[[0], [1]], [[2], [3]], [[4], [5]]]))
@portiss
portiss / currying.js
Created February 5, 2024 09:09
Write the sum(3)(2)
function add(x) {
return (y) => x + y;
}
@portiss
portiss / fibonacci.js
Last active May 1, 2024 17:10
fibonacci (memoized)
const memo = {}
function fibonacci(n, memo){
if(n<2)
return n
if(!memo[n-1])
memo[n-1] = fibonacci(n-1, memo)
if(!memo[n-2])
memo[n-2] = fibonacci(n-2, memo)
return memo[n-1] + memo[n-2]
}
@portiss
portiss / isParenthesisMatching.js
Created February 6, 2024 09:42
Parenthesis Matching (Using stack)
const isParenthesisMatching = (str) => {
const stack = []
const open = {
'{': '}',
'[': ']',
'(': ')'
}
const closed = {

An guide how to activate Windows 11 Pro for free

Why?

Because you will get some more features like an Bitlocker and host your device as an External Desktop which can be accessed through the internet

Am i also able to switch from any other edition to Pro?

The answer is yes! You can switch from almost any edition to Pro completely for free!

Note for users with unactivated Pro edition

People which already have Pro, but not activated, can skip to this step.

Getting started

What you first need to do is open CMD (Command Prompt) as Administrator using this keyboard key:

@hamelsmu
hamelsmu / webhook-circleback.py
Created April 25, 2024 04:59
Generate a project proposal automatically from a meeting transcript
from fastapi import Request, HTTPException
from pydantic import BaseModel, BaseModel, HttpUrl
from modal import Secret, App, web_endpoint, Image
from typing import Optional, List
from example import proposal
import os
app = App(name="circleback", image=Image.debian_slim().pip_install("openai", "pydantic", "fastapi"))
class Attendee(BaseModel):
@mjhea0
mjhea0 / python_blackjack.py
Last active May 1, 2024 17:03
python blackjack
import os
import random
deck = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]*4
def deal(deck):
hand = []
for i in range(2):
random.shuffle(deck)
card = deck.pop()
@Clybius
Clybius / index.html
Last active May 1, 2024 17:00
Embed AV1/No File Size Capped Videos in Discord
<head>
<meta property="og:image" content="GifToEmbedURL"> # Change the content to the link of a gif of your choice, which will be shown as the embed.
<meta property="og:type" content="video.other">
<meta property="og:video:url" content="VideoToEmbedURL"> # Change the content to the link of a video of your choice. Will work with videos over 50 MB, and even unsupported codecs such as AV1!
<meta property="og:video:width" content="1920"> # Set this to the video's width and height, not required, but will show the video as intended if the aspect ratio and size is correct.
<meta property="og:video:height" content="1080">
</head>