Skip to content

Instantly share code, notes, and snippets.

View geraldvillorente's full-sized avatar

Stoick The Vast geraldvillorente

  • Philippines
View GitHub Profile
@geraldvillorente
geraldvillorente / angular_refresh.admin.inc
Last active August 29, 2015 14:06
Add more field using #ajax framework in Drupal 7
<?php
/**
* @file
* Angular View admin file.
*/
function angular_refresh_endpoints($form, &$form_state, $no_js_use = FALSE) {
$form['#attached']['css'] = array(
drupal_get_path('module', 'angular_refresh') . '/angular_refresh.css',
);
@geraldvillorente
geraldvillorente / ubuntu-vagrant-drupal
Created November 27, 2014 00:12
Setting up a Drupal Environment in Ubuntu Vagrant
Do these steps inside your Vagrant machine.
1. Web Server
sudo apt-get install apache2
2. PHP5
sudo apt-get install php5 libapache2-mod-php5
3. MySQL
sudo apt-get install mysql-server mysql-client
@geraldvillorente
geraldvillorente / gist:2dd435f6cd7ac98da7eb
Created December 17, 2014 01:05
Getting the latest watchdog entry from watchdog table using watch command
watch -n 1 "mysql -u <user> -e 'SELECT message, referer, FROM_UNIXTIME('timestamp') FROM watchdog ORDER BY 'timestamp' DESC LIMIT 0,1' <database_name>"
@geraldvillorente
geraldvillorente / gist:48bbdfa630bb8a358612
Created February 3, 2015 13:14
Convert REQUEST_TIME into human-readable format
$machine_format = 1422969167;
echo date('l, F j, Y g:i a', $machine_format);
// Output
Wednesday, February 4, 2015 12:12 am
To control the workstation using x2x:
ssh -XC user@host x2x -[north,east,south,west] -to :0.0
This requires to have x2x installed on the target machine.
@geraldvillorente
geraldvillorente / gist:611c9a3cb9bbcfbf2637
Created March 23, 2015 06:06
How to get the git commit log or changelog
git log --no-merges --pretty=format:"%h - %an, %ar : %s" --since="February 13 2015"
@geraldvillorente
geraldvillorente / gist:bf1695a6e3a5955a7b68
Created April 12, 2015 02:16
Admin module and Bootstrap css fix
/* Put this css in your subtheme css */
/* Bootstrap admin menu fix */
.logged-in #admin-toolbar ul.menu li a,
.logged-in div#admin-toolbar.vertical div.admin-tab {
height: 26px;
}
@geraldvillorente
geraldvillorente / gist:cb994d91c4afdb4c00b9
Last active August 29, 2015 14:19
Find orphaned files in Drupal
SELECT fm.filename
FROM file_managed AS fm
LEFT OUTER JOIN file_usage AS fu
ON ( fm.fid = fu.fid )
LEFT OUTER JOIN node AS n
ON ( fu.id = n.nid )
WHERE (fu.TYPE = 'node' OR fu.TYPE IS NULL)
AND n.nid IS NULL;
@geraldvillorente
geraldvillorente / gist:65dae6173b64426f6e51
Created April 17, 2015 08:39
Drupal auto refresh using AngularJS
(function ($, Drupal) {
Drupal.behaviors.refresh = {
attach: function(context, settings) {
var app = angular.module('app', []);
app.controller('appController', function($scope, Poller) {
$scope.data = Poller.data;
});
@geraldvillorente
geraldvillorente / gist:6fc664f5a60638813a3c
Created May 18, 2015 00:30
How to install Drush on Ubuntu
$ sudo apt-get install php-pear
$ sudo pear channel-discover pear.drush.org
$ sudo pear install drush/drush
$ sudo drush
$ sudo chown -R $USER:$USER ~/.drush