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 / 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 / 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:]
<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>
ul.gallery {
list-style: none;
padding: 0;
margin: 0;
}
ul.gallery li {
width: 150px;
height: 150px;
overflow: hidden;
@ganglio
ganglio / me.svg
Created April 26, 2013 09:37
An SVG version of my face :D
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ganglio
ganglio / dabblet.css
Created March 27, 2013 03:04
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@ganglio
ganglio / dabblet.css
Created March 27, 2013 02:04
Untitled
.pesco {
width: 600px;
height: 300px;
box-shadow: 0 0 10px black inset;
}