Skip to content

Instantly share code, notes, and snippets.

View squallstar's full-sized avatar
🍉

Nicholas Valbusa squallstar

🍉
View GitHub Profile
@squallstar
squallstar / time_ago.php
Last active January 15, 2020 14:09
Posted x time ago (PHP function)
<?php
function time_ago($date,$granularity=2) {
$difference = time() - $date;
$retval = '';
$periods = array('decade' => 315360000,
'year' => 31536000,
'month' => 2628000,
'week' => 604800,
'day' => 86400,
'hour' => 3600,
@squallstar
squallstar / gist:1957795
Created March 2, 2012 11:07
A simple sandbox for your webapp. Includes hooks on dom ready, pubsub pattern and much more.

JS Sandbox Application

A simple sandbox for your webapp. Includes hooks on dom ready, pubsub pattern and much more.

Requires jQuery 1.7+.

#Source

/**

@squallstar
squallstar / related_records.php
Created April 25, 2012 16:40
This helper function returns other records of the same categories of a given Record Object. To be added on the frontend_helper of Bancha 1.2
@squallstar
squallstar / Readme.md
Created April 26, 2012 07:54
Multiple subdomains on a single Bancha installation

Bancha multidomain plugin

How to install:

(soon)

@squallstar
squallstar / ellipsis.css
Last active December 21, 2015 22:59
css ellipsis
foo {
width:200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
@squallstar
squallstar / date.prototype.js
Last active December 23, 2015 08:59
Date UTC timestamp
Date.prototype.getUTCTimestamp = function() {
var currentTime, localOffset;
currentTime = this.getTime();
localOffset = (-1) * this.getTimezoneOffset() * 60000;
return Math.round(new Date(currentTime + localOffset).getTime() / 1000);
};
@squallstar
squallstar / Gruntfile.js
Last active January 10, 2016 11:10
Retina images with Grunt
//Grunt Spritesmith plugin
sprite: {
build: {
src: ['src/img/sprite/*.png'],
destImg: 'build/img/s-' + timestamp + '.png',
destCSS: 'src/scss/common/sprite.scss',
imgPath: '../img/s-' + timestamp + '.png',
algorithm: 'binary-tree',
engine: 'gm',
'engineOpts': {
@squallstar
squallstar / define.coffee
Created September 24, 2013 09:14
AMD/CommonJS/Module.exports
if typeof define is 'function' and define.amd
# AMD
define -> MyObject
else if typeof exports is 'object'
# CommonJS
module.exports = MyObject
else
# Global
MyObject.init()
@squallstar
squallstar / imgregexp.php
Created October 11, 2013 13:48
PHP Regexp to extract images
<?php
//Full image URLs will be extracted into $matches[2]
preg_match_all("/<(img)?+[^>]* src=['\"]([^\"']+\.(jpe?g|png)[#?]?[^\"']*?)[\"']/i", $html, $matches);
@squallstar
squallstar / meta.html
Last active December 31, 2015 18:29
Live tiles on Windows 8
<meta name="application-name" content="Your app name" />
<meta name="msapplication-TileColor" content="#000000"/>
<meta name="msapplication-square70x70logo" content="http://logo.png" />
<meta name="msapplication-square150x150logo" content="http://logo2.png" />
<meta name="msapplication-wide310x150logo" content="http://logo3.png" />
<meta name="msapplication-square310x310logo" content="http://logo4.png" />
<meta name="msapplication-notification" content="frequency=30; polling-uri=http://example.org/livetile/1.xml; polling-uri2=http://example.org/livetile/2.xml; polling-uri3=http://example.org/livetile/3.xml; polling-uri4=http://example.org/livetile/4.xml" />