Skip to content

Instantly share code, notes, and snippets.

@steveruizok
steveruizok / cache.ts
Last active March 31, 2023 14:43
weak map gist
export class Cache<T extends object, K> {
items = new WeakMap<T, K>()
get<P extends T>(item: P, cb: (item: P) => K) {
if (!this.items.has(item)) {
this.items.set(item, cb(item))
}
return this.items.get(item)!
}
@sortofsleepy
sortofsleepy / VIewController.h
Last active December 12, 2022 13:07
Basic setup of getting a Metal context up and running.
//
// ViewController.h
// metal.test
//
// Created by josephchow on 12/10/19.
// Copyright © 2019 josephchow. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Metal/Metal.h>
{
"presets": [
"env",
"react"
],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread"
]
}
const path = require('path');
const DashboardPlugin = require('webpack-dashboard/plugin');
module.exports = {
mode: 'development',
entry: './src/app.js',
output: {
path: path.join(__dirname, 'public', 'dist'),
filename: 'bundle.js'
},
@companje
companje / map.glsl
Created January 23, 2018 22:46
map() function for GLSL known from Processing & openFrameworks
float map(float value, float min1, float max1, float min2, float max2) {
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
}
@peterdemartini
peterdemartini / command.sh
Last active March 6, 2025 07:29
Exclude node_modules in timemachine
find `pwd` -type d -maxdepth 3 -name 'node_modules' | xargs -n 1 tmutil addexclusion
@srdjan
srdjan / 100+ different counter apps...
Last active May 6, 2024 05:13
100+ different js counter apps...
100+ different js counter apps...
@xposedbones
xposedbones / map.js
Last active June 17, 2024 02:30
Javascript Map range of number to another range
Number.prototype.map = function (in_min, in_max, out_min, out_max) {
return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
UPDATE wp_posts SET `guid` = REPLACE (`guid`, 'http://www.your-site.com', 'https://www.your-site.com') WHERE post_type = 'attachment';
UPDATE wp_posts SET `post_content` = REPLACE (`post_content`, 'src="http://www.your-site.com', 'src="https://www.your-site.com');