Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Launching...

Daniel Primo delineas

🚀
Launching...
View GitHub Profile
@delineas
delineas / parser.js
Created Feb 3, 2016
Javascript Token Parser
View parser.js
parseJwt = function(token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace('-', '+').replace('_', '/');
return JSON.parse(window.atob(base64));
}
@delineas
delineas / provision.sh
Created Feb 7, 2016
Drupal 7 vagrant debian
View provision.sh
#!/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 Feb 15, 2016
Sanitize Database Drupal: Drush Script
View mydrushfile_sanitize.drush.inc
<?php
/**
* @file
* Provide Drush integration for release building and dependency building.
*/
/**
* Implements hook_drush_help().
*/
@delineas
delineas / mymodule.module
Last active Feb 22, 2016
Drupal Redirect Node Domain Access
View mymodule.module
<?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 Mar 24, 2016
Install php5-mongodb extension
View commands.md

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 Mar 30, 2016
SSH Tunnel Mysql Vagrant
View ssh-tunnel.sh
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 Apr 7, 2016
Drupal 7 Bootsrap Level
View snippet.php
<?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 Apr 7, 2016
Create MySQL Database User
View mysql.sql
#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 Apr 11, 2016
Mount SSH Folder Mac OSX
View bash.sh
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 Apr 13, 2016
Forever SSH Tunnel with Vagrant Machine
View readme.md

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