Skip to content

Instantly share code, notes, and snippets.

View lilpolymath's full-sized avatar
:octocat:
Exploring

Favour lilpolymath

:octocat:
Exploring
View GitHub Profile
@kiishi
kiishi / hooks.tsx
Last active September 18, 2022 22:57
react-query like Http Hooks ( with some little extras )
import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import { useEffect, useState } from 'react';
interface IRequestHookConfig {
// request params
params?: any;
// guards are like middlewares that run when a response is returned, before the state changes
// multiple guards can be added for different kind of checks
guards?: Array<(response: any, err: AxiosError | null) => Promise<void>>;
}
<?
//
// AUTO KEYWORD-BASED FOLLOWER CURATION BOT (by @levelsio)
//
// File: twitterFollowerCuratorBot.php
//
// Created: May 2021
// License: MIT
//
//MIT License
//Copyright (c) 2021 Felix Westin
//Source: https://github.com/Fewes/MinimalAtmosphere
//Ported to GLSL by Marcin Ignac
#ifndef ATMOSPHERE_INCLUDED
#define ATMOSPHERE_INCLUDED
// -------------------------------------
@gaearon
gaearon / CurvedArrow.js
Last active October 26, 2021 14:14
Curved SVG arrow between two objects (rects or circles) https://twitter.com/dan_abramov/status/1362255543721672704
// from/to: { left, top, width, height, shape: 'circle' | 'rect' }
function CurvedArrow({ from, to }) {
function curvedHorizontal(x1, y1, x2, y2) {
function pos(t) {
let mx = x1 + (x2 - x1) / 2;
let p1 = {x: x1, y: y1};
let p2 = {x: mx, y: y1};
let p3 = {x: mx, y: y2};
let p4 = {x: x2, y: y2};
return {
@abiodun0
abiodun0 / some_func.js
Last active February 8, 2021 21:03
Testing adhoc
function getGithubURL(resource) {
return `https://github.com/${resource}`;
}
function updateStoryViewWidth() {
const storyViewElem = document.querySelector('.story-view');
const { height } = storyViewElem.getBoundingClientRect();
storyViewElem.style.width = `${height / 1.77}px`;
}
@mattgperry
mattgperry / pointerEvents.tsx
Created August 26, 2020 15:19
Disable pointer-events at low opacity in Framer Motion
import { motion, useMotionValue, useTransform } from "framer-motion"
export function Overlay({ isVisible }) {
const opacity = useMotionValue(0)
const pointerEvents = useTransform(
opacity,
latest => latest < 0.5 ? "none" : "auto"
)
return (
@chidiwilliams
chidiwilliams / main.go
Last active August 3, 2020 13:08
My Solution to Find Treasure App (Ileya Game)
package main
import (
"encoding/json"
"fmt"
"log"
"math"
"net/http"
"os"
"time"
@abiodun0
abiodun0 / comonadsmonoidsandtrees.js
Created July 23, 2020 07:46
commonads, monoids and trees
// Leaf : val -> ann -> Tree val ann
function Leaf(val, ann) {
return {
ann: ann,
val: val,
toString: () => `Leaf(${val}, ${ann})`,
map: f => Leaf(val, f(ann)),
extend: f => Leaf(val, f(Leaf(val, ann))),
reduce: (f, acc) => f(acc, ann),
};
var Jimp = require('jimp');
const fileName = process.argv[2];
const width = process.argv[3];
const height = process.argv[4];
Jimp.read(fileName)
.then(photo => {
let colours = {};
for (let x = 0; x < width; x++) {
@devonzuegel
devonzuegel / twitter.css
Last active December 31, 2020 00:56
Custom CSS for Twitter
/* This has moved to:
* https://github.com/devonzuegel/digital-nesting/blob/master/twitter.css
*/