Skip to content

Instantly share code, notes, and snippets.

@jbail
jbail / gist:706193
Created November 19, 2010 06:35
Python Private Member Black Magic
class Vault(object):
#here's our private variable
__secret = "subtle and insubstantial, the expert leaves no trace"
#getter method to return the secret variable
def get_secret(self):
return self.__secret
fort_knox = Vault()
@jbail
jbail / CrashIE
Created November 21, 2010 04:08
How to crash IE with JavaScript
for (d in document.write) {
document.write(d);
}
@jbail
jbail / overflow_content.css
Created November 29, 2010 21:37
Making scrollbars on HTML elements using CSS overflow properties
/*
* Make the element scroll on both x and y axes - CSS2
*/
.scroll-both {
overflow:scroll;
}
/*
* Make the element scroll on x axis only - CSS3
*/
@jbail
jbail / scroll_properties.js
Created November 29, 2010 21:42
Accessing scroll properties in JavaScript
var square = document.getElementById("square");
var content = document.getElementById("content");
/*
* Vertical y-axis properties
*/
square.offsetHeight; //the height in pixels of the scrollable element (e.g. 150px)
square.scrollTop; //the number of pixels from the top that the element is scrolled (e.g. 350px)
content.scrollHeight; //the total height in pixels of the scrollable content (e.g. 500px)
@jbail
jbail / fixed_dimension_square.css
Created December 3, 2010 16:12
Fixing height and width with CSS
/*
* This is for my outer square box
*/
#square{
width:150px;
height:150px;
background:#AFAFAF;
}
/*
* This is the content inside the square box
@jbail
jbail / scroll_elements_nested.html
Created December 3, 2010 16:16
Nesting elements to create fixed size scrolling HTML regions
<div id="square">
<div id="content"></div>
</div>
@jbail
jbail / scolling_content_example.html
Created December 3, 2010 16:49
Scrolling content horizontally or vertically - Example HTML using a dash of CSS3 and JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Scrolling content and getting properties - Example HTML using a dash of CSS3 and JavaScript</title>
<style>
.square{
width:150px;
height:150px;
background:#AFAFAF;
}
@jbail
jbail / sleep.js
Created April 12, 2011 17:34
A possible implementation of a JavaScript sleep function
function sleep (duration, fn) {
setTimeout(fn, duration);
}
console.time('for_loop_timer');
for (var i=0; i<1000; i++){
//nothing to see here, move along
}
console.timeEnd('for_loop_timer');
@jbail
jbail / gist:954304
Created May 3, 2011 21:33
relative css, the old jquery way
$('#box").css('padding-top', parseInt($('#box').css('padding-top'), 10) + 10);