Skip to content

Instantly share code, notes, and snippets.

View reactormade's full-sized avatar

Reactormade reactormade

View GitHub Profile
@reactormade
reactormade / days_between_two_dates.php
Created August 22, 2012 12:42
PHP days between two dates
function days_between($day_i,$month_i,$year_i,$day_f,$month_f,$year_f){
$days_in_between = (mktime(0,0,0,$month_f,$day_f,$year_f) - mktime(0,0,0,$month_i,$day_i,$year_i))/86400;
return $days_in_between;
}
//If we want to calculate the days between 21/8/2009 and 1/9/2009 then
echo days_between(21,8,2009,1,9,2009);
//would give us 11
@reactormade
reactormade / CI_sessions_table.sql
Created August 25, 2012 17:57
Create CI_Sessions table
CREATE TABLE `sessions` (
`session_id` varchar(40) NOT NULL DEFAULT '0',
`ip_address` varchar(16) NOT NULL DEFAULT '0',
`user_agent` varchar(50) NOT NULL,
`last_activity` int(10) unsigned NOT NULL DEFAULT '0',
`user_data` text NOT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@reactormade
reactormade / git_remove_tag.git
Created August 27, 2012 23:06
GIT remove tag
git tag -d tag
git push origin :refs/tags/tag
@reactormade
reactormade / hidpi.txt
Last active October 9, 2015 15:58 — forked from simX/hidpi.txt
Enable HiDPI mode in Mountain Lion w/o Quartz Debug
//enable HiDPI modes
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES;
//revert to default
sudo defaults delete /Library/Preferences/com.apple.windowserver DisplayResolutionDisabled;
@reactormade
reactormade / lowercase_perl.sh
Created September 4, 2012 12:52
SHELL convert string to lowercase using perl
echo $1|perl -e 'print lc <>;'
@reactormade
reactormade / gist:4038377
Last active October 12, 2015 14:08
Twitter Bootstrap multiple remote modals on same page
anchor(base_url().'sample/'.$object->hash,'<span class="btn btn-mini btn-info"><i class="icon-search icon-white"></i> View</span>',array('data-remote'=>base_url().'sample/'.$object->hash,'data-toggle'=>'modal','data-target'=>'#modal-sample'));
$('#modal-sample').on('hidden', function() {
$(this).removeData('modal');
});
@reactormade
reactormade / gist:4101300
Created November 17, 2012 23:18
Fix postfix on Mountain Lion
sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start
@reactormade
reactormade / get_url_parameter.js
Created December 10, 2012 19:00
Get URL parameter with JavaScript
function get_url_parameter(name) {
return decodeURI(
(new RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[null])[1]
);
}
/* apply a natural box layout model to all elements */
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
@reactormade
reactormade / gist:5052806
Last active December 14, 2015 07:48
Extract a string from an array of string if it matches to a another string (comparison)
function extract_matching_string_from_array($array_of_strings, $comparison){
$array = array();
foreach ($array_of_strings as $string):
if (strstr($string, $comparison)):
array_push($array, $string);
endif;
endforeach;
return $array;
}