Skip to content

Instantly share code, notes, and snippets.

@real34
real34 / plugins.js
Created May 23, 2012 09:03
Small JS plugins for use across applications
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function f(){ log.history = log.history || []; log.history.push(arguments); if(this.console) { var args = arguments, newarr; try { args.callee = f.caller } catch(e) {}; newarr = [].slice.call(args); if (typeof console.log === 'object') log.apply.call(console.log, console, newarr); else console.log.apply(console, newarr);}};
// make it safe to use console.log always
(function(a){function b(){}for(var c="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),d;!!(d=c.pop());){a[d]=a[d]||b;}})
(function(){try{console.log();return window.console;}catch(a){return (window.console={});}}());
// place any jQuery/helper plugins in here, instead of separate, slower script files.
@real34
real34 / APC-Recipe.rb
Created June 22, 2012 13:26
Capistrano : APC recipe to deal with Apache APC cache
##
# APC recipe
# => convenience rules for dealing with APC in applications
##
_cset(:apc_webroot) { "" }
namespace :apc do
desc <<-DESC
Create a temporary PHP file to clear APC cache, call it (using curl) and removes it
@real34
real34 / composer.json
Last active October 10, 2015 09:57
Illustration basique de tri d'un tableau de périodes et de fusion des périodes successives
{
"name": "real34/agist",
"description": "Sample composer file to proving hosting micropackages on Gists works",
"license": "MIT",
"autoload": {
"classmap": ["."]
}
}
@real34
real34 / browser_update.js
Last active October 12, 2015 14:18
Javascript : script to include for displaying a notification to users having an old browser. Based on top of http://www.browser-update.org/
/**
* Generic script for displaying a "Browser outdated" message to users
* Displays an overlay and a message including the Chrome Frame
*
* @see http://www.browser-update.org/fr/
*/
var $buoop = {
reminder: 168,
newwindow: true,
@real34
real34 / mysql_backup.sh
Created December 11, 2012 14:50
SHELL script to backup all MySQL databases
#!/bin/bash
### MySQL Server Login Info ###
MUSER="root"
MPASS="xxxx"
MHOST="localhost"
MYSQL="/usr/local/bin/mysql"
MYSQLDUMP="/usr/local/mysql/bin/mysqldump"
BACKUP_PATH="/data/backup/mysql"
GZIP="/bin/gzip"
@real34
real34 / .htaccess
Last active December 10, 2015 00:29
Page de maintenance simple et configurable avec .htaccess pour rediriger vers elle
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123 # Allowed IP
RewriteCond %{REQUEST_URI} !^/maintenance.php [NC]
RewriteRule .* /maintenance.php [L]
@real34
real34 / OccitechCakeTestCase.php
Last active December 10, 2015 13:59
Extended CakePHP test case class with convenience methods
<?php
App::uses('ControllerTestCase', 'TestSuite');
/**
* Occitech custom Test Library.
* Extends core librairy to add convenience methods.
*/
abstract class OccitechCakeTestCase extends ControllerTestCase {
protected $fixtures = array();
@real34
real34 / version.ctp
Created February 28, 2013 06:36
(Cake)PHP element allowing to display version information from a version.txt file along with revision if deployed with capistrano
<?php
/**
* Displays information about the current version of the application
*/
$basePath = ROOT . DS;
$appVersion = array_fill_keys(array('version', 'revision', 'timestamp'), '');
if (file_exists($basePath . 'version.txt')) {
$appVersion['timestamp'] = filemtime($basePath . 'version.txt');
$appVersion['version'] = file($basePath . 'version.txt');
# Depends on Occitech's CakePHP capistrano recipe (see https://github.com/occitech/capistrano-recipes)
server "xxxx.yyy.com", :app, :web, :db, :primary => true
set :deploy_to, "/xxx/yyy"
set :branch, "develop"
set :url_base, "http://xxx.occi-tech.com"
set :application, "Croogo"
set :repository, "git@xxx/yyy.git"
set :scm, :git
set :git_enable_submodules, 1
@real34
real34 / BugherdHelper.php
Created April 12, 2013 08:53
CakePHP 2.x helper to include in your Controllers to automatically inject Bugherd script in your layouts
<?php
App::uses('Helper', 'View/Helper');
App::uses('File', 'Utility');
class BugherdHelper extends Helper {
public $helpers = array();
private $__bugherdBlacklistedLayouts = array('ajax', 'admin_popup');