Skip to content

Instantly share code, notes, and snippets.

@eerne
eerne / gist:123542
Created June 4, 2009 09:44
Array.remove()
Array.implement({
remove: function(i) {
var iSplat = $splat(i);
return this.filter(function(item, index){
return !iSplat.contains(index);
});
}
});
console.log( ['a', 'b', 'c', 'd'].remove(1) ) // returns ['a', 'c', 'd']
Document.implement({
id: (function(){
var types = {
string: function(id, nocash, doc){
id = doc.getElementById(id);
return (id) ? types.element(id, nocash) : null;
},
window.addEvent('domready', function(){
/* # Turns ul/li list into an Accordion, using MooTools 1.2.4.4
<ul>
<li><a href="#">Link A</a></li>
<li><a href="#">Link B</a></li>
<li class="active">
<a href="#">Link C</a>
<ul>
<li><a href="#">Sub A</a></li>
Slider.implement({
update: function(step){
// same as this.set() but doesn't fire any events
if (!((this.range > 0) ^ (step < this.min))) step = this.min;
if (!((this.range > 0) ^ (step > this.max))) step = this.max;
this.step = Math.round(step);
if (this.previousChange != this.step) this.previousChange = this.step;
this.knob.setStyle(this.property, this.toPosition(this.step));
if (this.previousEnd !== this.step) this.previousEnd = this.step;
// MooTools 1.3.0 Core Specs on Titanium Desktop 1.2.1
// Jasmine1.0.0.rc1 revision 1282853377
// 147 specs, 282 assertions, 40 failures in 5.619s
runshould return 'regexp' for RegExp objects
Expected 'RegExp' to equal 'regexp'.
function () {
expect(typeOf(/_/)).toEqual('regexp');
}
@eerne
eerne / ClassInsideAClass.py
Created November 30, 2010 18:29
Class inside a Class
class Outer():
def __init__(self):
self.test = 'LALALA LALA'
class Inner():
def readOuter(that):
that.blah = self.test
return that.blah
self.inner = Inner()
def what(self):
return self.inner.readOuter()
@eerne
eerne / ART.Ellipse2.js
Created January 7, 2011 22:33
Based on ART.Ellipse but with center in the middle rather than top/left
ART.Ellipse2 = new Class({
Extends: ART.Shape,
initialize: function(width, height){
this.parent();
if (width != null && height != null) this.draw(width, height);
},
draw: function(width, height){
@eerne
eerne / emailObfuscate.php
Created February 14, 2011 16:39
emailObfuscate output modifier for MODx
<?php
/**
* emailObfuscate output modifier for MODx
* Version: 1.0.0
*
* based on ObfuscateEmail plugin 0.9.1 (Apr 15, 2007) by Aloysius Lim.
* released under Public Domain.
* http://modxcms.com/extras/package/?package=322
*
* This modifier searches for all email addresses and "mailto:" strings in the
/*
---
source: http://gist.github.com/133677
provides: document.write
description: MooTools based document.write replacement
requires: MooTools
author: Thomas Aylott -- SubtleGradient.com
thanks: Daniel Steigerwald -- daniel.steigerwald.cz
@eerne
eerne / app.py
Created June 26, 2011 14:15
PySide testing python setup.py py2app
#!/usr/bin/env python
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtWebKit import *
app = QApplication(sys.argv)
view = QWebView(