Skip to content

Instantly share code, notes, and snippets.

@dshaw002
dshaw002 / timemodel
Created December 10, 2012 19:40
Using Time Model
Saving time data into DB
$this->load->model('time_model');
$user_id = $this->session->userdata('id');
$user_timezone = $this->time_model->getTimeZone($user_id);
$format = "U"; // automatically saves it in unix format, this is just to show you that you can adjust format....
$data['timestamp'] = $this->time_model->getUTCTimeStamp($user_timezone, $format);
Shorthand: $data['timestamp'] = $this->time_model->getUTCTimeStamp($this->time_model->getTimeZone($this->session->userdata('id'));
@dshaw002
dshaw002 / Twitter
Created November 7, 2012 21:32
Javascript for About/Twitter
<script>
$(document).ready(function(){
$(document).on('click','.tour-modal-next', function(e){
e.preventDefault();
var tour_id= parseInt($(this).attr('id'));
tour_id++;
$('.tour-modal').hide();
if(tour_id != 5) {
$('#take-the-tour-'+tour_id).show();
@dshaw002
dshaw002 / gist:3762127
Created September 21, 2012 15:20
Regex Validate
$(document).ready(function(){
jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
phone_number = phone_number.replace(/\s+/g, "");
/*return this.optional(element) || phone_number.length > 9 &&
phone_number.match(/^\(\d{3}\) ?\d{3}( |-)?\d{4}|^\d{3}( |-)?\d{3}( |-)?\d{4}/);*/
return this.optional(element) || phone_number.length > 9 &&
phone_number.match(/^(\d{3})(-\d{3})(-\d{4})$/);
}, "Please specify a valid phone number<br>Example: 204-303-3403");
@dshaw002
dshaw002 / ValidateMe
Created August 14, 2012 20:09
Valdiator
$(document).ready(function(){
jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
phone_number = phone_number.replace(/\s+/g, "");
/*return this.optional(element) || phone_number.length > 9 &&
phone_number.match(/^\(\d{3}\) ?\d{3}( |-)?\d{4}|^\d{3}( |-)?\d{3}( |-)?\d{4}/);*/
return this.optional(element) || phone_number.length > 9 &&
phone_number.match(/^(\d{3})(-\d{3})(-\d{4})$/);
}, "Please specify a valid phone number<br>Example: 204-303-3403");