Skip to content

Instantly share code, notes, and snippets.

@xeoncross
xeoncross / run.php
Created August 30, 2011 01:45 — forked from greut/run.php
A web server in pure PHP (non-concurrent and concurrent)
#!/usr/bin/env php
<?php
$app = function($request) {
$body = <<<EOS
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<title>Hello World!</title>
@rkh
rkh / chat.rb
Created December 14, 2011 12:55
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@ziadoz
ziadoz / awesome-php.md
Last active May 8, 2025 07:37
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@xeoncross
xeoncross / view.__get.php
Last active October 1, 2015 11:57
View Error Handling For Missing Values
<?php
// Sets the error handler to check the current class for the value if it's missing
// http://stackoverflow.com/a/2669273/99923
error_reporting(E_ALL);
ini_set("display_errors", 0);
class View {
function display($file, $values)
{
@xeoncross
xeoncross / index.php
Created May 22, 2012 21:08
Validator Class
<?php
$validator = new Validator();
// Each validation rule is a property of the validator object.
$validator->username = function($value, $key, $self)
{
if(preg_match('~\W~', $value))
{
return 'Your username must only contain letters and numbers';
@jbroadway
jbroadway / Slimdown.md
Last active February 20, 2025 13:00
Slimdown - A simple regex-based Markdown parser.
<?php
class QueryBuilder implements IteratorAggregate
{
private $conn;
private $parts = array();
public function __construct(Connection $conn)
{
@xeoncross
xeoncross / README.md
Created August 15, 2012 16:13 — forked from jbroadway/Slimdown.md
Slimdown - A simple regex-based Markdown parser.

Slimdown

A very basic regex-based Markdown parser. Supports the following elements (and can be extended via Slimdown::add_rule()):

  • Headers
  • Links
  • Bold
  • Emphasis
  • Deletions
@igorw
igorw / build.sh
Created December 11, 2012 19:40
Static Site Generator
#!/bin/bash
# Amazing static site generator
# Works for PHP and HTML sites
# Assumes web root to be in /web
# Dumps the site into a directory named "static"
PORT=9999
php -S localhost:$PORT -t web >/dev/null &
PID=$!
@ircmaxell
ircmaxell / equality.php
Last active April 19, 2019 13:52
Unicode Set Functions
<?php
const ✓ = true;
const ✕ = false;
function ≠($left, $right) {
return $left != $right;
}
function ≅($left, $right) {