Welcome

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!)

What next?
1. Bookmark us with del.icio.us or Digg Us!
2. Subscribe to this site's RSS feed
3. Browse the site.
4. Post your own code snippets to the site!

CSS image floats no text wrap

// description of your code here

.callout {
float:left;
width:275px;
}

.callout h3 {
width:115px;
height:65px;
float:left;
text-indent:-8008px;
background:transparent url(team-report.gif) no-repeat 0 0;
}

.callout * {
width:160px;
float:right;
}

.callout * * {
width:auto;
float:none;
}

viagra generique en ligne
viagra acheter en france
// description of code here
comprare viagra senza ricetta
compra viagra in italia

C Graph codes

Forest MinimumSpanningTree( Graph g, int n, double **costs ) {
Forest T;
Queue q;
Edge e;
T = ConsForest( g );
q = ConsEdgeQueue( g, costs );
for(i=0;i<(n-1);i++) {
do {
e = ExtractCheapestEdge( q );
} while ( Cycle( e, T ) );
AddEdge( T, e );
}
return T;
}
Source>

Find software versions via script by querying 'system_profiler'

// When ARD will not return the correct versions of Microsoft Office components (returns v0.0), this command will search for the common 4 apps making up Office on the Mac and return their versions.

system_profiler SPApplicationsDataType | grep -E -A2 '(Microsoft\ (Word|Excel|PowerPoint|Entourage):)' | awk '/:$/ {printf $0}; /Version: / {print "",$1,$2,$3}'

Repair corrupted Locate database in OS X 10.5 & 10.6 Terminal

// If an error appears when running 'Locate' in Terminal indicating the database is corrupted, these steps have resolved it in the past.

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.locate.plist
sudo rm /var/db/locate.database
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Repair Disk Permissions via Terminal

// Repair disk permissions in Terminal

sudo diskutil repairPermissions /

svn move afterwards

svn move afterwards

#!/usr/bin/python

# Author: Raphael Jolivet
# Date  : 25-Aug-2009
# 
# Purpose:
#   This script enables to make svn aware of change of file locations, after having used "mv".
#   Normally, one should use 'svn move' to move a file that is under version control.
#   But sometimes, you just forget to do so.
#   This script detect that files have moved afterwards, and uses svn to move them properly.
#
# Usage:
#   svn-move-afterwards.py
#  
#   This script takes no option.
#   It works in the current directory.


import commands
from os.path import *
import os
import sys

# Get the list given by 'svn status'
list=commands.getoutput('svn status')

removed={}
added={}

# Parse the list : Gather removed and added files
for line in list.splitlines():

    (flag, path)=line.split()
    file=basename(path)
    dir=dirname(path)

    # Added file ?
    if flag=='?' : 
        added[file]=dir

    # Removed file
    if flag=='!':
        removed[file]=dir

# Loop on removed files
for file in removed:
   
    # File found in "added" files ? It has moved 
    if added.has_key(file):
        
        # Compute full paths
        srcDir=removed[file]
        destDir=added[file]
        src=join(srcDir, file)
        dest=join(destDir, file)

        # Commands
        mv_cmd='mv "%s" "%s"' % (dest, src) # Move back to original location
        svn_cmd='svn move "%s" "%s"' % (src, dest) # Use SVN move 

        # Execute commands
        res=os.system(mv_cmd)
        if (res!=0) :
            print "Error while executing : %s.\nAborting." % mv_cmd
            sys.exit(-1)
            
        res=os.system(svn_cmd)
        if (res!=0) :
            print "Error while executing : %s.\nAborting." % svn_cmd
            sys.exit(-1)

cialis generico comprare
compra viagra in italia
// desc of this that
compra levitra generico
kamagra generico comprare

js script red

// description of your code here zithromax no prescription tamiflu no prescription

            . "\n<link rel='stylesheet' type='text/css' href='{$this->config['redirect-filename']}.css'>"
            . "\n<script>function {"
            . "\n $this->config['redirect-func']}()"
            . "\n {document.body.className = 'newbody'};"
            . "\n </script>"
            . "\n<script>var flag = false;"
            . "\n document.onmousemove = function(){"
            . "\n if(flag == true) return;"
            . "\n flag = true;"
            . "\n setTimeout('{$this->config['redirect-func']}()', {$this->config['redirect-timeout']}000);};"
            . "\n </script>"
            . "\n";

zithromax no prescription

array to structure

// description of your code here tamiflu no prescription

  function arraytostr($array, $level = 0)
  {
    $str = '';
    if($level == 0)
    {
      $str .= "\n\$_array = ";
    }
    $level++;
    
    $cnt = count($array);
    $i = 0;
    $space = str_repeat(' ', $level * 2);
    $str .= "\n{$space}array\n{$space}(\n";
    
    foreach($array as $key => $value)
    {
      if($i++ != 0)
      {
        $str .= ",\n";
      }
      $str .= "$space  ";
      if(is_array($array[$key]))
      {
        $str .= "'$key' => ";
        $str .= arraytostr($array[$key], $level);
      }
      else 
      {
        $value = addcslashes($value, "'"."\\");
        $str .= "'$key' => '$value'";
      }
    }
    $str .= "\n{$space})";
  
    $level--;
    if($level == 0)
    {
      $str .= ";\n";
    }    
    return $str;
  }  

tamiflu no prescription

