Skip to content

Instantly share code, notes, and snippets.

View dshafik's full-sized avatar
💫
Available for Hire!

Davey Shafik dshafik

💫
Available for Hire!
View GitHub Profile
diff --git a/runkit.c b/runkit.c
index 67c487b..4a15711 100644
--- a/runkit.c
+++ b/runkit.c
@@ -142,7 +142,7 @@ zend_module_entry runkit_module_entry = {
PHP_RSHUTDOWN(runkit),
PHP_MINFO(runkit),
#if ZEND_MODULE_API_NO >= 20010901
- PHP_RUNKIT_VERSION,
+ PHP_RUNKIT_VERSION,
<?php
date_default_timezone_set("America/New_York");
function gen() {
$i = 0;
while (true) {
file_put_contents("./log",
date("Y-m-d H:i:s") .' '.
(yield $i++) . ' ' .
PHP_EOL
, FILE_APPEND);
@dshafik
dshafik / gist:2900834
Created June 9, 2012 12:36
Git Completion Prompt
source $HOME/.bash_completion/git-completion.bash
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUPSTREAM="auto"
PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \[\033[1;31m\]$(__git_ps1 "(%s) ")\[\033[1;37m\]\$\[\033[00m\] '
@dshafik
dshafik / gist:2887343
Created June 7, 2012 08:11
xh-gui urlSimilartor
<?php
function _urlSimilartor($url)
{
//This is an example
$url = preg_replace("/[0-9]+/", "XXX", $url);
$qs = parse_url($url, PHP_URL_QUERY);
if ($qs) {
$parts = array();
parse_str($qs, $parts);
/*
$ http GET https://api.github.com/users/dshafik/repos
HTTP/1.1 200 OK
Server: nginx/1.0.13
Date: Wed, 25 Apr 2012 01:57:50 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 200 OK
X-RateLimit-Limit: 5000
<?php
class Registry {
/**
* @var array The store for all objects
*/
static private $store = array();
/**
@dshafik
dshafik / hl.py
Created March 25, 2012 10:56
CLI syntax highlighter
#!/usr/bin/env python
"""
Highlight stdin using pygments and output to stdout
Re-uses httpie.
Auto-detects the input language.
Will not colorize if piped into something else.
<?php
$pdo = new PDO("mysql:host=HOSTNAME", "USERNAME", "PASSWORD");
$query = $pdo->prepare("SHOW DATABASES");
$query->execute();
foreach ($query->fetchAll(PDO::FETCH_OBJ) as $row) {
$db = $row->Database;
echo "= $db =" . PHP_EOL;
$pdo->exec("USE $db");
The media type quality factor associated with a given type is determined by finding the media range with the highest precedence which matches that type. For example,
Accept: text/*;q=0.3, text/html;q=0.7, text/html;level=1,
text/html;level=2;q=0.4, */*;q=0.5
would cause the following values to be associated:
text/html;level=1 = 1
text/html = 0.7
text/plain = 0.3
image/jpeg = 0.5
#!/usr/bin/env python
"""
Convert JSON data to human-readable form.
(Reads from stdin and writes to stdout)
"""
import sys
import json