Skip to content

Instantly share code, notes, and snippets.

View alOneh's full-sized avatar

Alain Hippolyte alOneh

  • @sensiolabscc
  • Paris, France
View GitHub Profile
@alOneh
alOneh / gist:1261518
Created October 4, 2011 12:31
Retrieve the path of a specific status with the output of git status -s (A, M, D, ??, ...)
// your_search can be : A, M, D, ??
git status -s | grep 'your_search' | awk '{print $2}'
@alOneh
alOneh / gist:1433101
Created December 5, 2011 10:09
Change the local timezone to UTC on unix
sudo rm /etc/localtime
sudo ln -s /usr/share/zoneinfo/UTC /etc/localtime
# now check it's ok
$ date
lun déc 5 10:03:47 UTC 2011
#!/bin/sh
# Go in to the Geoip folder
cd /usr/share/GeoIP
# Download the new database of city
wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
# Download the new database of country
wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
<?php
function good_indexes($sequence) {
$size_of_sequence = count($sequence);
$sum_lower_indexes = 0;
for ($i = 0; $i <= $size_of_sequence; $i++)
{
if (!isset($sequence[$i]))
{
@alOneh
alOneh / gist:1509940
Created December 22, 2011 11:13
Script that use OnlineSchemaChange of Facebook
// do online schema change
$alter = "ALTER TABLE ".$tableName." ADD ".$description .";
try {
$osc = new OnlineSchemaChange($sock, $user, $pwd, $db, null, $alter);
// Return true on success or false on failure
return $osc->execute();
} catch (Exception $e) {
@alOneh
alOneh / macros.html.twig
Created April 4, 2012 01:08
Macros for twig template
{# Todo : Manage dropdown and search form #}
{% macro navbar(items, active, options) %}
{% set active = active|default('home') %}
{% set options = {
'fixed': '',
'divider': ''|default(false),
'brand': ''
}|merge(options|default({}))
%}
@alOneh
alOneh / gist:2953365
Created June 19, 2012 10:10
RegexConverter for Flask app
# source http://stackoverflow.com/questions/5870188/does-flask-support-regular-expressions-in-its-url-routing
from flask import Flask
from werkzeug.routing import BaseConverter
app = Flask(__name__)
class RegexConverter(BaseConverter):
def __init__(self, url_map, *items):
super(RegexConverter, self).__init__(url_map)
self.regex = items[0]
<?php
$zip = new ZipArchive();
$t = $zip->open('MA.20130715-174538.ZIP');
$fp = $zip->getStream('MA.XML');
while (!feof($fp)) {
echo fread($fp, 4096);
}
fclose($fp);
$zip->close();
@alOneh
alOneh / www.example.com.conf
Created November 6, 2014 13:45
Symfony 1.4 Nginx configuration
server {
listen 80;
root /var/www/example.com/web;
index index.php;
server_name example.com.dev;
access_log /var/log/nginx/$host.access.log;
error_log /var/log/nginx/$host.error.log;
@alOneh
alOneh / Version00000000000000.php
Created September 15, 2016 09:36
Migration 0 exemple
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
class Version00000000000000 extends AbstractMigration
{
public function up(Schema $schema)