Skip to content

Instantly share code, notes, and snippets.

View noook's full-sized avatar
🐧
I'd like to learn fun things and Rust

Neil Richter noook

🐧
I'd like to learn fun things and Rust
View GitHub Profile
// Import h3 as npm dependency
import { createApp, createRouter, defineEventHandler, getRouterParam, sendError, createError, readBody, readValidatedBody, setResponseStatus, sendNoContent, getQuery, getValidatedQuery, H3Event, getRequestHeader } from "h3";
import { z } from 'zod'
import type { Prettify } from './utils'
// Create an app instance
export const app = createApp();
// Create a new router and register it in app
const router = createRouter();
@noook
noook / js101.md
Last active August 20, 2020 17:08
A dead simple overview of Javascript.

Javascript 101

Introduction

This guide aims to teach the most primitive concepts of Javascript, and is adressed to any people with a minimum knowledge of programming. This guide won't focus on ES6 specificities or any shorthand / advanced syntax.

Use cases of each notion are isolated and won't mix too much notions in order to focus on the current notion.

const tree = [];
for (let i = 1; i < 15; i += 1) {
const row = [];
for (let j = 0; j < i; j += 1) {
if ([0, i - 1].includes(j)) {
row.push(1);
} else {
row.push(tree[tree.length - 1][j - 1] + tree[tree.length - 1][j]);
}
@noook
noook / screenshot-hook.sh
Last active November 7, 2018 18:14
Uploads a screenshot to the server and copies the link in the clipboard
generate_uid() {
NEWUID=$(openssl rand -base64 15 | sed -E 's/[\/\+=]//' | head -c 6);
CODE=$(curl -sI https://domain.tld/$NEWUID.png | head -n 1|cut -d$' ' -f2);
if [ $CODE == 200 ];then
echo $(generate_uid);
else
echo $NEWUID;
fi
}
@noook
noook / commands.sh
Created September 20, 2018 09:53
Useful commands that I will never remember
# Sets a new hostname to a computer
sudo scutil --set HostName name-you-want
@noook
noook / slack-spotify.sh
Last active October 22, 2018 22:36
Slack integration to display current song playing in Spotify
#!/bin/bash
APIKEY="TOKEN HERE" # https://api.slack.com/custom-integrations/legacy-tokens
trap onexit INT
function reset() {
echo 'Resetting status'
curl -s -d "payload=$json" "https://slack.com/api/users.profile.set?token="$APIKEY"&profile=%7B%22status_text%22%3A%22%22%2C%22status_emoji%22%3A%22%22%7D" > /dev/null
}
function onexit() {
@noook
noook / .htaccess
Created May 3, 2018 12:08
New Router
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/assets(/.*|)$ [NC]
RewriteRule .* index.php