Skip to content

Instantly share code, notes, and snippets.

@ssokolow
ssokolow / index.php
Created July 6, 2012 03:39
Basic stub for mod_rewrite-like behaviour using PHP 5.4's development server
<?php
// To the extent possible under law, I (Stephan Sokolow) waive all copyright and related or
// neighbouring rights to this code snippet. (Though it'd still be nice if you mention me)
// If we're running under `php -S` with PHP 5.4.0+
if (php_sapi_name() == 'cli-server') {
// Replicate the effects of basic "index.php"-hiding mod_rewrite rules
// Tested working under FatFreeFramework 2.0.6 through 2.0.12.
$_SERVER['SCRIPT_NAME'] = str_replace(__DIR__, '', __FILE__);
@stilliard
stilliard / jsonToTable.php
Created October 9, 2012 13:24
JSON to HTML table
<?php
/**
* JSON data to html table
*
* @param object $data
*
*/
function jsonToTable ($data)
{
@ajaxray
ajaxray / cookies.js
Created November 24, 2012 12:01
Small JavaScript class to help create, read and delete cookie.
/**
* Cookies - A small class to manipulate cookies from javascript
*
* Compressed version: https://gist.github.com/4147384
*
* @see www.quirksmode.org/js/cookies.html
* @author Anis uddin Ahmad <anisniit@gmail.com>
*/
window.Cookies = {
@mindplay-dk
mindplay-dk / TestServer.php
Last active November 20, 2019 12:23
Minimal (copy and paste) unit testing
<?php
/**
* This class will launch the built-in server in PHP 5.4+ in the background
* and clean it up after use.
*/
class TestServer
{
/**
* @var resource PHP server process handle
@hubgit
hubgit / project-gutenberg-fetch-html.sh
Last active March 2, 2017 10:33
Fetch all HTML books from Project Gutenberg
#!/bin/bash
URL='http://www.gutenberg.org/robot/harvest?filetypes[]=html&langs[]=en'
REFERER='http://www.gutenberg.org/wiki/Gutenberg:Information_About_Robot_Access_to_our_Pages'
USER_AGENT='Gutenberg Importer'
wget --wait 10 --mirror --span-hosts --referer="$REFERER" --user-agent="$USER_AGENT" "$URL"
@mattia72
mattia72 / FullPie.md
Last active August 22, 2019 16:19 — forked from stevenleeg/pie.coffee
This is a simple widget that lets you render pie charts in Dashing.

FullPie widget

This is a simple widget that lets you render pie charts in Dashing. Forked from stevenleeg/pie.coffee It looks a little bit like this:

Screenshot

Usage

dashboard.erb:

@collinglass
collinglass / .pagevue.js
Last active September 1, 2019 09:33
Simple Multi-View Routing with Page.js and Vue.js
Simple Multi-View Routing with Page.js and Vue.js
@ivanoats
ivanoats / jqh.js
Created December 10, 2015 04:32
Hyperscript for jQuery
// hyperscript for jQuery
// create nested HTML elements with a DSL
// used to create reusable, interactive HTML components
//
// based on the many implentations out there like
// https://github.com/dominictarr/hyperscript
// https://github.com/Matt-Esch/virtual-dom/tree/master/virtual-hyperscript
// and Elm https://github.com/evancz/elm-html
var $h = function(element, properties, content) {
var $component = $('<' + element + '>');
@arteymix
arteymix / example.vala
Last active July 2, 2017 06:08
Example of non-blocking execution in GTK with Vala (run with `vala --pkg=gtk+-3 example.vala`)
using Gtk;
Button button;
public static int main (string[] args) {
Gtk.init (ref args);
var window = new Window ();
window.title = "Count without blocking the UI";
window.border_width = 10;
window.window_position = WindowPosition.CENTER;
<?php
class Csv
{
public static function fromArray($rows, $delimiter = ',')
{
if (empty($rows)) {
return '';
}