Skip to content

Instantly share code, notes, and snippets.

View abulte's full-sized avatar

Alexandre Bulté abulte

View GitHub Profile
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
@abulte
abulte / Dockerfile
Created November 1, 2015 18:46
Node Dockerfile / Docker-Compose
FROM node:0.12
EXPOSE 3000
RUN mkdir /code
WORKDIR /code
COPY package.json /code/
RUN npm install
RUN npm install -g nodemon
ADD . /code
### Keybase proof
I hereby claim:
* I am abulte on github.
* I am abulte (https://keybase.io/abulte) on keybase.
* I have a public key whose fingerprint is 2AF6 528B BA92 D7AC 4F92 DF0B D126 E953 8D0C 3164
To claim this, I am signing this object:
@abulte
abulte / directive.js
Last active January 2, 2016 20:29
Test fast click efficiency on mobile
module.directive('mesureTime', function() {
return {
restrict: 'A',
// require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
var timeTouch;
elm.on('click', function() {
if (timeTouch) {
alert(new Date().getTime() - timeTouch, " ms");
} else {
@abulte
abulte / gist:8112151
Last active May 14, 2016 16:30
Angular CORS *BAD* pratice
myApp.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}
]);
@abulte
abulte / htaccess
Created December 24, 2013 11:44
WordPress AngularJS CORS setup
# CORS Headers (add this)
<ifModule mod_headers.c>
Header always set Access-Control-Allow-Origin: "*"
Header always set Access-Control-Allow-Methods "POST, GET, PUT, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "X-Requested-With, content-type"
</ifModule>
# BEGIN WordPress (you should have this in your original WP .htaccess)
<IfModule mod_rewrite.c>
RewriteEngine On
@abulte
abulte / entity_menu_links-depends-on-i18n_menu.patch
Last active December 27, 2015 07:28
Patch entity_menu_links to depend on i18n_menu #drupal
@abulte
abulte / drupal-7-fetch-siblings-menu.php
Created October 24, 2013 12:05
Drupal 7 Fetch siblings of node in menu
<?php
// requires Menu Node API https://drupal.org/project/menu_node
// [ALB] ripped from submenutree.module
// Traverse down the tree to find our node, following in_active_trial
// This code stanza is loosely inspired by menu_set_active_trail()
$item = $current_item;
$tree = menu_tree_all_data($item['menu_name'], $item);
$my_tree = FALSE;
@abulte
abulte / drupal-fetch-children-node-menu.php
Last active December 25, 2015 05:09
Fetch children node from the current menu in Drupal 7
<?php
// requires Menu Node API https://drupal.org/project/menu_node
$children = array();
$trail = menu_get_active_trail();
if (count($trail)) {
$current_item = $trail[count($trail) - 1];
$parameters = array(
'active_trail' => array($current_item['plid']),
@abulte
abulte / mySampleMenusMigration.class.php
Last active May 30, 2019 13:12
Drupal menu creation with Migrate module from a CSV file - Got it from Google Cache of this page: http://www.mezasefi.com/d/en/blogs/nobu/2012-10-02/sample-migration-module-importing-menu-csv.html
<?php
class mySampleMenusMigration extends Migration {
public function __construct() {
parent::__construct(MigrateGroup::getInstance('mySampleMenusMigration'));
$this->description = t('Creates sample menues.');
// the csv file contains the header.
$dir = drupal_get_path('module', 'mySampleMigrate');
$this->source = new MigrateSourceCSV("$dir/sample_menus.csv", array(), array('header_rows' => 1));