Skip to content

Instantly share code, notes, and snippets.

View jrsalunga's full-sized avatar
💭
I may be slow to respond.

Jefferson Raga Salunga jrsalunga

💭
I may be slow to respond.
View GitHub Profile
@jrsalunga
jrsalunga / Collection-inside-Model
Created September 23, 2013 01:45
Collection inside Model
var Document = Backbone.Model.extend({
constructor: function() {
this.items = new ItemSet(null, {document: this});
this.items.on('change', this.save, this);
Backbone.Model.apply(this, arguments);
},
parse: function(resp) {
this.items.set(resp.items, {parse: true, remove: false});
delete resp.items;
return resp;
@jrsalunga
jrsalunga / gist:3705662
Created September 12, 2012 09:56
php random password generator
// string of random a-z, A-Z, 0-9
function generatePassword($length = 8) {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$count = mb_strlen($chars);
for ($i = 0, $result = ''; $i < $length; $i++) {
$index = rand(0, $count - 1);
$result .= mb_substr($chars, $index, 1);
}
@jrsalunga
jrsalunga / gist:3705639
Created September 12, 2012 09:53
random password generator for mysql
SELECT SUBSTRING(MD5(RAND()) FROM 1 FOR 6) AS password