Howto resize multiple pictures, graphics, images
for k in $(ls *.jpg); do convert -resize 800 -quality 80 $k r800-$k; done
11332 users tagging and storing useful source code snippets
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
for k in $(ls *.jpg); do convert -resize 800 -quality 80 $k r800-$k; done
<%=date_select(:date,'',:start_year => 1950,:include_blank => false, :default => { :year => '1970' })%> def convert_date(obj) return “#{obj[‘(1i)’]}-#{obj[‘(2i)’]}-#{obj[‘(3i)’]}” end
//+ Jonas Raoni Soares Silva //@ http://jsfromhell.com class JS{ //generic and maybe not the desired results xD function value($o){ if($o === null) return 'null'; $t = strtolower(gettype($o)); if($t == 'string' && is_numeric($o) && ($o[0] || strlen($o) == 1) || in_array($t, array('double', 'integer'))) $t = 'number'; elseif($t == 'string' && preg_match('@^\d{4}(?:-\d{1,2}){1,2}(?: (?:\d{1,2}:){2}\d{1,2})?$@', $o)) //strtotime works also with "strange" values strtotime('x') $t = 'date'; elseif($t == 'array' && ($c = count($k = array_keys($o))) && $k !== range(0, $c - 1)) $t = 'object'; elseif(!in_array($t, array('boolean', 'string', 'array', 'object'))) $t = 'string'; $t = 'from' . $t; return self::$t($o); } function fromNumber($o){ return +$o . ''; } function fromObject($o){ $r = array(); foreach($o as $n => $v) $r[] = self::fromString($n) . ':' . self::value($v); return '{' . implode(',', $r) . '}'; } function fromBoolean($o){ return $o ? 'true' : 'false'; } //$q = should quote? //$c = char that will be used to quote function fromString($o, $q = true, $c = '"'){ return ($p = $q ? $c : '') . preg_replace('/\r\n|\n\r|\r/', '\n', str_replace($c, '\\' . $c, str_replace('\\', '\\\\', $o))) . $p; } function fromArray($o){ $s = ''; foreach($o as $v) $s .= ($s ? ',' : '') . self::value($v); return '[' . $s . ']'; } function fromDate($o){ (is_numeric($o) && $o = +$o) || ($o = strtotime($o)) > 0 || ($o = mktime()); $o = explode(',', date('Y,n,j,G,i,s', $o)); foreach($o as $i => $v) $o[$i] = +$v; return 'new Date(' . implode(',', $o) . ')'; } }
$o = new stdClass; $o->abc = 123; echo implode("\n<br />", array( JS::value('1984-07-22 11:30:12'), JS::value('Test'), JS::value(1234), JS::value(true), JS::value(array(1,2,3)), JS::value(array('lala' => 'x')), JS::value($o) ));
for img in $(ls *.png); do convert $img -resize 75% smaller-$img; done;
//+ Jonas Raoni Soares Silva //@ http://jsfromhell.com/geral/utf-8 [v1.0] UTF8 = { encode: function(s){ for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l; s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i] ); return s.join(""); }, decode: function(s){ for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l; ((a = s[i][c](0)) & 0x80) && (s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ? o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "") ); return s.join(""); } };
var s = "aáéíóúe"; document.write( ('UTF8.encode("' + s + '") = ').bold(), UTF8.encode(s), "<br />", ('UTF8.decode(UTF8.encode("' + s + '"))) = ').bold(), UTF8.decode(UTF8.encode(s)) );
def date_add(sdate='', unit='',i=0) sdate[/(\d+)\/(\d+)\/(\d+)\s(\d+):(\d+):(\d+)/] iyear = $3.to_i; imonth = $2.to_i; iday = $1.to_i; ihour = $4.to_i; imin = $5.to_i; isec = $6.to_i case unit when 'days' t1 = Time.local(iyear,imonth,iday,ihour,imin,isec) t1 += (60 * 60 * 24 * i) when 'weeks' t1 = Time.local(iyear,imonth,iday,ihour,imin,isec) t1 += (60 * 60 * 24 * 7 * i) when 'months' imonth += i if imonth < 12 then t1 = Time.local(iyear,imonth+i,iday,ihour,imin,isec) else t1 = Time.local(iyear+=1,imonth -12,iday,ihour,imin,isec) end when 'quarter' imonth += 3 if imonth <= 12 then t1 = Time.local(iyear,imonth,iday,ihour,imin,isec) else t1 = Time.local(iyear+=1,imonth - 12,iday,ihour,imin,isec) end when 'years' t1 = Time.local(iyear+i,imonth,iday,ihour,imin,isec) else raise 'not a valid date unit' end t1 end
date_add("17/03/2008 17:48:00",'months',2)
tidy -asxhtml -numeric < index.html > index.xml
#add this to environment.rb #call to_iso on any UTF8 string to get a ISO string back #example : "Cédez le passage aux français".to_iso class String require 'iconv' #this line is not needed in rails ! def to_iso Iconv.conv('ISO-8859-1', 'utf-8', self) end end
mencoder video.mp4 -ovc lavc -vf scale=123:100 -oac lavc -o video.avi ffmpeg -i video.avi -ac 1 audio1.mp3
y = 'testing'.scan(/./) y.each do |c| puts c end