Never been to DZone Snippets 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

About this user

Andrew Ayer http://andrew.beanwood.com/

« Newer Snippets
Older Snippets »
Showing 1-5 of 5 total  RSS 

Quickly Copy Large Directory Tree Via SSH

To copy the entire directory tree at /some/path to other.host via SSH...

   1  
   2  find /some/path -print | sort | cpio -o -Hnewc | ssh -C other.host "cpio -idvum"


Make sure you use an absolute path to the directory tree. Existing files on the destination host will be overwritten unconditionally.

Set the title of an xterm or rxvt window

Badly formatted post broke our parser. Please edit!

Decode an encoded query string in C

Here's a little function to decode part of a query string that has been encoded as per the HTML specification with %xx notation, where xx is the hexidecimal representation of a character.

Be warned that this function modifies the contents of the string you pass as the argument!

   1  
   2  #include <stdlib.h>
   3  
   4  char* decode_query (char* str)
   5  {
   6          char*           in = str;
   7          char*           out = str;
   8  
   9          char            c = 0;
  10          char            decode_buffer[5] = { '0', 'x', 0, 0, 0 };
  11  
  12          while ((c = *in++)) {
  13                  if (c == '%' && *in && *(in + 1)) {
  14                          decode_buffer[2] = *in++;
  15                          decode_buffer[3] = *in++;
  16  
  17                          c = char(strtod(decode_buffer, (char**) NULL));
  18                  } else if (c == '+')
  19                          c = ' ';
  20  
  21                  *out++ = c;
  22          }
  23  
  24          *out = 0;
  25  
  26          return str;
  27  }

Always Show Vertical Scrollbar in Firefox

To always show the vertical scrollbar, regardless of whether there is content to scroll (à la Internet Explorer), add this to userContent.css

   1  
   2  html {
   3       overflow: -moz-scrollbars-vertical;
   4  }


Tested in Firefox 1.0 and above.

Auto-Sizing DIVs

To have a <DIV> shrink and enlarge based on its content, use this CSS:

   1  div.autosize { display: table; width: 1px; }
   2  div.autosize > div { display: table-cell; }


In your HTML, enclose the <DIV> you want autosized in another <DIV> with class="autosize"

Before:

   1  
   2  <div>
   3  I want this to be auto sized!
   4  </div>


After:

   1  
   2  <div class="autosize">
   3  <div>
   4  I want this to be auto sized!
   5  </div>
   6  </div>


Tested in Firefox, Mozilla, Safari, Opera 7, and Internet Explorer 6.
« Newer Snippets
Older Snippets »
Showing 1-5 of 5 total  RSS