Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
7 total  XML / RSS feed 

Compressing a directory with rar on Linux

I've been struggling to get this to work for so long that when I finally got it going I had to throw it up here so I wouldn't lose it.
rar a -m5 -R output.rar /etc/

This will create a max compression (not taking into account dictionary sizes and the like) archive of the entire etc directory.

Attach Events

// takes this.events with format 'element:event': function(e) { } and attaches it

attachEvent: function(selector) {
  var sel = selector.split(':');
  var el =  this.el[sel[0]];
  var ev =  sel[1];
  if (!el)      return;
  if (!el.each) Event.observe(el, ev, this.events[selector]);
  else el.each( function(item, index) {
    Event.observe(item, ev, this.events[selector]);
  }.bind(this));
},
attachEvents: function() {
  for (property in this.events) this.attachEvent(property);
},
removeEvent: function(selector) {
  var sel = selector.split(':');
  var el = this.el[sel[0]];
  var ev = sel[1];
  if (!el) return;
  if (!el.each) Event.stopObserving(el, ev, this.events[selector]);
  else el.each(function(item, index) {
    Event.stopObserving(item, ev, this.events[selector]);
  }.bind(this));
},
removeEvents: function() {
  for (x in this.events) this.removeEvent(x);
}

Attach Elements

// takes this.el and copies it to this.elements, replacing CSS selector with DOM object(s)

attachElement: function(p) {
  this.el[p] = $$(this.elements[p]);
  if (this.el[p].length == 1) this.el[p] = this.el[p][0];
},
attachElements: function() {
  this.el = {};
  for (x in this.elements) this.attachElement(x);
},
clearElements: function() {
  for (x in this.el) this.el[x] = null;
}

Bind Functions

// these functions force a common 'this' on inner objects

bindTo: function(source, bindTo) {
  if (typeof source == 'function') return;
  for (x in source)
    if (typeof source[x] == 'function')
      source[x] = source[x].bind(bindTo);
},
bindAll: function() {
  this.bindTo(this.events,   this);
  this.bindTo(this.ajax,     this);
  this.bindTo(this.complete, this);
}

Custom Ajax.Request Function

// this is a custom function that simplifies creating an ajax object

function(url, complete, form, params) {
  params = params ? $H(params).toQueryString() : '';
  if (!complete) complete = function(r){};
  if (form)      params   = Form.serialize(form) + '&' + params;
  new Ajax.Request(url, 
    { asynchronous:true,
      evalScripts:true, 
      onComplete: function(r) { complete(r.responseText); },
      parameters:params
    });
}

Baseline CSS FINAL - 2006-07-01

Resets CSS so all browsers are the same, and sets a cross-browser base font size (verdana 13px)

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0;}
table{border-collapse:collapse;border-spacing:0;}
fieldset,img{border:0;}
cite,code,em,strong,th{font-style:normal;font-weight:normal;}
ol,ul{list-style:none;}
th{text-align:left;}
h1,h2,h3,h4{font-size:100%;}
q:before,q:after{content:'';}
body{font:13px verdana,sans-serif;*font-size:small;*font:x-small;}
table{font-size:inherit;font:100%;}
select,input,textarea{font:99% verdana,sans-serif;}
pre,code{font:115% monospace;*font-size:100%;}
body*{line-height:1.22em;}

Baseline CSS - 2006-07-01

Base font-sizing added to base.css

/*
        Reset default styles // base.css
        AUTH: Austin Govella (austin.govella@gmail.com)
        DATE: 2006-05-11
        DESC: Resets default styles for all browsers (merges Tantek Celik's undohtml.css and Yahoo's reset.css), and
              sets base font size to 13px verdana (based on Y!'s fonts.css).
        NOTE: Included in main.css w/ @import
        REVS: 2006-05-12 - Removed elements not commonly used - ACG
              2006-07-01 - Added base font sizing - ACG 
*/



/* Reset default styles across browsers
---------------------------------------- */
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0;}
table{border-collapse:collapse;border-spacing:0;}
fieldset,img{border:0;}
cite,code,em,strong,th{font-style:normal;font-weight:normal;}
ol,ul{list-style:none;}
th{text-align:left;}
h1,h2,h3,h4{font-size:100%;}
q:before,q:after{content:'';}



/* Set uniform base font size
---------------------------------------- */
body{font:13px verdana,sans-serif;*font-size:small;*font:x-small;}
table{font-size:inherit;font:100%;}
select,input,textarea{font:99% verdana,sans-serif;}
pre,code{font:115% monospace;*font-size:100%;}
body * {line-height:1.22em;}
« Newer Snippets
Older Snippets »
7 total  XML / RSS feed