Skip to content

Instantly share code, notes, and snippets.

View knibals's full-sized avatar

Oumar Fall knibals

View GitHub Profile
@knibals
knibals / docker-image-size.sh
Created May 11, 2018 12:16 — forked from andyrbell/docker-image-size.sh
Sort docker images by size desc
#!/bin/sh
docker images --format '{{.Size}}\t{{.Repository}}\t{{.Tag}}\t{{.ID}}' | sed 's/ //' | sort -h -r
@knibals
knibals / git-pre-receive-hook.sh
Created October 31, 2017 15:46 — forked from caniszczyk/git-pre-receive-hook.sh
A reasonable git pre-receive-hook
#!/bin/sh
#
# For each ref, validate the commit.
#
# - It disallows deleting branches without a /.
# - It disallows non fast-forward on branches without a /.
# - It disallows deleting tags without a /.
# - It disallows unannotated tags to be pushed.
@knibals
knibals / composer.json
Created October 22, 2017 17:45 — forked from Glutnix/composer.json
Checking PSR-2 validation with PHPCS using a pre-commit git hook.
{
"require-dev": {
"squizlabs/php_codesniffer": "2.0.*@dev"
},
"scripts": {
"post-install-cmd": [
"bash contrib/setup.sh"
]
}
}
@knibals
knibals / php-cs-fixer-pre-commit.php
Created October 22, 2017 17:44 — forked from mardix/php-cs-fixer-pre-commit.php
A pre-commit hook to make PHP code PSR-2 compliant, check for syntax error
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
@knibals
knibals / gist:f0da59599b2b249cf37325cfad604640
Created August 22, 2017 15:19 — forked from mtibben/gist:7078931
sublime-phpcs cheatsheet

sublime-phpcs cheatsheet

Install dependencies

brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php53 php-cs-fixer php-md php-code-sniffer
php-cs-fixer self-update
@knibals
knibals / redirectExample.go
Created August 16, 2017 09:18 — forked from d-schmidt/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
"log"
)
func redirect(w http.ResponseWriter, req *http.Request) {
// remove/add not default ports from req.Host
target := "https://" + req.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
Verifying that +knibals is my blockchain ID. https://onename.com/knibals
@knibals
knibals / Select theme by IP address
Created April 25, 2013 10:01
Select a specific theme by IP address (may be useful when THEMERS work collaboratively with DEV people)
<?php
/**
* @file helpers.module
*/
/**
* Implements hook_custom_theme().
* Activer le theme uniquement pour le themer (par adresse IP)
*/
@knibals
knibals / drupal_jquery_from_cdn.php
Created October 23, 2012 13:00
Retrieve jQuery from CDN (hook_js_alter)
/**
* Implements hook_js_alter().
*/
function YOUR_THEME_js_alter(&$js) {
if (isset($js['misc/jquery.js'])) {
$jquery_path = 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js';
$js['misc/jquery.js']['data'] = $jquery_path;
$js['misc/jquery.js']['version'] = '1.8.0';
$js['misc/jquery.js']['type'] = 'external';
}
@knibals
knibals / gist:2491501
Created April 25, 2012 17:31 — forked from mrconnerton/gist:1979037
node form in ctools modal drupal 7
<?php
/**
* Implements hook_menu().
*/
function mymodule_menu() {
$items['mymodule/%ctools_js/add'] = array(
'page callback' => 'mymodule_node_add_modal_callback',
'page arguments' => array(1),
'access arguments' => array('access content'),