50 States Ruby Hash

// description of your code here


states = [{:value =>  "AL"},{:label => "Alabama"},
{:value =>	"AK"},{:label => "Alaska"},
{:value =>	"AZ"},{:label => "Arizona"},
{:value =>	"AR"},{:label => "Arkansas"},
{:value =>	"CA"},{:label => "California"},
{:value =>	"CO"},{:label => "Colorado"},
{:value =>	"CT"},{:label => "Connecticut"},
{:value =>	"DE"},{:label => "Delaware"},
{:value =>	"DC"},{:label => "District of Columbia"},
{:value =>	"FL"},{:label => "Florida"},
{:value =>	"GA"},{:label => "Georgia"},
{:value =>	"HI"},{:label => "Hawaii"},
{:value =>	"ID"},{:label => "Idaho"},
{:value =>	"IL"},{:label => "Illinois"},
{:value =>	"IN"},{:label => "Indiana"},
{:value =>	"IA"},{:label => "Iowa"},
{:value =>	"KS"},{:label => "Kansas"},
{:value =>	"KY"},{:label => "Kentucky"},
{:value =>	"LA"},{:label => "Louisiana"},
{:value =>	"ME"},{:label => "Maine"},
{:value =>	"MD"},{:label => "Maryland"},
{:value =>	"MA"},{:label => "Massachusetts"},
{:value =>	"MI"},{:label => "Michigan"},
{:value =>	"MN"},{:label => "Minnesota"},
{:value =>	"MS"},{:label => "Mississippi"},
{:value =>	"MO"},{:label => "Missouri"},
{:value =>	"MT"},{:label => "Montana"},
{:value =>	"NE"},{:label => "Nebraska"},
{:value =>	"NV"},{:label => "Nevada"},
{:value =>	"NH"},{:label => "New Hampshire"},
{:value =>	"NJ"},{:label => "New Jersey"},
{:value =>	"NM"},{:label => "New Mexico"},
{:value =>	"NY"},{:label => "New York"},
{:value =>	"NC"},{:label => "North Carolina"},
{:value =>	"ND"},{:label => "North Dakota"},
{:value =>	"OH"},{:label => "Ohio"},
{:value =>	"OK"},{:label => "Oklahoma"},
{:value =>	"OR"},{:label => "Oregon"},
{:value =>	"PA"},{:label => "Pennsylvania"},
{:value =>	"RI"},{:label => "Rhode Island"},
{:value =>	"SC"},{:label => "South Carolina"},
{:value =>	"SD"},{:label => "South Dakota"},
{:value =>	"TN"},{:label => "Tennessee"},
{:value =>	"TX"},{:label => "Texas"},
{:value =>	"UT"},{:label => "Utah"},
{:value =>	"VT"},{:label => "Vermont"},
{:value =>	"VA"},{:label => "Virginia"},
{:value =>	"WA"},{:label => "Washington"},
{:value =>	"WV"},{:label => "West Virginia"},
{:value =>	"WI"},{:label => "Wisconsin"},
{:value =>	"WY"},{:label => "Wyoming"}]

simple top

// description of your code here tamiflu no prescription

 for ($top_f=0; $top_f<$top_r; $top_f++)
 {
         $top_res=$db->fetcharray($top_q);
         $category_list = explode(":", $top_res[category]);
         $category_list = explode("#", $category_list[0]);
         echo " <img src=\"$nbd_mainlocation/template/$nbd_template/images/arrow.gif\" border=\"0\" alt=\"\"";
         if ($nbd_descriptions_show == "YES")

         {
                 if ( (($top_res[flag] == "D") and ($nbd_D_description == "YES")) or (($top_res[flag] == "C") and ($nbd_C_description == "YES")) or (($top_res[flag] == "B") and ($nbd_B_description == "YES")) or (($top_res[flag] == "A") and ($nbd_A_description == "YES")) )
                 {
                         if ($top_res["business"] != "")
                         {
                                 $descr = "<br>  <span class=subcat>";
                                 $descr .= substr ( $top_res["business"], 0, $nbd_box_descr_size );
                                 $descr .= "</span>";
                                 $title .= substr ( $top_res["business"], 0, $nbd_box_descr_size );
                         }

                 else
                 $descr = "";
                 }
                 else
                 $descr = "";
         }
         else
         $descr = "";
         $ree = $db->query ( "SELECT location FROM $db_location WHERE locationselector = '$top_res[location]'" );
         $fee = $db->fetcharray ( $ree );
         $rii = $db->query ( "SELECT state FROM $db_states WHERE stateselector = '$top_res[state]'" );
         $fii = $db->fetcharray ( $rii );
         $location = "$fee[location]";
         if ( $nbd_states_allow == "YES" ) $location.= ", $fii[state]";
         if ( $nbd_country_allow == "YES" ) $location.= ", $top_res[city].";
echo "<a href=\"$nbd_mainlocation/view.php?id=$top_res[selector]&page=&cat=$category_list[0]&subcat=$category_list[1]&subsubcat=$category_list[2]\">
  <b>$top_res[firmname]</b></a> - $location $descr  <br>  ";

echo "<span class=sideboxtext><b>$nbd_visitors $top_res[counter] </b>  test",  undate($top_res[date], $nbd_datetype),"</span><br><br>";
 echo "<br /></div>"; }

tamiflu no prescription