Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
magnetikonline / README.md
Last active February 7, 2025 07:27
IE 7/8/9/10/11 Virtual machines from Microsoft - Linux w/VirtualBox installation notes.
<?php
function pre_print_r($var){
echo "<pre>";
print_r($var);
echo "</pre>";
}
function Bigrams($word){
@willurd
willurd / web-servers.md
Last active May 4, 2025 11:11
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000

Permission Cheat Sheet

   chown -R www-data:www-data ./
   // set the proper owner
   find . -type f -exec chmod 644 {} \+
   // Recursively set FILE permissions.
@mathiasverraes
mathiasverraes / TestFrameworkInATweet.php
Last active September 24, 2024 14:47
A unit testing framework in a tweet.
<?php
function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}
@sukei
sukei / Signal.php
Last active August 24, 2021 11:08
An Observer in a Tweet
<?php
/**
* The Signal class is the smallest and fastest observer written in PHP 5.6 and
* using some new features such as the variadic functions and the arguments
* unpacking.
*
* ...and it fits in a tweet.
*
* @author Quentin Schuler aka Sukei <[email protected]>
@sukei
sukei / Template.php
Last active August 24, 2021 12:05
A Template Engine in a Tweet
<?php
/**
* The render function is a lightweight template engine, that allows string
* interpolation and output escaping.
*
* ...and it fits in a tweet.
*
* @author Quentin Schuler aka Sukei <[email protected]>
*/
@sukei
sukei / Container.php
Last active April 20, 2022 08:44
A Service Container in a Tweet
<?php
/**
* The Container class is a lightweight service container.
*
* ...and it fits in a tweet.
*
* @author Quentin Schuler aka Sukei <[email protected]>
*/
class Container{private $s;function set($k,$c){$this->s[$k]=$c;}function get($k){return(is_a($v=$this->s[$k],'Closure'))?$v($this):$v;}}
@sukei
sukei / Router.php
Created February 19, 2014 15:21
A Router in a Tweet
<?php
/**
* The Router class is a fast and lightweight router (yes it is). It can handle
* a path and call the matching controller. If there is no match, then an
* exception will be throwned.
*
* ...and it fits in a tweet.
*
* @author Quentin Schuler aka Sukei <[email protected]>
<?php
/**
* procedural wrappers for web request/response variables
*
* @author Jesus A. Domingo <[email protected]>
* @license MIT
*/
/**
* Gets a request parameter (from $_GET over $_POST combination)