Skip to content

Instantly share code, notes, and snippets.

View oshanz's full-sized avatar
🌴
On vacation

Oshan Wisumperuma oshanz

🌴
On vacation
View GitHub Profile
@oshanz
oshanz / gist:f7089e0432f4509e6fd4
Created October 11, 2014 06:14
my first backbone mess
/**
* @author Waruna Oshan Wisumperuma
* @contact warunaoshan@gmail.com
* Friday, October 03 2014 16:32:36
*
*/
"use strict";
var PaginCollection, ReportModel, paginTotal = 0;
@oshanz
oshanz / serializeArray
Created October 15, 2014 08:53
serializeArray
var o = {}, a = this.$('#contactForm').serializeArray();
$j.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
@oshanz
oshanz / viewHelper
Created January 29, 2015 09:50
backbone viewHelper
sortMonths : function(months) {
return _.intersection(['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], months);
}
getUniqPluck : function(arg, useCache) {
if (useCache) {
return this[arg] = this[arg] || _.uniq(_.pluck(this.List, arg)).sort();
} else {
return _.uniq(_.pluck(this.List, arg));
}
alert(([][[]]+[])[!+[]+!![]+!![]+!![]]+([]
[[]]+[])[+[]]+(!![]+[])[+[]]+([][[]]+[])
[+[]]+([]+{})[!+[]+!![]]+([][[]]+[])[!
+[]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!!
[]]+([][[]]+[])[!+[]+!![]+!![]]+([][[]]+[])
[!+[]+!![]+!![]]+(!![]+[])[+[]])
@oshanz
oshanz / date.sql
Last active August 29, 2015 14:27 — forked from johngrimes/date.sql
MySQL Date Dimension Build Script
/* Adapted from Tom Cunningham's 'Data Warehousing with MySql' (www.meansandends.com/mysql-data-warehouse) */
###### small-numbers table
DROP TABLE IF EXISTS numbers_small;
CREATE TABLE numbers_small (number INT);
INSERT INTO numbers_small VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
###### main numbers table
DROP TABLE IF EXISTS numbers;
CREATE TABLE numbers (number BIGINT);
@oshanz
oshanz / Serializor.php
Created October 16, 2015 09:07 — forked from bubba-h57/Serializor.php
Doctrine 2 Entities Serialized to JSON
<?php
namespace H57\Util;
class Serializor {
/**
* Converts the Doctrine Entity into a JSON Representation
*
* @param object $object The Object (Typically a Doctrine Entity) to convert to an array
@oshanz
oshanz / ssh message
Created January 23, 2014 16:10
Send message to remote PC via SSH
ssh -X login
export DISPLAY=:0
xmessage 'hi'
xdialog 'hi'
libnotify 'hi'
notify-send 'hi'
@oshanz
oshanz / jquery date range
Created January 25, 2014 05:05
jquery date range
$(document).ready(function() {
$("#From").datepicker({
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
maxDate: new Date(),
onClose: function(selectedDate) {
$("#To").datepicker("option", "minDate", selectedDate);
}
});
@oshanz
oshanz / jquery date as sql format
Created January 25, 2014 05:08
jquery date as sql format
var now = new Date();
var day = ("0" + now.getDate()).slice(-2);
var month = ("0" + (now.getMonth() + 1)).slice(-2);
var today = now.getFullYear()+"-"+(month)+"-"+(day) ;
$('#datePicker').val(today);
@oshanz
oshanz / ajax
Last active January 4, 2016 10:59
ajax
$.ajax({
type: 'post',
url: URL + 'index/updateDetails',
data: $('#form_updateUserDetails').serialize(),
//data: {'page': page, 'from': $('#From').val(), 'to': $('#To').val()},
success: function(data) {
// console.log(data);
$('#user_up_error').html(data);
setErrorOff();
listup();