Skip to content

Instantly share code, notes, and snippets.

@psdtohtml5
psdtohtml5 / snippet.html
Created October 17, 2013 22:42
HTML : Wai-Aria template
<!doctype html>
<html>
<head>
<title>Title of your document</title>
<meta charset="utf-8">
<meta name="description" content="">
</head>
<body>
@psdtohtml5
psdtohtml5 / snippet.js
Created October 15, 2013 23:58
JavaScript : Add Business days to a date
// https://github.com/lsmith/addBusinessDays/blob/master/addBusinessDays.js
// var d = new Date();
// addBusinessDays(d, numberOfDays);
function addBusinessDays(d,n) {
d = new Date(d.getTime());
var day = d.getDay();
d.setDate(d.getDate() + n + (day === 6 ? 2 : +!day) + (Math.floor((n - 1 + (day % 6 || 1)) / 5) * 2));
return d;
}
@psdtohtml5
psdtohtml5 / snippet.txt
Created August 21, 2013 05:55
OPENSSL : Base64 Encode
openssl base64 < path/to/file.png | tr -d '\n' | pbcopy
@psdtohtml5
psdtohtml5 / snippet.php
Created August 17, 2013 13:54
PHP : Laravel 4 Database transactions
try {
DB::connection()->getPdo()->beginTransaction();
// database queries here
DB::connection()->getPdo()->commit();
} catch (\PDOException $e) {
// Woopsy
DB::connection()->getPdo()->rollBack();
}
@psdtohtml5
psdtohtml5 / snippet.php
Created August 17, 2013 13:53
PHP : Laravel 3 Database Transactions
try {
DB::connection()->pdo->beginTransaction();
// database queries here
DB::connection()->pdo->commit();
} catch (\PDOException $e) {
// Woopsy
DB::connection()->pdo->rollBack();
}
@psdtohtml5
psdtohtml5 / snippet.html
Created August 15, 2013 12:54
CSS : Sticky footer , Footer at bottom
<!-- SINGLE COLUMN LAYOUT -->
<div id="wrap">
<header id="header"></header>
<section id="main"></section>
</div>
<footer id="footer"></footer>
<!-- MULTI COLUMN LAYOUT -->
<div id="wrap">
<header id="header"></header>
@psdtohtml5
psdtohtml5 / snippet.js
Created August 12, 2013 21:39
JavaScript : Scroll and Focus to Element (input)
var cursorFocus = function(elem) {
var x = window.scrollX, y = window.scrollY;
window.scrollTo(x, y);
elem.focus();
}
cursorFocus(document.getelementbyId('search-terms'));
@psdtohtml5
psdtohtml5 / gist:6156480
Last active December 20, 2015 15:48
Google Maps
<script>
showMap([
{
target: "map-canvas",
locations: [
["Saved Home 1",-25.363882,131.040922],
["Saved Home 2",-25.363882,131.044922],
["Saved Home 3",-25.363882,131.048922],
["Saved Home 4",-25.363882,131.052922],
["Saved Home 5",-25.363882,131.056922],
@psdtohtml5
psdtohtml5 / gist:6114930
Created July 30, 2013 17:19
PHP : Extract image source from HTML
$doc = new DOMDocument();
$doc->loadHTML($html);
$tags = $doc->getElementsByTagName('img');
foreach ($tags as $tag) {
echo $tag->getAttribute('src');
}
@psdtohtml5
psdtohtml5 / gist:6114544
Created July 30, 2013 16:30
PHP : Get IP
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP']))
//check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
//to check ip is pass from proxy
{