Skip to content

Instantly share code, notes, and snippets.

@subimage
subimage / backbone-prototype.js
Last active December 22, 2015 21:19
A Prototype.js => 1.7.1 compatible backbone.js 0.9.1 Used in production for Cashboard (http://cashboardapp.com)
// Backbone.js 0.9.1
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
//
// HACKED TO BE PROTOTYPE.JS COMPATIBLE BY [SUBIMAGE AT GMAIL DOT COM]
// REQUIRES PROTOTYPE >= 1.7.1
String.prototype.midTruncate = function(length, seperator){
var left, right;
length = length || 30, left = Math.ceil(length/2), right = Math.floor(length/2);
seperator = seperator || '…';
if (this.length<=(length+1)) return this.toString();
return this.slice(0,left).strip()+seperator+this.slice(-right,this.length).strip();
};
@MatthewZaso
MatthewZaso / JavaScript Prototype JS Example
Created January 18, 2013 18:50
This is a Scorecard class that was made for my multiplayer "Yahtzee" project. It uses Prototype.js and creates a new instance of a scorecard dynamically using SVG.
//////////////////////////////////////////////////////
// Class: Scorecard //
// Object that holds data for the user's rolls //
//////////////////////////////////////////////////////
// Scorecard constructor
function Scorecard(x,y,side,player) {
this.x = x;
this.y = y;
@RiANOl
RiANOl / gist:1077723
Last active April 4, 2024 08:34 — forked from anonymous/gist:957281
AES128 / AES256 CBC with PKCS7Padding in PHP
<?
function aes128_cbc_encrypt($key, $data, $iv) {
if(16 !== strlen($key)) $key = hash('MD5', $key, true);
if(16 !== strlen($iv)) $iv = hash('MD5', $iv, true);
$padding = 16 - (strlen($data) % 16);
$data .= str_repeat(chr($padding), $padding);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv);
}