Skip to content

Instantly share code, notes, and snippets.

import os
def relpath(path, root=''):
if not root:
root=os.curdir
path=os.path.normpath(path)
root=os.path.normpath(root)
common=os.path.commonprefix((path, root))
tail=root[len(common):]
var Tabs=new Class({
Implements: [Events, Options],
options: {
},
initialize: function(options){
@magmoro
magmoro / generic_8side_css.css
Created April 13, 2009 04:22
generate 8side css
v\:*{
behavior:url(#default#VML);
}
@magmoro
magmoro / splitter.py
Created April 12, 2009 18:55
splitter
splitter.py img.gif 10 10
splitter.py img.gif 10 15 20 12
@magmoro
magmoro / git_new_remote_branch.sh
Created March 15, 2009 09:22
new_remote_branch_git
git push origin master:refs/heads/test
#creates test branch
#or
git push origin local_branch:new_remote_branch
@magmoro
magmoro / builder.css
Created March 9, 2009 16:39
xml builder
h2, h3, h4{
font-weight:normal;
font-family:Georgia, serif;
padding-left:.5em;
}
h2{
background:#c3c3c3;
border-bottom:solid 1px #959595;
color:#6a6a6a;
XML.getNodes=function(node, xpath){
var found=[], foundNodes;
var root=node.ownerDocument||node;
if(Browser.Engine.trident){
root.setProperty("SelectionLanguage","XPath");
foundNodes=node.selectNodes(xpath)
for(var i=0, l=foundNodes.length; i<l; i++) found.push(foundNodes[i]);
}else{
foundNodes=root.evaluate(xpath, node, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i=0, l=foundNodes.snapshotLength; i<l; i++) found.push(foundNodes.snapshotItem(i));
var SVG={
ns: 'http://www.w3.org/2000/svg'
}
var svg = document.createElementNS(SVG.ns, 'svg').inject(document.body);
svg.setAttribute('width',100);
svg.setAttribute('height',100);
svg.setStyles({
position: 'absolute',
left:10,
top:10
// http://habrahabr.ru/blogs/svg/37595/
SVG = {
_NS: 'http://www.w3.org/2000/svg',
_regexp: {
istext: /text|tspan|tref/i,
translate: /translate\(([-\d\.]+),?\s*([-\d\.]*?)\)/i,
rotate: /rotate\(([\d\.]+),?.*?\)/i,
scale: /scale\(([\d\.]+),?.*?\)/i
},
function vmlImage(props){
var left=(props.left||0)-1;
var top=(props.top||0)-1;
var width=props.width+1;
var height=props.height+1;
var rect=new Element('v:rect',{
styles:{
width: width,
height: height,
left: left,