Skip to content

Instantly share code, notes, and snippets.

module.exports = function(grunt) {
// https://www.sitepoint.com/writing-awesome-build-script-grunt/
// http://paislee.io/testing-angularjs-with-grunt-karma-and-jasmine/
grunt.loadNpmTasks('grunt-karma');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
@pandauxstudio
pandauxstudio / gist:1d96c9833c96314055f4ee35d31d8f71
Created March 17, 2017 23:32
.htaccess URL Redirect only if base is requested
RewriteEngine on
RewriteRule ^$ http://pandaux.co/ [R=301,L]
Exec mysql client as root
$ mysqld -u mysql --skip-grant-tables &
Update your password
$ mysql -u root
Reload privileges
mysql> update mysql.user set password=password('newpassword') where user='root';
Kill mysqld
@pandauxstudio
pandauxstudio / gist:9379460
Last active August 29, 2015 13:57
Change database and table character set, this is useful for supporting Arabic language
ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
@pandauxstudio
pandauxstudio / gist:9101728
Created February 19, 2014 21:14
Timezone-Adjusted Timestamp
// Source: http://stackoverflow.com/questions/2834353/php-how-do-i-convert-a-server-timestamp-to-the-users-timezone
$timestamp = time();
echo 'Unix timestamp: ' . $timestamp;
$dt = DateTime::createFromFormat('U', $timestamp);
$dt->setTimeZone(new DateTimeZone($timezone));
$adjusted_timestamp = $dt->format('U') + $dt->getOffset();
echo ' Timestamp adjusted for: ' . $timezone . $adjusted_timestamp;
$monthName = date("F", mktime(0, 0, 0, $monthNum, 10));
@pandauxstudio
pandauxstudio / gist:8310908
Created January 8, 2014 02:43
Basic image cropping.
function momentImgResize(img, maxWidth, maxHeight) {
if (img.data('type') == 'placeholder') {
return;
}
var widthHeightRatio = 1.5;
var imgWidth = img.width();
var imgHeight = img.height();
@pandauxstudio
pandauxstudio / gist:8066425
Created December 21, 2013 07:18
Remove past months of months select of current year
removePastMonths = function (selectedYear, momentId) {
var curYear = (new Date).getFullYear();
var curMonth = (new Date).getMonth();
var monthSelect = $("#doneMomentMonth");
var monthSelectOptions = $("#doneMomentMonth > option");
// If current year is selected, remove past months
if (selectedYear == curYear) {
@pandauxstudio
pandauxstudio / gist:8045773
Created December 19, 2013 20:31
Add image placeholder if image is not found.
$("img").error(function () {
$(this).attr('src', '/images/photo-placeholder.jpg');
});
@pandauxstudio
pandauxstudio / gist:7556974
Created November 20, 2013 03:02
Synchronise two selected.
var countrySelects = $('[name="addresscountry"], [name="deliverycountry"]');
countrySelects.change(function(e) {
countrySelects.val(this.value);
});