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 / gist:94e9bd953c01a4ce8dad
Last active October 26, 2017 05:07
MySQL show processlist in realtime
watch -n1 'mysql -uUSER -pPASSWORD --execute="SHOW PROCESSLIST"'
@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 / sitemap-crawler.php
Last active September 11, 2023 10:51
Sitemap crawler to test 301 and 404.
/**
* Crawl the sitemap.xml for 301 redirections and 404 errors.
* Source: http://edmondscommerce.github.io/php/crawl-an-xml-sitemap-quality-check-301-and-404.html
*
* To use this script you need to allocate a huge amount of time to maximum_execution_time to
* avoid Fatal error: Maximum execution time...I suggest to run this script on terminal.
* Ex: $ php test-xml.php > ~/Desktop/sitemap-curl-result.txt
*
* For 3000 links the average time the script consumed is around 45 minutes to 1 hour.
*/
@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
@geraldvillorente
geraldvillorente / gist:81c45703765282c60b52
Created May 22, 2015 05:46
A decent way to avoid using setTimeout when checking for html element changes
$('selector', context).bind("DOMSubtreeModified", function() {
// Do something.
});
@geraldvillorente
geraldvillorente / facebook.util.php
Created June 7, 2015 23:32
Facebook cache buster.
<?php
/**
* Note: If the image is still missing just rerun this script until the cached has been cleared.
*
* To use this script either you can run this via terminal or browser.
* To run this in a terminal:
* $ php facebook.util.php [URL]
*
* To use the browser just put the URL in the text field.
*/
@geraldvillorente
geraldvillorente / gist:6376aa3e07617b49a9c2
Last active August 29, 2015 14:23
Registering a custom menu group under admin/config page.
/**
* Implements hook_menu().
*/
function my_custom_module_menu() {
$items = array();
$items['admin/config/custom'] = array(
'title' => 'Custom Settings',
'description' => 'App custom settings.',
'weight' => -30,
@geraldvillorente
geraldvillorente / gist:ebc60f26ed4852dbe077
Created June 22, 2015 04:22
Example of how to handle image in Amazon S3
function about_us_fetch_image() {
$image_url = NULL;
$fid = variable_get('about_us_image', '');
if (is_numeric($fid) && $fid > 0) {
$file = file_load($fid);
$dest_uri = 's3://about-us-resized.jpg';
// Check if the target image exists. If not, build it.
if (!file_exists($dest_uri)) {
// Copy the image.
file_copy($file, $dest_uri, FILE_EXISTS_REPLACE);