Skip to content

Instantly share code, notes, and snippets.

View neotohin-snippet's full-sized avatar

neotohin-snippet

View GitHub Profile
@neotohin-snippet
neotohin-snippet / drupal:oop_module
Created April 26, 2013 15:39
drupal:oop_module
<?php
define('DOCROOT', dirname(__FILE__));
spl_autoload_register('st_oop_autoload');
/**
* Autoload Mechanism
*/
@neotohin-snippet
neotohin-snippet / htpasswd
Created January 21, 2013 09:55
htpasswd
**INLCUDE htpasswd**
To generate .htpasswd:
htpasswd -c ./.htpasswd admin
Add this in .htaccess:
AuthUserFile /home/test/public_html/.htpasswd
AuthGroupFile /dev/null
@neotohin-snippet
neotohin-snippet / javascript:GET_datas
Created January 15, 2013 13:05
javascript:GET_datas
getUrlVars: function() {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
@neotohin-snippet
neotohin-snippet / d7:webform:filesave
Created January 4, 2013 06:56
d7:webform:filesave
Hook Webform Presave: http://drupalcontrib.org/api/drupal/contributions%21webform%21webform.api.php/function/hook_webform_submission_presave/7
Writing to a csv or excel file : http://drupal.org/node/1177352
File Save with entity(Very short and simple code):
$entity = entity_load($id);
$data = file_get_contents($localpath);
$destination = file_create_filename(basename($localpath), file_default_scheme() . '://yourdir/' );
$file = file_save_data($data, $destination);
$entity->field_attachment[LANGUAGE_NONE][] = (array)$file;
@neotohin-snippet
neotohin-snippet / htaccess:redirection
Created December 21, 2012 14:00
htaccess:redirection
# Redirect root to /exploreap URI
RewriteRule ^$ /exploreap [R=301]
# Rewrite HTTP to HTTPS on some pages and sections
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} /user [NC,OR]
RewriteCond %{REQUEST_URI} /admin [NC,OR]
RewriteCond %{REQUEST_URI} ^/exploreap/thank-you-for-subscribing$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
@neotohin-snippet
neotohin-snippet / d7:code:date
Created November 23, 2012 10:12
d7:code:date
$node = node_load( 9 );
$date = $node->field_exam_date['und'][0];
$date_object = new DateObject($date['value'], new DateTimeZone($date['timezone_db']));
$date_object->setTimezone(new DateTimeZone($date['timezone']));
return date_format_date($date_object, 'custom', 'Y m d h:m:s');
@neotohin-snippet
neotohin-snippet / d7:entity:EntityFieldQuery
Created November 16, 2012 12:07
d7:entity:field_collection
<?php
// Getting All nodes of a particular type
// In my example its node type news
$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'news')
->propertyCondition('status', 1);
$results = $query->execute();
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" Increasing undo limits
set undolevels=1000