Skip to content

Instantly share code, notes, and snippets.

View evaisse's full-sized avatar

Emmanuel Vaïsse evaisse

  • none
  • Nancy, France
View GitHub Profile
@evaisse
evaisse / ErrorHandler.php
Created January 28, 2011 17:05
A hardened error handler for PHP script
<?php # -*- coding:utf-8 -*-
/**
* handle exceptions, errors ( convert them into ErrorException instances) ,
* even fatal errors too via shutdown registrered function.
* Provide a pretty smart debug pageon demand
*
* @example
<?php
/**
* get file mimetype
*
* Tries to get mime data of the file.
*
* @param str $filepath
* @return str mime-type of the given file, or false if nothing found
*/
@evaisse
evaisse / backupThisFile.js
Created March 21, 2012 11:00
[KOMODO] backup this file
var filename = ko.views.manager.currentView.koDoc.baseName,
path = ko.views.manager.currentView.koDoc.displayPath;
/*
Set this to the path of your local directory where you want to backup your files
*/
var backupLocation = "/Users/evaisse/Library/Application Support/"
+ "KomodoEdit/autobackup";
@evaisse
evaisse / auto-find-snippets.js
Created March 21, 2012 11:04
[KOMODO] Run snippets from keyword
/**
* Get and run a snippets from your toolbox.
*
* First snippet name is guess by word under your cursor or before your
* cursor if none selected. In our example : "fooBar"
* The script search a snippet named :
* 1. the word join with the language name (lowercase) -> "php_fooBar"
* 2. the snippet name with preceding joker (def "any_") -> "any_fooBar"
*
* the snippet is run if found, and nothing happen otherwise (except a nice
@evaisse
evaisse / debug.php
Last active December 30, 2015 12:29
<?php
/**
*
*/
function my_exception_handler($exception)
{
print '<pre>';
print $exception;
print '</pre>';
@evaisse
evaisse / HarProxy.java
Last active September 6, 2016 10:07
HAR exporter using selenium webdriver & firefox custom profile using netexport & firebug
import java.io.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
import java.lang.InterruptedException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
#!/bin/sh
# vmstat_tool.sh
# vmstat parser script. Makes the information easily readable.
# Ensure that the number of loops and delay parameters
# were passed to this script
# examine output with : nohup vmstat_tool.sh 100 > ./vmstat.log &
if [ $# -ne 1 ]
then
echo "Usage: $0 count"
exit
@evaisse
evaisse / object.toquerystring.js
Last active October 19, 2017 00:09
Object.toQueryString - Vanilla JS version - encode object to POST, GET AJAX calls
/**
* Simply encode a base js object as {a:2, d:[1,"two"], c: {foo: {bar:1}}}
* And returns URL encoded string : a=2&d[0]=1&d[1]=two&c[foo][bar]=1"
*
* @param {Object} object A base javascript object : {}
* @param {String} base Optionnal base notation, should only be used by recursion for internal work
* @return {String} URL encoded query string
*/
Object.toQueryString = function (object, base) {
var queryString = [];
@evaisse
evaisse / gist:302b21637957a64155d5
Last active August 29, 2015 14:22
fatal with to without trace ?
<?php
function will_fatal()
{
a();
}
function a()
{
@evaisse
evaisse / poll2build.sh
Last active August 29, 2015 14:25
poll2build.sh
#!/bin/sh
# lockfile for script
LOCKFILE=/var/lock/poll2build.pid
# check lock file
[ -f $LOCKFILE ] && echo "script already running @ `cat /var/lock/poll2build.pid`" && exit 0;
# trap for cleanup lock file
trap "{ rm -f $LOCKFILE; exit 255; }" EXIT INT