Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View r17x's full-sized avatar
🤘
REconciling...

RiN r17x

🤘
REconciling...
View GitHub Profile
@r17x
r17x / a.c
Created April 19, 2024 05:45
neovim_kavvaiii
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::
@r17x
r17x / x.js
Created April 17, 2024 18:18
react_only
const idle = () => ({ kind: 'idle' })
const loading = () => ({ kind: 'loading' })
const loaded = (data) => ({ kind: 'loaded', data })
const error = (error) => ({ kind: 'error', error })
const isLoaded = (state) => state.kind === 'loaded'
const renderWhenLoaded = (state, reactNode) => isLoaded(state)
? reactNode(state.data)
: null
Output vieskod.gif
Set Shell "fish"
Set FontSize 32
Set Width 1200
Set Height 720
Type "echo 'Welcome to Vi es kod! and I run Vi es kod! FTW 🔥🔥'" Sleep 500ms Enter
Type "alias vieskode='"nix run '"github:r17x/nvim.nix"'"'" Sleep 250ms Enter
Type "vieskode" Sleep 15s Enter
// make it "composable function for ANYTHING"
const pipe = (...args) => p => args.reduce((x, f) => f(x), p)
// promise RESOLVE handler
const pOK = f => p => p.then(f)
// promise REJECT handler
const pErr = f => p => p.catch(f)
// when promise rejected you must be handled the rejection
const responsePredicate = f => res => f(res) ? res : promise.reject(res)
// I just want 200 and request is OK
const responseOK = responsePredicate(res => res.ok && res.status === 200)
@r17x
r17x / find_postinstall
Last active March 18, 2024 19:32
chmod +x <THISSCRIPT>
#!/bin/bash
# Function to display the postinstall field of package.json if exists
display_hook_install() {
if [ -f "$1" ]; then
postinstall=$(jq -r '.scripts.postinstall' "$1")
dir=$(dirname "$1")
packagename=$(jq -r '.name' "$1")
packageversion=$(jq -r '.version' "$1")
@r17x
r17x / Main.hs
Created January 31, 2024 17:26
HackerRankSolutions
-- Input: 10
-- Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
-- Signature
fn :: (Integral a) => a -> [a]
-- Solution with pattern-matching
fn 0x0 = []
fn n = if n - 1 < 0 then fn 0 else fn (n - 1) ++ [n]
-- n = -1
@r17x
r17x / tag_clean.sh
Created January 21, 2024 15:42
Tag Clean 30 day ago
#!/usr/bin/env sh
git for-each-ref --sort=taggerdate --format '%(refname:short) %(taggerdate:format:%s)' "refs/tags/*" | while read tag tagdate; do
threshold_date=$(date -d '60 days ago' --utc '+%s')
if [ -n "$tagdate" ]; then
if [ "$tagdate" -lt "$threshold_date" ]; then
echo "==> $tag is older than 60 days"
echo "==> $tag will be deleted"
git tag --delete $tag
git push origin --delete $tag
@r17x
r17x / README.md
Created January 15, 2024 09:14
Merge 2 Repository
# Do with fresh clone
git clone REPO1 A
git clone REPO2 B

cd A

# bundle repo as directory (I hate CONFLICT by structure project, so new repo, new directory)
git filter-repo --to-subdirectory-filter apps/A
# VHS documentation
#
# Output:
# Output <path>.gif Create a GIF output at the given <path>
# Output <path>.mp4 Create an MP4 output at the given <path>
# Output <path>.webm Create a WebM output at the given <path>
#
# Require:
# Require <string> Ensure a program is on the $PATH to proceed
#
@r17x
r17x / promise101.md
Created January 7, 2024 14:24
Promise101

Promise is Like a MONAD but Never be a MONAD

// same thing: f(x)
const apply = (x, f) => f(x)

const touch = (f) => (x) => {
  apply(x, f)
  return x
}