Skip to content

Instantly share code, notes, and snippets.

View knibals's full-sized avatar

Oumar Fall knibals

View GitHub Profile
@knibals
knibals / Drupal menu theming: items level
Last active August 29, 2015 14:01 — forked from henrijs/gist:6225177
Ajouter une classe du niveau du menu dans l'UL pour theming
```php
function themename_menu_link(&$vars) {
$element = $vars['element'];
$sub_menu = '';
$element['#attributes']['data-menu-parent'] = array($element['#original_link']['menu_name'] . '-' . $element['#original_link']['depth']);
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
@knibals
knibals / .gitignore
Last active August 29, 2015 14:22 — forked from mynameispj/.gitignore
Git Ignore SASS cache files
# Ignore docs files
styles/.sass-cache
styles/.sass-cache/*
To untrack a single file that has already been added/initialized to your repository, i.e., stop tracking the file but not delete it from your system use: git rm --cached filename
To untrack every file that is now in your .gitignore:
First commit any outstanding code changes, and then, run this command:
@knibals
knibals / GoWithC.go
Last active September 2, 2015 10:31 — forked from 17twenty/GoWithC.go
Cross Compiling and Language Interop oh my!
package main
import (
"./binding"
"fmt"
)
func main() {
binding.PrintHello()
binding.Seed(1)
fmt.Println(binding.Random())
<?php
/**
* Implements hook_form_alter().
*
* Redirects user logins to the front page.
*/
function HOOK_form_user_login_alter(&$form, &$form_state) {
$form['#action'] = url('user', array('query' => array('destination' => '<front>')));
}
@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'),
@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 {
@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 / 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 / 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 / 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.