Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Mickaël Andrieu mickaelandrieu

🏠
Working from home
View GitHub Profile
View static_or_self.php
<?php
// sources: http://stackoverflow.com/a/4719222
class A {
public static function className(){
echo __CLASS__;
}
public static function test(){
self::className();
}
@mickaelandrieu
mickaelandrieu / .bashrc
Created January 30, 2014 17:03
From @lyrixx github
View .bashrc
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
if [ -d $HOME/.rbenv/bin ]; then
PATH="$HOME/.rbenv/bin:$PATH"
View .bash_aliases
## Common bash function
alias sudo="sudo " # Hack, for sudo an aliases
alias ls="ls --color"
alias l="ls -lh --color"
alias ll="ls -lh --color"
alias lla="ll -a --color"
alias df="df -h"
@mickaelandrieu
mickaelandrieu / minimal benchmark
Last active August 29, 2015 13:56
A very minimal benchmark: casperjs vs beautifulsoup4
View minimal benchmark
python version:
from bs4 import BeautifulSoup
import requests
r = requests.get("http://www.google.fr/search?num=100&q=scrapping")
data = r.text
View BaseManager.php
<?php
namespace Foo\Bar\BazBundle\Util;
abstract class BaseManager
{
protected $em;
protected $class;
View phantomPDF.js
/**
* @author Thomas Bley
* @licence GNU-FDL
* Source: http://we-love-php.blogspot.fr/2012/12/create-pdf-invoices-with-html5-and-phantomjs.html
*/
var page = new WebPage();
var system = require("system");
// change the paper size to letter, add some borders
// add a footer callback showing page numbers
View casperPDF.js
/**
* @author Mickaël Andrieu <mickael.andrieu@sensiolabs.com>
* @licence MIT
* Usage: casperjs casperPDF.js "[url]" [filename.<format>]
*/
var casper = require('casper').create({
pageSettings: {
paperSize: {
format: "Letter",
View TestFrameworkInATweet.php
<?php
function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}
View Makefile
run:
casperjs index.js && convert *.jpg video.mpeg && gify video.mpeg out.gif && rm *.jpg video.mpeg
@mickaelandrieu
mickaelandrieu / captureCollection.js
Created May 17, 2014 15:10
How to capture multiples images with the same class with CasperJS ?
View captureCollection.js
var clipRects = this.getElementsBounds('.list_item img.poster');
var i = 0;
clipRects.forEach(function(clipRect) {
casper.capture(i+'.png', clipRect);
i++;
});