Skip to content

Instantly share code, notes, and snippets.

@zgolus
zgolus / gist:2b7a56c2bc3ae1f6051b
Created September 11, 2015 12:45
one line server
ncat -l 8080 -k -c 'printf 0'
@zgolus
zgolus / gist:79dc1571c02d3d392ba3
Created May 3, 2015 19:31
console debugging with phpstorm
export XDEBUG_CONFIG="idekey=PHPSTORM"
@zgolus
zgolus / tidy.ini
Created February 27, 2015 23:41
minimal tidy config
#based on http://tidy.sourceforge.net/docs/quickref.html
#HTML, XHTML, XML Options Reference
anchor-as-name: no #?
doctype: omit
drop-empty-paras: no
fix-backslash: no
fix-bad-comments: no
fix-uri:no
hide-endtags: yes #?
#input-xml: yes #?
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
@zgolus
zgolus / CORS
Created June 25, 2014 18:23
CORS handling with PHP
<?php
// Specify domains from which requests are allowed
header('Access-Control-Allow-Origin: *');
// Specify which request methods are allowed
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
/*
* jQuery < 1.4.0 adds an X-Requested-With header which requires pre-flighting
@zgolus
zgolus / UnderscoreToCamelCase
Last active August 29, 2015 14:01
underscore to camel case
<?php
$key = preg_replace_callback(
'#_(\S)#',
function ($matches) {
return strtoupper($matches[1]);
},
$key
);
<?php
class UserManager
{
protected $couchbase;
public function __construct(\Couchbase $couchbase)
{
$this->couchbase = $couchbase;
}