Skip to content

Instantly share code, notes, and snippets.

@raynimmo
raynimmo / gist:e9a4cad9b64a86c9fcec
Created August 27, 2014 17:44
screen reorientation hack
$(document).ready(function () {
function reorient(e) {
var portrait = (window.orientation % 180 == 0);
$("body > div").css("-webkit-transform", !portrait ? "rotate(-90deg)" : "");
}
window.onorientationchange = reorient;
window.setTimeout(reorient, 0);
});
addLoadEvent(setSidebarNav);
function addLoadEvent(func) {
if (window.addEventListener)
window.addEventListener("load",func,false);
else if (document.addEventListener)
document.addEventListener("load",func,false);
@raynimmo
raynimmo / drupal-captcha-style-partial.scss
Created July 29, 2014 19:01
styling hooks for default drupal image captcha
fieldset .captcha{
legend{
.fieldset-legend{
}
}
.fieldset-wrapper{
.fieldset-description{
@raynimmo
raynimmo / gist:0fdc1d61d55282d061a3
Last active September 14, 2016 05:13
humans.txt
/* the humans responsible & colophon */
/* humanstxt.org */
/* TEAM */
Developer: Ray Nimmo
Site: http://www.junglecreative.com
Twitter: @raynimmo
Location: Koh Phangan, Thailand
@raynimmo
raynimmo / Drupal standard modules WGET
Last active September 14, 2016 05:17
WGET for various Drupal modules
/*
Views, Chaos Tools, Token, Pathauto, Libraries API, Admin Menu, Webform, IMCE, Google Analytics, Wysiwyg,
Backup Migrate, Captcha, XML Sitemap, Module Filter, CCK, Media, Global Redirect, Sitemap, Honeypot,
Disable CSS, Search 404
*/
wget http://ftp.drupal.org/files/projects/views-7.x-3.8.tar.gz http://ftp.drupal.org/files/projects/ctools-7.x-1.4.tar.gz http://ftp.drupal.org/files/projects/token-7.x-1.5.tar.gz http://ftp.drupal.org/files/projects/pathauto-7.x-1.2.tar.gz http://ftp.drupal.org/files/projects/libraries-7.x-2.2.tar.gz http://ftp.drupal.org/files/projects/admin_menu-7.x-3.0-rc4.tar.gz http://ftp.drupal.org/files/projects/webform-7.x-3.20.tar.gz http://ftp.drupal.org/files/projects/imce-7.x-1.9.tar.gz http://ftp.drupal.org/files/projects/google_analytics-7.x-2.0.tar.gz http://ftp.drupal.org/files/projects/wysiwyg-7.x-2.2.tar.gz http://ftp.drupal.org/files/projects/backup_migrate-7.x-3.0.tar.gz http://ftp.drupal.org/files/projects/captcha-7.x-1.1.tar.gz http://ftp.drupal.org/files/projects/xmlsi
@raynimmo
raynimmo / drupal list content types
Last active August 29, 2015 14:01
Drupal list all content types and fields
$content_types = node_get_types();
$output = '';
foreach($content_types as $content_type => $content_type_object) {
$output .= "" . $content_type_object->name . "";
$output .= ' ';
$fields = _content_type_info();
$fields = $fields['content types'][$content_type]['fields'];
$ouput = '';
foreach ($fields as $field_name=>$field) {
$output .= $field['widget']['label'];
@raynimmo
raynimmo / cookies.js
Created April 21, 2014 15:23
JavaScript for read, set & delete for cookies from http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
@raynimmo
raynimmo / tar.gz extract overwrite
Created March 28, 2014 18:14
extract .tar.gz and overwrite existing files
gunzip -c *.*.tar.gz | tar xopf -
@raynimmo
raynimmo / php-paths.php
Last active August 29, 2015 13:57
PHP file paths
__FILE__ (on Hosting) === /home/xfiddlec/public_html/folder1/folder2/yourfile.php
__FILE__ (on Localhost) === C:\wamp\www\folder1\folder2\yourfile.php
$_SERVER['HTTP_HOST'] === www.yoursite.com (or without WWW)
$_SERVER["PHP_SELF"] === /folder1/folder2/yourfile.php
$_SERVER["REQUEST_URI"] === /folder1/folder2/yourfile.php?var=blabla
$_SERVER["DOCUMENT_ROOT"] === /home/xfiddlec/public_html
//basename returns the last filename
basename('/folder1/folder2/yourfile.php') {i.e. basename(__FILE__) ==== yourfile.php
//dirname returns the part upper part, without filename [same as getcwd()]
@raynimmo
raynimmo / php-get-url.php
Created January 27, 2014 04:48
PHP get current page URL
function getUrl() {
$url = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] : 'https://'.$_SERVER["SERVER_NAME"];
$url .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";
$url .= $_SERVER["REQUEST_URI"];
return $url;
}