Linux find/replace through multiple files in current directory (dangerous)
sed -i.orig 's/hello/goodbye/g' *
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!)
Nick Hammond nickhammond.com
sed -i.orig 's/hello/goodbye/g' *
email = $('email'); filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (filter.test(email.value)) { // Yay! valid return true; } else {return false;}
STATES = [ [ "Alabama", "AL" ], [ "Alaska", "AK" ], [ "Arizona", "AZ" ], [ "Arkansas", "AR" ], [ "California", "CA" ], [ "Colorado", "CO" ], [ "Connecticut", "CT" ], [ "Delaware", "DE" ], [ "Florida", "FL" ], [ "Georgia", "GA" ], [ "Hawaii", "HI" ], [ "Idaho", "ID" ], [ "Illinois", "IL" ], [ "Indiana", "IN" ], [ "Iowa", "IA" ], [ "Kansas", "KS" ], [ "Kentucky", "KY" ], [ "Louisiana", "LA" ], [ "Maine", "ME" ], [ "Maryland", "MD" ], [ "Massachusetts", "MA" ], [ "Michigan", "MI" ], [ "Minnesota", "MN" ], [ "Mississippi", "MS" ], [ "Missouri", "MO" ], [ "Montana", "MT" ], [ "Nebraska", "NE" ], [ "Nevada", "NV" ], [ "New Hampshire", "NH" ], [ "New Jersey", "NJ" ], [ "New Mexico", "NM" ], [ "New York", "NY" ], [ "North Carolina", "NC" ], [ "North Dakota", "ND" ], [ "Ohio", "OH" ], [ "Oklahoma", "OK" ], [ "Oregon", "OR" ], [ "Pennsylvania", "PA" ], [ "Rhode Island", "RI" ], [ "South Carolina", "SC" ], [ "South Dakota", "SD" ], [ "Tennessee", "TN" ], [ "Texas", "TX" ], [ "Utah", "UT" ], [ "Vermont", "VT" ], [ "Virginia", "VA" ], [ "Washington", "WA" ], [ "West Virginia", "WV" ], [ "Wisconsin", "WI" ], [ "Wyoming", "WY" ] ] <%= form.select :state, STATES, :include_blank => true %>
def trim_by_words(string,wordcount) string.split[0..(wordcount-1)].join(" ") +(string.split.size > wordcount ? "..." : "") end
simple_format(string)
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline; background: transparent; } :focus { outline: 0; } body { } ol, ul {list-style: none;} caption, th, td { text-align: left; font-weight: normal; } blockquote:before, blockquote:after, q:before, q:after {content: "";} blockquote, q {quotes: "" "";} strong{font-weight: bold;} em{font-style: italic;} .clear{clear: both;} #content:after{ content: "."; height: 0; display: block; clear: both; visibility: hidden; } .left, #left{ float: left; display: inline; } .right, #right{ float: right; display: inline; }
#something:after{ content: "."; height: 0; display: block; clear: both; visibility: hidden; }
config.active_record.timestamped_migrations = false
$(function(){ $('a[@rel$='external']').click(function(){ this.target = "_blank"; }); });
Event.observe(window, 'load', function() { $$('a[rel="external"]').each(function(link){ if(link.readAttribute('href') != '' && link.readAttribute('href') != '#'){ link.writeAttribute('target','_blank'); } }); });
<a rel="external" href="http://google.com">Google Rocks.</a>
<div id="slide-show"> <ul id="slide-images"> <li><img src="images/one.jpg" alt="One" title="One" /></li> <li><img src="images/two.jpg" alt="Two" title="Two" /></li> <li><img src="images/three.jpg" alt="Three" title="Three" /></li> </ul> </div>
#slide-images{ position:relative; display:block; margin:0px; padding:0px; width:290px; /* Adjust to width-height of your images */ height:142px; overflow:hidden; } #slide-images li{ position:absolute; display:block; list-style-type:none; margin:0px; padding:0px; background-color:#FFFFFF; } #slide-images li img{ display:block; background-color:#FFFFFF; }
var delay = 1000; var start_frame = 0; function init() { var lis = $('slide-images').getElementsByTagName('li'); for( i=0; i < lis.length; i++){ if(i!=0){ lis[i].style.display = 'none'; } } end_frame = lis.length -1; start_slideshow(start_frame, end_frame, delay, lis); } function start_slideshow(start_frame, end_frame, delay, lis) { setTimeout(fadeInOut(start_frame,start_frame,end_frame, delay, lis), delay); } function fadeInOut(frame, start_frame, end_frame, delay, lis) { return (function() { lis = $('slide-images').getElementsByTagName('li'); Effect.Fade(lis[frame]); if (frame == end_frame) { frame = start_frame; } else { frame++; } lisAppear = lis[frame]; setTimeout("Effect.Appear(lisAppear);", 0); setTimeout(fadeInOut(frame, start_frame, end_frame, delay), delay + 1850); }) } Event.observe(window, 'load', init, false);