Skip to content

Instantly share code, notes, and snippets.

View mehdichaouch's full-sized avatar
🤖
Happiness Developer

Mehdi Chaouch mehdichaouch

🤖
Happiness Developer
View GitHub Profile
@thomasfr
thomasfr / Git push deployment in 7 easy steps.md
Last active July 3, 2024 02:22
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@mhemmings
mhemmings / adminer.sh
Created January 30, 2014 22:52
Download Adminer like a boss! Found myself often wanting to quickly put Adminer on a box for a few minutes while I investigated something but couldn't remember the URL. This script downloads Adminer and also has some cool extra functionality, including automatic deletion (see --help for usage)
#!/bin/bash
usage() {
printf "%s\n" "Usage: $0 [-m] [-e] [-o] [-c] [-d]"
printf "\t%s\n\t%s\n\t%s\n\t%s\n" \
"-m MySQL only" "-e English only" "-o Output file" \
"-c CSS file to download" "-d Auto-delete time (minutes)"
exit 1
}
@tegansnyder
tegansnyder / create-admin-user.php
Created January 22, 2014 15:46
Create admin user programmatically
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
umask(0);
Mage::app();
try {
$user = Mage::getModel('admin/user')
->setData(array(
@Gremlyn
Gremlyn / MetadataExtension.php
Last active December 31, 2015 23:59
I needed a way to store metadata about entities that didn't follow a strict relational table structure. The data to be stored for each entity, in the example below they are 'Task' entities, could vary depending on what the given Task is. This means I needed an Entity-Attribute-Value model, which isn't readily supported by Doctrine. With the code…
<?php
namespace Acme\AppBundle\Twig;
use Acme\AppBundle\Service\MetadataInterface;
class MetadataExtension extends \Twig_Extension
{
private $task_metadata;
@akeemw
akeemw / prepare-commit-msg
Last active January 26, 2016 15:53 — forked from shytikov/commit-msg
Usage: Add "prepare-commit-msg" to your repos ".git/hooks"
#!/bin/sh
#
# Automatically adds branch name and branch description to every commit message.
# Unless we are on the master or develop branch.
#
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
TEXT=$(cat "$1" | sed '/^#.*/d')
@robwilkerson
robwilkerson / vagrant-provision-php.ini.sh
Created November 5, 2013 01:54
Modify php.ini to turn on errors for debugging and disable the short open tag.
# Show PHP errors
sed -i -r -e 's/short_open_tag = On/short_open_tag = Off/g' /etc/php5/fpm/php.ini
sed -i -r -e 's/error_reporting = E_ALL & ~E_DEPRECATED/error_reporting = E_ALL | E_STRICT/g' /etc/php5/fpm/php.ini
sed -i -r -e 's/display_errors = Off/display_errors = On/g' /etc/php5/fpm/php.ini
@hofmannsven
hofmannsven / README.md
Last active April 1, 2025 06:51
Git CLI Cheatsheet
@SeanCannon
SeanCannon / array_flatten.php
Last active October 28, 2024 18:01
PHP array_flatten() function. Convert a multi-dimensional array into a single-dimensional array.
<?php
/**
* Convert a multi-dimensional array into a single-dimensional array.
* @author Sean Cannon, LitmusBox.com | [email protected]
* @param array $array The multi-dimensional array.
* @return array
*/
function array_flatten($array) {
if (!is_array($array)) {
@jnaskali
jnaskali / new_gist_file
Created June 28, 2013 15:22
Google spreadsheet row update timestamp script
// Originally from http://webapps.stackexchange.com/questions/37408/google-docs-auto-updating-column-showing-last-modify-date
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
var r = s.getActiveCell();
if( r.getColumn() != 2 ) { //checks the column
var row = r.getRow();
var time = new Date();
time = Utilities.formatDate(time, "GMT+02:00", "d.M.y, h:m");
SpreadsheetApp.getActiveSheet().getRange('B' + row.toString()).setValue(time);
};
@lionelgaillard
lionelgaillard / gist:5785508
Last active December 18, 2015 12:48
Automatically dump your MySQL database on commit
#!/bin/bash
DBUSER="dbuser"
DBPASS="dbpass"
DB="dbname"
DUMPPATH="."
mysqldump -u $DBUSER -p$DBPASS $DB > $DUMPPATH/$DB.sql
git add $DUMPPATH/$DB.sql