Skip to content

Instantly share code, notes, and snippets.

@Crash--
Crash-- / gist:2793164
Created May 26, 2012 09:44
Remove all merged branch. Be careful if you have merged a branch into the master and continue to work on it and then you haven't merged it yet, this script will remove it.
git checkout master
git fetch
git remote prune origin
#Remove locally
git branch --merged master | grep -v 'master$' | xargs git branch -d
echo "Branches merged, to delete:"
git branch -r --merged master | sed 's/ *origin\///' | grep -v 'master$'
@Crash--
Crash-- / gist:3900328
Created October 16, 2012 16:21
Postfix : Remove messages from/to a specific from your queue
#change foo.bar@gmail\.com
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / foo.bar@gmail\.com$/ { print $1 }' | tr -d '*!' | postsuper -d -
@Crash--
Crash-- / gist:3902506
Created October 16, 2012 22:36
Rest method PUT not allowed
/** Zend 1.12 **/
/** bootstrap / routes **/
$front = \Zend_Controller_Front::getInstance();
$front->setParam('bootstrap',$this);
//REST API
$router = $front->getRouter();
$restRoute = new Zend_Rest_Route($front, array(), array(
'default' => array('rest'),
));
@Crash--
Crash-- / gist:4204272
Created December 4, 2012 14:08
Optimize ?
public function __get($key)
{
$func = array($this, 'get' . ucwords($key));
if (\is_callable($func)) {
return call_user_func($func);
}
}
@Crash--
Crash-- / gist:9526238
Last active August 29, 2015 13:57
Some HTML from epub 3 fixed-layout
<span class="s1 f49 fs7 l0" style=
"left:35909.7px;bottom:1711.58px;letter-spacing:-20px;word-spacing:20px;color:rgb(35,31,32);">
19</span><span class="s1 f53 fs8 l0" style=
"left:31691.7px;bottom:1702.37px;letter-spacing:-3px;word-spacing:20px;color:rgb(35,31,32);">P</span><span class="s1 f53 fs8 l0"
style=
"left:32025.8px;bottom:1702.37px;letter-spacing:-3px;word-spacing:20px;color:rgb(35,31,32);">e</span><span class="s1 f53 fs8 l0"
style=
"left:32312.6px;bottom:1702.37px;letter-spacing:-3px;word-spacing:20px;color:rgb(35,31,32);">o</span><span class="s1 f53 fs8 l0"
style=
"left:32625.4px;bottom:1702.37px;letter-spacing:-3px;word-spacing:20px;color:rgb(35,31,32);">p</span><span class="s1 f53 fs8 l0"
self = [super initPageWithID:_bookPageIdentifier.ID
book:_bookPageIdentifier.book
title:_bookPageIdentifier.title
titleHtml:_bookPageIdentifier.titleHtml
path:_bookPageIdentifier.path
thumbnail:_bookPageIdentifier.thumbnail
pagePrefix:_bookPageIdentifier.pagePrefix
pageShortPrefix:_bookPageIdentifier.pageShortPrefix
pageLongPrefix:_bookPageIdentifier.pageLongPrefix
parentPart:_bookPageIdentifier.parentPart
#!/bin/bash
for f in `find ./app/app/data -name "index.html"`;do
png=${f/html/png}
phantomjs ./bin/rasterize.js $f $png "entire page"
metadataFile=${f/index/meta-data}
metadataFile=${metadataFile/html/json}
IMG_CHARS=$(identify "${png}" 2> /dev/null) || die "${IMAGE} is not a proper image"
# grab width and height
@Crash--
Crash-- / gist:750d6e5c0e029ca71dc8
Created May 22, 2014 22:24
Firebase : Here we go!
var firebase = new Firebase('https://v****.firebaseio.com/exercices');
firebase.on('child_added', function(newExercice) {
$scope.$apply(function(){
updateExercices($scope.exercices, $scope.chartData, newExercice);
});
});
<?php
public function streamAction(){
$toto = $this->xml_stream_reader('./data/hg3.xml');
var_dump($toto);
return false;
}
public function xml_stream_reader($url)
{
@Crash--
Crash-- / catalogue netflixfr
Created September 15, 2014 08:52
Catalogue de netflix FR
Cinéma français
Delicatessen
Sheitan
Romance
Enter the Void
L'Appolonide, souvenirs de la maison close
Indochine
Ils
Swimming Pool