Skip to content

Instantly share code, notes, and snippets.

View ryanmerritt's full-sized avatar

Ryan Merritt ryanmerritt

View GitHub Profile
@yshnb
yshnb / fabfile.py
Created April 3, 2013 18:10
fabfile to setup ssh-key in remote-server
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os,sys,time
import fabric
from fabric.contrib.files import *
from fabric.api import *
from fabric.operations import *
import ilogue.fexpect
@artofhuman
artofhuman / fabfile.py
Created January 28, 2013 18:18
example fabfile.py
# -*- coding: utf-8 -*-
from fabric.api import task
from fabric.api import run
from fabric.api import local
from fabric.api import env
from fabric.api import cd
from fabric.api import prefix
from fabric.api import hide
# Расположение зависимостей для проекта
from deployment.cuisine import *
from fabric.api import *
from fabric.context_managers import *
from fabric.utils import puts
from fabric.colors import red, green
import simplejson
import os
@midav
midav / fabfile.py
Created November 22, 2012 15:23 — forked from justinvoss/fabfile.py
Example Fabric and Cuisine Scrips
from deployment.cuisine import *
from fabric.api import *
from fabric.context_managers import *
from fabric.utils import puts
from fabric.colors import red, green
import simplejson
import os
@yann2192
yann2192 / fabfile.py
Created October 24, 2012 14:19 — forked from justinvoss/fabfile.py
Example Fabric and Cuisine Scrips
from deployment.cuisine import *
from fabric.api import *
from fabric.context_managers import *
from fabric.utils import puts
from fabric.colors import red, green
import simplejson
import os
@ryanmerritt
ryanmerritt / gist:3745830
Created September 18, 2012 20:54 — forked from philsturgeon/gist:3228499
DateTime comparison (strings)
<?php
function calculateDateDiff($strStart, $strEnd) {
$objStart = DateTime::createFromFormat("m/j/Y g:i:s A", $strStart);
$objEnd = DateTime::createFromFormat("m/j/Y g:i:s A", $strEnd);
// Return Total Seconds
return $objEnd->getTimestamp() - $objStart->getTimestamp();
// Return formatted diference (7hrs 5mins and 43 seconds)
return $objStart->diff($objEnd)->format('%hhrs %imins and %sseconds ');
@ryanmerritt
ryanmerritt / gist:3745827
Created September 18, 2012 20:53 — forked from philsturgeon/gist:3228471
Complicated Compare date difference (Seconds)
<?php
function calculateDateDiff($strStart, $strEnd) {
$parts = explode(' ', $strStart);
$dates = explode('/', $parts[0]);
$times = explode(':', $parts[1]);
$unix_start = mktime($times[0], $times[1], $times[2], $dates[0], $dates[1], $dates[2]);
$parts = explode(' ', $strEnd);
$dates = explode('/', $parts[0]);
$times = explode(':', $parts[1]);
@ryanmerritt
ryanmerritt / MyDateTime.php
Created September 18, 2012 10:23 — forked from colindecarlo/MyDateTime.php
Calculate the last <blank> of the month
<?php
class MyDateTime extends DateTime
{
protected $_daysOfTheWeek = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
public function lastDayOfTheMonth()
{
@ryanmerritt
ryanmerritt / formatDateTime.php
Created September 18, 2012 10:23 — forked from nomanson/formatDateTime.php
PHP function for formatting date and time
function format_datetime($examine_query)
{
$split_query = explode("FROM", $examine_query);
$result = mysql_query($examine_query);
$numfields = mysql_num_fields($result);
for ($i = 0; $i < $numfields; $i++)
{
$field_info = mysql_field_type($result, $i);
$field_name = mysql_field_name($result, $i);
@ryanmerritt
ryanmerritt / datetime.php
Created September 18, 2012 10:22
PHP MySQL DATETIME Conversion Code for both inserting into and displaying from a mysql db.
<?php
// DATE/TIME Manipulation for dates from php to mysql and back again
// get time and date right now for inserting datetime into mysql
// the field in the db should be set as a mysql "datetime" field type
// First - set the local timezone
date_default_timezone_set('America/New_York')
// use this in a hidden form field to insert the time into db record
echo date('Y-m-d H:i:s',time());