Skip to content

Instantly share code, notes, and snippets.

View SevanBadal's full-sized avatar
🐙

Sevan SevanBadal

🐙
View GitHub Profile
@SevanBadal
SevanBadal / demo.js
Created March 21, 2024 21:05
NextJs 14 Image component fills parent w/out overflow
import Image from 'next/image'
import HeroImage from '/public/hero.jpg'
export default function Hero() {
return (
<div style={{ position: 'relative', width: '100%', height: '100vh' }}>
<Image
src={HeroImage}
alt="Picture of the author"
{
"name": "bubble",
"version": "1.0.0",
"description": "",
"main": "bubbleSort.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
@SevanBadal
SevanBadal / binary-search.js
Last active December 13, 2023 02:53
Two binary search implements, one using recursion and another using loops. Quest from https://daily-quest-tau.vercel.app
const binarySearch = (array, target) => {
// min and max are indexes
let min = 0
let max = array.length - 1
// while loop will run until min and max cross each other
while(min <= max) {
// find middle index
const middle = Math.floor((min + max) / 2)
const current = array[middle]
// determine if we need to search left or right or end if we found it
@SevanBadal
SevanBadal / package.json
Last active December 13, 2023 02:45
Daily Quest reverseWords. Quest from https://daily-quest-tau.vercel.app
{
"name": "daily-quest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
@SevanBadal
SevanBadal / .vimrc
Created June 28, 2023 16:04
My default .vimrc file
" Enable syntax highlighting
syntax on
" Enable line numbers
set number
" Show matching brackets
set showmatch
" Indenting Configs
set autoindent
set smartindent
set tabstop=4
@SevanBadal
SevanBadal / week-11b-worksheet.hs
Last active April 19, 2023 19:39
Haskelliday: A Functor-Applicative-Monad Break from Class. I suggest loading this file into GHCI and exploring the main function and MyTree data type before proceeding to the questions.
import System.Random (StdGen, randomR, split, newStdGen)
-- main to help debug your Functor, Applicative and Monad instances
-- feel free to edit main!
main :: IO ()
main = do
treeOne <- generateRandomTree 10 -- tree of ten random nodes
-- you will end of needing to construct a tree of expressions of some type (a -> a) for the applicative
-- you can construct that tree manually via value constructors or by creating a new generateTree function
print treeOne
import System.Random
main :: IO ()
main = do
g1 <- newStdGen
g2 <- newStdGen
let tenRandomLetters = take 10 (randomRs ('a', 'z') g1)
let randomInts = take 10 (randomRs (1, 10) g2)
let mixLettersAndNumbers = [(letter, number) | letter <- randomLetters, number randomInts]
print mix
@SevanBadal
SevanBadal / vector-gadt.hs
Created February 15, 2023 17:04
Haskell GADT w/ type class constraint deriving Show
data Vector a where
Vector :: (Num a) => a -> a -> a -> Vector a
deriving instance Show a => Show (Vector a)
@SevanBadal
SevanBadal / sevo.zsh-theme
Created February 5, 2023 04:36
Drop in .oh-my-zsh/custom/themes
PROMPT='%{$fg[white]%}%c$(git_prompt_info): % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%}:%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%}%{$fg[red]%}-[*]"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$reset_color%}%{$fg[magenta]%}-[✓]"
@SevanBadal
SevanBadal / ada_http_post.adb
Created November 12, 2022 21:37
HTTP POST example using Ada's GNAT Sockets library
with GNAT.Sockets;
with Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Streams; use Ada.Streams;
procedure Ada_Http_Post is
CRLF : constant String := ASCII.CR & ASCII.LF;
Host : constant String := "httpbin.org";
Path : constant String := "/post";
Host_Entry : constant GNAT.Sockets.Host_Entry_Type :=
GNAT.Sockets.Get_Host_By_Name (Host);