Skip to content

Instantly share code, notes, and snippets.

View j0k3r's full-sized avatar

Jérémy Benoist j0k3r

View GitHub Profile
@pborreli
pborreli / import
Created May 10, 2010 14:42
Dealing with mass import in doctrine/pdo using pcntl_fork
<?php
class importTask extends sfTask
{
protected function execute($arguments = array(), $options = array())
{
$xml = simplexml_load_file('file');
$users = array();
foreach ($xml->users as $user)
{
@codepo8
codepo8 / localstorage.js
Created August 25, 2010 14:44
Store the state of a rendered form the easy way
<script>
// test for localStorage support
if(('localStorage' in window) && window['localStorage'] !== null){
var f = document.getElementById('mainform');
// test with PHP if the form was sent (the submit button has the name "sent")
<?php if(isset($_POST['sent']))){?>
// get the HTML of the form and cache it in the property "state"
localStorage.setItem('state',f.innerHTML);
@pborreli
pborreli / *Configuration.class.php
Created September 1, 2010 15:52
removing admin gen css files at app/project level
<?php
class privateConfiguration extends sfApplicationConfiguration {
public function configure() {
$this->dispatcher->connect('view.configure_format', array($this, 'listenToViewConfigureFormatEvent'));
}
@marcw
marcw / gist:909430
Created April 8, 2011 07:20
Add twig search to ack-grep
alias ack='ack-grep --type-set twig=.twig'
@coldnebo
coldnebo / Default (Linux).sublime-keymap
Created August 10, 2011 23:20
simple scripts to prettify your xml and json in sublime text 2
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]
@jakzal
jakzal / deploy.rb
Created November 28, 2011 16:11
Updating assets version before assetic dump (capifony)
namespace :symfony do
namespace :assets do
desc "Updates assets version"
task :update_version do
run "sed -i 's/\\(assets_version: \\)\\(.*\\)$/\\1 #{real_revision}/g' #{latest_release}/app/config/config.yml"
end
end
end
before "symfony:assetic:dump" do
@ubermuda
ubermuda / slice.sh
Created November 30, 2011 10:46
A small shellscript to slice a file into several smaller files
#!/bin/bash
INPUT_FILE=$1
LINES_PER_FILE=$2
if [ -z $LINES_PER_FILE ]; then
LINES_PER_FILE=1000
fi
if [ -z $INPUT_FILE ]; then
@ronanguilloux
ronanguilloux / PHP.sublime-build
Created December 15, 2011 15:34
php -l syntaxt check in sublime-text 2
// place this 'PHP.sublime-build' file in ~/.config/sublime-text-2/Packages/User/
{
"cmd": ["/usr/bin/php", "-l", "$file"],
"selector": "source.php",
"file_regex": "^Parse error: .* in (.*?) on line ([0-9]*)"
}
// Then restart ST2 & type 'CTRL+B' to use it
@damienalexandre
damienalexandre / gist:1507857
Created December 21, 2011 21:47
Web Storage API
// Stocker une valeur
sessionStorage.setItem('key', 'value');
localStorage.setItem('key', 'value');
// Récupérer une valeur
var item = sessionStorage.getItem('key');
var item = localStorage.getItem('key');
// Supprimer une valeur
sessionStorage.removeItem('key');
@everzet
everzet / composer.json
Created December 22, 2011 08:56
Install & use Behat+Mink with ALL dependencies through Composer
{
"require": {
"behat/behat": ">=2.2.2",
"behat/mink": ">=1.3.2"
},
"repositories": {
"behat/mink-deps": { "composer": { "url": "behat.org" } }
}
}