Skip to content

Instantly share code, notes, and snippets.

@ganglio
ganglio / lorem.sql
Created July 19, 2017 10:24
A brilliant function to generate Lorem Ipsum in SQL
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES';
DELIMITER //
DROP FUNCTION IF EXISTS str_random_lipsum;
//
CREATE FUNCTION str_random_lipsum(p_max_words SMALLINT ,p_min_words SMALLINT ,p_start_with_lipsum TINYINT(1) )
RETURNS VARCHAR(10000)
NO SQL
BEGIN
@ganglio
ganglio / placeholder.svg
Created June 27, 2017 23:10
A placeholder image
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ganglio
ganglio / mu.php
Created December 15, 2016 12:12
µ - APIs with HMAC
<?php
if (
file_exists(__DIR__ . $_SERVER['REQUEST_URI']) &&
!is_dir(__DIR__ . $_SERVER['REQUEST_URI'])
) {
return false;
}
$secret = getenv("SEC");
@ganglio
ganglio / gist:7143266
Created October 24, 2013 19:13
Ken Perlin's SIGGRAPH 2002 Noise Generator Implementation
// JAVA REFERENCE IMPLEMENTATION OF IMPROVED NOISE - COPYRIGHT 2002 KEN PERLIN.
public final class ImprovedNoise {
static public double noise(double x, double y, double z) {
int X = (int)Math.floor(x) & 255, // FIND UNIT CUBE THAT
Y = (int)Math.floor(y) & 255, // CONTAINS POINT.
Z = (int)Math.floor(z) & 255;
x -= Math.floor(x); // FIND RELATIVE X,Y,Z
y -= Math.floor(y); // OF POINT IN CUBE.
z -= Math.floor(z);
@ganglio
ganglio / fps.js
Created September 20, 2013 16:42
Calculate the current website FPS
(function(){
"use strict";
var filterStrength = 20;
var frameTime = 0, lastLoop = new Date, thisLoop;
var loop = function() {
var thisFrameTime = (thisLoop=new Date) - lastLoop;
frameTime+= (thisFrameTime - frameTime) / filterStrength;
lastLoop = thisLoop;
@ganglio
ganglio / gist:6436012
Created September 4, 2013 11:58 — forked from burin/gist:3840737
<!-- standard viewport tag to set the viewport to the device's width
, Android 2.3 devices need this so 100% width works properly and
doesn't allow children to blow up the viewport width-->
<meta name="viewport" id="vp" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width" />
<!-- width=device-width causes the iPhone 5 to letterbox the app, so
we want to exclude it for iPhone 5 to allow full screen apps -->
<meta name="viewport" id="vp" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)" />
<!-- provide the splash screens for iPhone 5 and previous -->
<link href="assets/splashs/splash_1096.png" rel="apple-touch-startup-image" media="(device-height: 568px)">
<link href="assets/splashs/splash_iphone_2x.png" rel="apple-touch-startup-image" sizes="640x960" media="(device-height: 480px)">
@ganglio
ganglio / aco.py
Created June 5, 2013 16:24
ACO conversion utility
#!/usr/bin/env python
# aco
#
# Convert an Adobe Color Swatches file to standard hex color codes
import sys, re, os
def main():
args = sys.argv[1:]
@ganglio
ganglio / bag.md
Created June 4, 2013 11:23
Bag project

Bag project

This are specs and thoughts about a hybrid laptop/tablet porter bag

Laptop Specs (Macbook):

* Height: 25 mm
* Width: 325 mm
* Depth: 227 mm
  • Weight: 2040 g
<svg>
<g id='rect'>
<rect x='50' y='50' width='150' height='100' stroke='black' fill='transparent'/>
<circle cx='50' cy='50' r='5' stroke='black' fill='white'/>
</g>
</svg>
<svg>
<g id='rect'>
<rect x='50' y='50' width='150' height='100' stroke='black' fill='transparent'/>
<circle cx='50' cy='50' r='5' stroke='black' fill='white'/>
</g>
</svg>