Skip to content

Instantly share code, notes, and snippets.

View pissang's full-sized avatar

Yi Shen pissang

View GitHub Profile
@paullewis
paullewis / gist:1981455
Created March 5, 2012 22:03
Quicksort in JavaScript
/**
* An implementation for Quicksort. Doesn't
* perform as well as the native Array.sort
* and also runs the risk of a stack overflow
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
* array.push(Math.round(Math.random() * 100));
@mourner
mourner / index.html
Last active December 2, 2019 02:29
Mapbox GL JS Puppeteer benchmark
<!doctype html>
<meta charset="utf-8">
<title>Benchmark</title>
<body></body>
<style>html, body, #map { height: 100%; margin: 0; } </style>
<div id="map"></div>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.40.0/mapbox-gl.js'></script>
<!-- <script src="mapbox-gl.js"></script> -->
@veltman
veltman / README.md
Last active September 12, 2020 15:07
Triangulation morphing #2
@leeoniya
leeoniya / stable-sort-test.js
Created June 19, 2013 18:09
test if js engine's Array#sort implementation is stable
// test if js engine's Array#sort implementation is stable
var str = "abcdefghijklmnopqrstuvwxyz";
str.split("").sort(function(a,b) {
return ~~(str.indexOf(b)/2.3) - ~~(str.indexOf(a)/2.3);
}).join("") == "xyzvwtursopqmnklhijfgdeabc";
@mbostock
mbostock / .block
Last active March 31, 2021 08:11
Poisson-Disc II
license: gpl-3.0
@kyptov
kyptov / UnityLoader.js
Last active January 15, 2022 13:01
without gzip and brotli decompressors
var UnityLoader = UnityLoader || {
Compression: {
identity: {
require: function() {
return {};
},
decompress: function(data) {
return data;
},
hasUnityMarker: function() {
@claus
claus / gist:1396250
Created November 26, 2011 20:22
Resolution independent rendering of Bezier curves in WebGL
<!doctype html>
<html>
<head>
<title>Resolution independent rendering of Bezier curves in WebGL</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script src="glMatrix-0.9.6.min.js"></script>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
attribute vec2 aBezierCoord;
@mritzco
mritzco / install.md
Last active September 2, 2022 00:11
Running AR.js sample locally
@mattdesl
mattdesl / point-to-line-2d.js
Created March 22, 2018 00:36
2D Point to Line Segment distance function
// Taken From:
// https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment
function sqr (x) {
return x * x;
}
function dist2 (v, w) {
return sqr(v[0] - w[0]) + sqr(v[1] - w[1]);
}
@merolhack
merolhack / slugify.js
Last active May 29, 2023 11:30 — forked from mathewbyrne/slugify.js
Javascript Slugify: For accents and other latin characters
function slugify(text)
{
var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;";
var to = "aaaaaeeeeeiiiiooooouuuunc------";
_.each( from, function( character, i ) {
text = text.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
});
return text
.toString() // Cast to string
.toLowerCase() // Convert the string to lowercase letters