Skip to content

Instantly share code, notes, and snippets.

View KrofDrakula's full-sized avatar

Klemen Slavič KrofDrakula

View GitHub Profile
@guest271314
guest271314 / assemblyscript-deno-bun-node-js.md
Last active February 28, 2025 03:26
Executing AssemblyScript directly, and compiling to JavaScript with tsc, Deno, and Bun (and executing WASM directly with bun)

Executing AssemblyScript directly, and compiling to JavaScript with tsc, Deno, and Bun (and executing WASM directly with bun)

Installing

bun install typescript@next assemblyscript @types/node
bun add v1.2.1-canary.15 (5633ec43)

installed [email protected] with binaries:
 - tsc
@tommyettinger
tommyettinger / mulberry32.c
Last active February 24, 2025 16:25
Mulberry32 PRNG
/* Written in 2017 by Tommy Ettinger ([email protected])
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
See <http://creativecommons.org/publicdomain/zero/1.0/>. */
#include <stdint.h>
const MODULE_DIR = /(.*([\/\\]node_modules|\.\.)[\/\\](@[^\/\\]+[\/\\])?[^\/\\]+)([\/\\].*)?$/g;
{
loader: 'babel-loader',
test: /\.jsx?$/,
include(filepath) {
if (filepath.split(/[/\\]/).indexOf('node_modules')===-1) return true;
let pkg, manifest = path.resolve(filepath.replace(MODULE_DIR, '$1'), 'package.json');
try { pkg = JSON.parse(fs.readFileSync(manifest)); } catch (e) {}
return !!(pkg.module || pkg['jsnext:main']);
@developit
developit / preact-8-changes.md
Last active August 25, 2017 00:51
Important changes coming in Preact 8

Removed: Element Recycling

DOM Element recycling will be removed in Preact 8.

This should have no effect on most applications. In fact, it fixes a number of known issues related to element state not being fully reset on reuse.

💡 Why? Many DOM properties are stateful, and trying to reset them all when recycling is a game of whack-a-mole. Preact's size makes it infeasible to use whitelists to address these issues, so recycling is being dropped. >

@developit
developit / instant-documentation-publish.sh
Last active September 26, 2024 22:57
Publish your docs instantly using gist & documentation-viewer
# SETUP: install documentation.js:
npm i -g documentation browser-pipe
# SETUP: install gist cli (github.com/defunkt/gist)
brew install gist
# generate docs, upload to gist.github.com, then pipe the Gist URL to Documentation Viewer in your browser:
documentation src | gist -p -f docs.json | awk '{print "https://documentation-viewer.firebaseapp.com/#"$1}' | browser-pipe
@paulirish
paulirish / what-forces-layout.md
Last active April 19, 2025 04:59
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@KrofDrakula
KrofDrakula / template.js
Last active October 3, 2015 06:01
An easily understandable templating function
// A very light-weight templating function
// Use <% ... %> to embed code, <%= ... %> to output expressions.
//
// Caveat: because the parser makes no attempts at interpreting
// any `<%` and `%>` inside code blocks, so if you need
// metatemplating, you need to escape those sequences
// just like '<scr'+'ipt>' in script tags.
//
// See examples of usage below.
function template(str, params) {
@KdotJPG
KdotJPG / OpenSimplex2S.java
Last active April 2, 2025 15:44
Visually isotropic coherent noise algorithm based on alternate constructions of the A* lattice.
/**
* K.jpg's OpenSimplex 2, smooth variant ("SuperSimplex")
*
* More language ports, as well as legacy 2014 OpenSimplex, can be found here:
* https://github.com/KdotJPG/OpenSimplex2
*/
public class OpenSimplex2S {
private static final long PRIME_X = 0x5205402B9270C86FL;
@matjaz
matjaz / run.coffee
Created August 13, 2012 17:02
Run coffee script directly without globally installed coffee command
#!/usr/bin/env node
coffee=require('coffee-script');fs=require('fs');coffee.run(fs.readFileSync(__filename, 'utf-8').slice(136, -2));
/*
console.log i for i in [3..1]
console.log 'Lift off!'
*/
anonymous
anonymous / Alpha-transparent-JPEGs.html
Created November 10, 2010 14:53
Using <canvas> element to enable JPEG transparency by using one as the source and the other for a bitmap mask.
<!DOCYTPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Alpha blender</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<style type="text/css">
html { background: black; }
</style>
</head>