Skip to content

Instantly share code, notes, and snippets.

View simonjodet's full-sized avatar

Simon Jodet simonjodet

View GitHub Profile
@simonjodet
simonjodet / Database.php
Created October 19, 2012 08:33
Mockery - Partially mocking class's own methods
<?php
class Database
{
/**
* @var \Doctrine\DBAL\Connection
*/
private $conn;
public function __construct(\Silex\Application $app)
@simonjodet
simonjodet / atom.xml.twig
Created September 19, 2012 12:09
Gumdrop: Example of index page and RSS feed
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Simon's Blog</title>
<link href="http://blog.jodet.com/atom.xml" rel="self"/>
<link href="http://blog.jodet.com/"/>
<updated>{{ pages|reverse[0].date|date(DATE_ATOM) }}</updated>
<id>http://blog.jodet.com/</id>
<author>
<name>Simon Jodet</name>
</author>
@simonjodet
simonjodet / default.twig
Created September 19, 2012 11:30
Gumdrop: Example of post layout
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% if page.title != 'Home' and page.title != '' %}{{ page.title }} - {% endif %}Simon's Blog</title>
<link rel="stylesheet" href="/tools/bootstrap.min.css?cache={{ "now"|date("U") }}" type="text/css" charset="utf-8"/>
<link rel="stylesheet" href="/style/css/style.css?cache={{ "now"|date("U") }}" type="text/css" charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="Gumdrop">
<meta name="author" content="Simon Jodet">
<link rel="alternate" type="application/rss+xml" href="http://feeds.feedburner.com/jodet/blog"/>
@simonjodet
simonjodet / blog.domain.com
Created June 25, 2012 14:14
Blog Nginx configuration
server
{
listen 80;
server_name blog.domain.com;
location = /50x.html
{
root /var/www/nginx-default;
}
index index.html;
@simonjodet
simonjodet / gist:2988870
Created June 25, 2012 14:10
Blog post-receive hook
git push github master # I have setup a "github" remote on my /var/www/blog_repo/ repository in order to push my commits to github automatically with this line
cd /var/www/blog/ # Change directory to hosted sources
env -i git pull origin master # Pull commits from "origin" remote (/var/www/blog_repo/) into /var/www/blog/
export PATH="/var/lib/gems/1.8/bin/:$PATH" # Make sure gems are available for jekyll
jekyll --no-auto # Generage blog
php search_indexer/search_indexer.php # Update search index
@simonjodet
simonjodet / Anonymous.php
Created June 4, 2012 08:18
PHP anonymous class
<?php
/**
* This is an helper class to quickly create anonymous classes
* Usage:
* $shellWrapper = new Anonymous();
* $shellWrapper->exec = function($command) use($shellWrapper)
* {
* return exec($command);
* };
* $shellWrapper->exec('ls -la .');
@simonjodet
simonjodet / gist:2713959
Created May 16, 2012 21:07
Nginx configuration for pretty URLs in Silex
server
{
listen 80;
server_name website.loc www.website.loc;
access_log /var/log/nginx/website.access_log;
error_log /var/log/nginx/website.error_log;
root /var/www/website.loc/web/;
index index.php;
@simonjodet
simonjodet / gist:1570469
Created January 6, 2012 12:48
Extend TextMate
# Install Project+: http://ciaranwal.sh/projectplus
mkdir -p ~/Library/Application\ Support/TextMate/Bundles
cd !$
svn co http://svn.textmate.org/trunk/Review/Bundles/GetBundles.tmbundle/
osascript -e 'tell app "TextMate" to reload bundles'
@simonjodet
simonjodet / usb_eject.rb
Created December 18, 2011 08:35
Mac OS external drives eject tool
#!/usr/bin/env ruby
# External USB drives eject tool.
# You should install growlnotify to get notifications from http://growl.info/extras.php#growlnotify
# It will eject all USB disks and all mounted images. It will warn you with a red icon if something goes wrong
# It starts from the bottom to the top to tentavily eject the mounted images before the drive they could be on.
#
# Advices:
# - Use Automator to make this script an app
# - Install Better Touch Tool (http://www.boastr.de/) to give it a global shortcut
@simonjodet
simonjodet / gist:1472043
Created December 13, 2011 12:56
Ruby - Execute a shell command
cmd = 'ls'
stdin, stdout, stderr = Open3.popen3(cmd)
stdout = stdout.readlines.to_s
stderr = stderr.readlines.to_s