Skip to content

Instantly share code, notes, and snippets.

View necromant2005's full-sized avatar

Rostyslav Mykhajliw necromant2005

View GitHub Profile
@phred
phred / unserialize.php
Created September 7, 2011 19:04
Simple reliable and non-regex method to unserialize PHP session data
//
// This is the result of about an hour's delving into PHP's hairy-ass serialization internals.
// PHP provides a session_decode function, however, it's only useful for setting the contents of
// $_SESSION. Say, for instance, you want to decode the session strings that PHP stores in its
// session files -- session_decode gets you nowhere.
//
// There are a bunch of nasty little solutions on the manual page[1] that use pretty hairy regular
// expressions to get the job done, but I found a simple way to use PHP's unserialize and recurse
// through the string extracting all of the serialized bits along the way.
//
@artero
artero / launch_sublime_from_terminal.markdown
Last active January 25, 2024 16:57 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@jrom
jrom / nginx.conf
Created February 7, 2012 17:14
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@SocalNick
SocalNick / di.create-definitions.php
Created June 26, 2012 16:13
ZF2 Di definition compiler
<?php
// in ZF2 project, place this in ./bin directory
chdir(dirname(__DIR__));
$zf2Path = (getenv('ZF2_PATH') ?: 'vendor/ZendFramework/library');
require_once $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
require_once $zf2Path . '/Zend/Loader/StandardAutoloader.php';
use Zend\Loader\AutoloaderFactory;
use Zend\Loader\StandardAutoloader;
@Ocramius
Ocramius / di.create-definitions.php
Created June 26, 2012 16:32 — forked from SocalNick/di.create-definitions.php
ZF2 Di definition compiler
<?php
// in ZF2 project, place this in ./bin directory
chdir(dirname(__DIR__));
$zf2Path = (getenv('ZF2_PATH') ?: 'vendor/ZendFramework/library');
require_once $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
require_once $zf2Path . '/Zend/Loader/StandardAutoloader.php';
use Zend\Loader\AutoloaderFactory;
use Zend\Loader\StandardAutoloader;
@gllist
gllist / gist:3668037
Created September 7, 2012 17:36 — forked from markstreich/gist:3667944
PhantomJS: Ajax response capture through console.log
var page = require('webpage').create();
page.open('http://www.website.com/', function (status) {
if (status === 'success') {
captureAjaxResponsesToConsole();
}
});
function captureAjaxResponsesToConsole() {
// logs ajax response contents to console so sublime's onConsoleMessage can use the contents
@necromant2005
necromant2005 / deploy.rb
Created November 1, 2012 08:39
recipy php
ssh_options[:keys] = [File.join(Dir.pwd, "config", "ubuntu.pem")]
set :application, "MyAPPNAME"
set :repository, "git@github.com:necromant2005/MYAPPName.git"
# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
set :deploy_to, "/var/www/#{application}"
@surjikal
surjikal / prediction-io-ubuntu-precise.md
Last active March 24, 2017 11:33
Prediction IO Install Notes on Ubuntu Precise (12.04)
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@denji
denji / Phalcon-Zephir.md
Last active February 24, 2023 03:02
Zephir write your PHP Extension

About this article will do the following things:

  • Install & Setup
  • Write a simple Router
  • Zephir rewritten version
  • Extension installation and testing

Installation