Skip to content

Instantly share code, notes, and snippets.

@jtickle
jtickle / fancyApi.php
Last active December 20, 2015 23:39
Functional PHP: A getModule function that works like Node.js' require()
<?php
// I have no idea how to solve the problem of the fact that anything
// declared here ends up on the global scope. Namespaces, maybe? But
// I'm doing this in part to get away from namespaces and just let things
// be functional. So I wrap it up in this load function but you should
// try to pick some name that won't conflict.
function fancyApi(&$exports) {
$myConfig = 'World';
# 10 Status Code Definitions
Each Status-Code is described below, including a description of which method(s) it can follow and any shit required in the response.
## 10.1 Informational 1xx
This class of status code indicates a half-fucky response, consisting only of the Status-Line and optional headers, and is terminated by an empty line. There are no required headers for this class of status code. Since HTTP/1.0 did not define any 1xx status codes, servers MUST wonder why exactly humans decided to start off at 200.
A client MUST be prepared to accept one or more half-fucky responses prior to a regular response, even if the client does not expect a 100 (Go On) status message. Unexpected 2xx status responses MAY be shit-canned by a user agent.
@jtickle
jtickle / gist:9419951
Last active August 29, 2015 13:57
Compilable and Interpretable GFM
# Hello Class
This class exposes an interface "sayHello" that says hello.
If someone wrote a utility called 'gfmc', it would be a compiler that compiles whatever you put in code blocks in whatever language you specified and puts them in sensible places.
I don't think this is actually possible but you get the idea. It may not have any value at all, but then again it might if you want to make an API to your thing in every language anyone's ever heard of.
```php
class Hello {
@jtickle
jtickle / Better GFMC Idea
Last active August 29, 2015 13:57
Better GFMC idea
```
namespace My\Shitty;
use \Exception;
```
# Class: Thing
It is a thing that holds stuff. Takes an array in the constructor in which to put stuff; doesn't care if it's empty or not.
```
@jtickle
jtickle / older.sh
Last active August 29, 2015 13:59
BASH "Older Than" Script
#!/bin/bash
# This script will return 0 if the specified file is older, 1 if newer than the specified date.
# Intended for use with GNU Find, like so:
#
# find filez/ -exec ./older.sh {} "2 days ago 00:00" + -delete
#
# If you want to find files that are newer than 2 days ago, you'd do something like:
#
# find filez/ -not -exec ./older.sh {} "2 days ago 00:00" + -delete
#!/usr/bin/env sh
# This script will display a count of the arguments passed to it,
# once each time it is called by xargs.
#
# To show how xargs works:
#
# seq 1 1000000 | xargs ./count-args
echo Called once by xargs with $# arguments.
ticklejw@MAL ~
$ find test -exec ./sleepawhile {} \; -type f -print
Sleeping for 1 second... done!
Sleeping for 1 second... done!
test/0
Sleeping for 1 second... done!
test/1
Sleeping for 1 second... done!
test/2
Sleeping for 1 second... done!
@jtickle
jtickle / ipaddr.sh
Created February 11, 2015 01:13
Parses 'ip addr' and shows you what you are really looking for - IP per interface.
ip -o -4 addr | awk '/.* ([a-zA-Z0-9]+)/ {print $2 "\t" $4}'
@jtickle
jtickle / GeodesicSphere.js
Created September 4, 2016 16:25 — forked from Inscrutabilis/GeodesicSphere.js
Three.js geodesic sphere primitive class
/**
* @author Inscrutabilis / mailto:[email protected]
*/
/*
* Generates a geodesic sphere geometry
* By default, it is 1x1x1 octahedron, as a first approximation to sphere
* It will return more sphere-like object if you specify iterations > 0
* But please keep in mind that it generates (4 ^ iterations) * 8 faces
* Radius argument overrides default sphere radius (1)
@jtickle
jtickle / ftw.c
Created January 3, 2017 02:05
Fourier transform
#include <fftw3.h>
#include <math.h>
#define N 256
// This thing does a fourier transform on a generated array of data
// and makes a CSV out of it so I could make pretty graphs in an
// outside tool.
//
// in the output: