Skip to content

Instantly share code, notes, and snippets.

View delineas's full-sized avatar
🚀
Launching...

Daniel Primo delineas

🚀
Launching...
View GitHub Profile
@delineas
delineas / parser.js
Created February 3, 2016 23:54
Javascript Token Parser
parseJwt = function(token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace('-', '+').replace('_', '/');
return JSON.parse(window.atob(base64));
}
@delineas
delineas / provision.sh
Created February 7, 2016 19:19
Drupal 7 vagrant debian
#!/bin/sh
##### INFO #####
# provision.sh
#
# This script will provision a clean Ubuntu 12.04 LTS 64bit Vagrant box to be
# used for drupal 7 development.
#
# Author: Arradi Nur Rizal
@delineas
delineas / mydrushfile_sanitize.drush.inc
Created February 15, 2016 19:39
Sanitize Database Drupal: Drush Script
<?php
/**
* @file
* Provide Drush integration for release building and dependency building.
*/
/**
* Implements hook_drush_help().
*/
@delineas
delineas / mymodule.module
Last active February 22, 2016 11:40
Drupal Redirect Node Domain Access
<?php
function mymodule_init() {
if(arg(0) == 'node' && is_numeric(arg(1)) && !arg(2) && $node = node_load(arg(1))) {
$current_domain = domain_get_domain();
$domains = domain_get_node_domains($node->nid);
if (!in_array($current_domain['domain_id'], $domains['domain_id'])) {
$values = array_values($node->domains);
$sourceDomain = array_shift($values);
$sourceDomain2 = domain_lookup($sourceDomain);
//domain_goto($sourceDomain2);
@delineas
delineas / commands.md
Last active March 24, 2016 14:55
Install php5-mongodb extension

Install the php driver $ sudo pecl install mongodb

Create the extension file $ sudo nano /etc/php5/mods-available/mongodb.ini and write inside: extension=mongodb.so

Create a symbolic link for this file $ sudo ln -sv /etc/php5/mods-available/mongodb.ini /etc/php5/apache2/conf.d/20-mongodb.ini

Create an other symbolic link for this file $ sudo ln -sv /etc/php5/mods-available/mongodb.ini /etc/php5/cli/conf.d/20-mongodb.ini

Restart apache or the server used $ sudo service apache2 restart

@delineas
delineas / ssh-tunnel.sh
Last active March 30, 2016 17:33
SSH Tunnel Mysql Vagrant
ssh -N -L 3306:127.0.0.1:3316 -p 2222 -i ~/.vagrant.d/insecure_private_key vagrant@127.0.0.1
mysql -u root -proot -P 3316 -h 127.0.0.1
# Alternative
ssh -N -L 3317:127.0.0.1:3306 vagrant@VAGRANT_HOST -i /FOLDER/TO/VAGRANT/.vagrant/machines/default/virtualbox/private_key
mysql -u root -proot -P 3317 -h 127.0.0.1
@delineas
delineas / snippet.php
Created April 7, 2016 14:18
Drupal 7 Bootsrap Level
<?php
if (drupal_get_bootstrap_phase() >= DRUPAL_BOOTSTRAP_FULL) {
$message = theme('item_list', array());
}
// On earlier bootstrap stages not all theme functions are available.
else {
$message = theme_item_list(array());
}
@delineas
delineas / mysql.sql
Created April 7, 2016 20:25
Create MySQL Database User
#logged as root > mysql -u root -p
create database DATABASENAME character set utf8 collate utf8_general_ci;
create user DATABASEUSER@localhost identified by 'DATABASEUSER';
set password for DATABASEUSER@localhost = password('CHOOSE_PASSWORD');
grant select, insert, update, delete, create, drop, index, alter, create temporary tables, lock tables on DATABASENAME.* to DATABASEUSER@localhost;
flush privileges;
@delineas
delineas / bash.sh
Last active April 11, 2016 08:35
Mount SSH Folder Mac OSX
brew install sshfs
brew install sshfs ssh-copy-id
sshfs -o reconnect -o volname=MyVolName -o IdentityFile=~/.ssh/id_rsa username@HOSTIP:/var/www/html /Volumes/MyVolName
# Go to Finder > Volumnes
#Unmount
umount -f /Volumes/MyVolName
@delineas
delineas / readme.md
Created April 13, 2016 11:59
Forever SSH Tunnel with Vagrant Machine

First of all, create the script

# Command line
# Install sshpass and screen previously (apt-get install sshpass screen)
nano ssh_tunnel.sh

Paste into this file