Select spacer images
<img src="[\w\/\-\_]*spacer.[jpeg|jpg|gif|png]+[^>]*/?>
2827 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 (or not, you can keep them private!)
<img src="[\w\/\-\_]*spacer.[jpeg|jpg|gif|png]+[^>]*/?>
ffunction resizeImgOO(el) { function imgRatio() { return (el.height / el.width); } function holderRatio() { return (el.offsetParent.offsetHeight / el.offsetParent.offsetWidth); } function fitToContainer() { if(imgRatio>holderRatio) { el.height = el.offsetParent.offsetHeight; } else { el.width = el.offsetParent.offsetWidth; } } this.imgRatio = imgRatio; this.holderRatio = holderRatio; this.resize = fitToContainer; } var img = new resizeImgOO(document.getElementById('yourImgId')); img.resize();
hdiutil burn image.iso
#! /usr/bin/env ruby require 'open-uri' $home_dir = `echo $HOME`.chomp `mkdir #{$home_dir}/tmp` `mkdir #{$home_dir}/.tmp` $tmp_dir = $home_dir + "/.tmp" Dir.chdir($tmp_dir) # Where wget will download files before moving. puts "Files will be stored under -> #{$home_dir}/tmp" #-- Filters for others -- # $otvali_re = /http:\/\/img.otvali.ru\/[0-9]{4}\/[0-9]{2}\/[a-z0-9_]+_[0-9]{1,2}\.jpg/ $friendz_re = /thumbs\/([a-z0-9_]+.jpg)/ # -- Superiorpics Filters -- # $fake_link = /(http:\/\/img[0-9]+.image(shack|venue)+\.(us|com)+\/(my|img).php\?image=(\w+_?)+\.jpg)/ $shack_link = /(http:\/\/img[0-9]+.image(shack|venue)+\.(us|com)+\/(\w_?-?)+\/(\w_?-?)+\/(\w+_?)+\.jpg)/ $av_link = /src="((\w_?-?)+\/(\w_?-?)+\/(\w+_?)+\.jpg)/i # -- Filters for HollywoodTuna -- # $tuna_small = /(\/images\/(\w+_?)+\.jpg)/ def makeNewFolder puts "OK, where do you want to hide these? Or ENTER and I'll do it for you." answer = gets if answer !="\n" $new_folder_name = answer.gsub(/[\s\W]/, '_').chomp else $new_folder_name = File.basename($address, ".*").gsub(/[\s\W]/, '_') end $path_to_new_dir = $home_dir + "/tmp/" + $new_folder_name + "/" `mkdir #{$path_to_new_dir}` puts "Created: " + $new_folder_name puts "Path --> " + $path_to_new_dir end def cleanUp puts "Moving files to #{$path_to_new_dir}..." `mv #{$home_dir}/.tmp/*.jpg #{$path_to_new_dir}` end ## Main Program ## $pages = Array.new puts "Enter URL:" $address = gets.chomp if $address =~ /otvali.ru/ puts "Scanning page..." $pages = open($address).read.scan($otvali_re).delete_if { |x| x =~ /_s__/ } # Remove thumbnails. Their URLs contains "_s__" elsif $address =~ /friends.kz/ puts "Scanning page..." $pages = open($address).read.scan($friendz_re).flatten!.uniq $pages.collect! { |path| "http://friends.kz/uploads/posts/" + path } elsif $address =~ /superiorpics/ puts "Scanning page..." $pages = open($address).read.scan($fake_link).flatten!.delete_if { |i| i !~ /http/ } # Remove all regex objects save the full URL $pages.collect! do |page| if page =~ /imageshack/ puts "Resolving #{page}" open(page).read.scan($shack_link)[0][0] # Returns the actual link buried under two arrays of Regex objects elsif page =~ /imagevenue/ puts "Resolving #{page}" path_to_pic = open(page).read.scan($av_link)[0][0] av_direct = "http://" + URI.parse(page).host + "/" + path_to_pic end end elsif $address =~ /(hollywoodtuna|tunaflix)/ puts "Who do you want? ENTER to take'em all! Start with OMIT for negative search." search_string = gets.chomp.gsub(/ /, "|" ) # Prepare to feed into Regex tuna_want = Regexp.new(search_string) puts tuna_want puts "Scanning page..." $pages = open($address).read.scan($tuna_small).flatten!.delete_if { |i| i !~ /(th|tn|small)\.jpg$/ } $pages.collect! do |page| page.gsub!("images", "images/bigimages") page.gsub!(/(th|tn|small)\.jpg$/, "big.jpg") tuna_direct = URI.parse($address).host + page end if search_string =~ /^OMIT/ $pages.delete_if { |i| i =~ tuna_want } else $pages.delete_if { |i| i !~ tuna_want } end end ## Report total of found images, if nothing then exit the program. $pages.uniq! puts $pages if $pages.length == 0 puts "Yeah right. Nice try. Off you go!" exit elsif $pages.length <= 20 puts "What?! #{$pages.length}, is that all?" elsif $pages.length >= 21 puts "What're y'fuckin nuts??! #{$pages.length} !!!" end makeNewFolder $threads = [] $down_count = 0 for pic_to_fetch in $pages $threads << Thread.new(pic_to_fetch) do |link| puts "Fetching #{link}" %x{wget --quiet --random-wait #{link}} $down_count += 1 puts "Downloaded " + $down_count.to_s + "/" + $pages.length.to_s end end $threads.each {|thr| thr.join } dwn_actual = Dir.entries($tmp_dir).length-2 cleanUp dwn_moved = Dir.entries($path_to_new_dir).length-2 if $pages.length == dwn_actual and dwn_actual == dwn_moved puts "All completed @ #{Time.now.hour}:#{Time.now.min}. See y'around, dirty boy." elsif dwn_moved <= dwn_actual diff = dwn_actual - dwn_moved puts "#{diff} got lost in the moving, baby. Goodbye." elsif dwn_actual <= $pages.length diff = $pages.length - dwn_actual puts "#{diff} got lost coming down. Goodbye." end
procedure Flaxen( Bitmap:TBitmap); var H,V:Integer; WSK,WSK2,WSK3:^TRGBTriple; begin Bitmap.PixelFormat:=pf24bit; for V:=0 to Bitmap.Height-1 do begin Wsk:=Bitmap.ScanLine[V]; Wsk2:=Wsk; Wsk3:=Wsk; inc(Wsk2); inc(Wsk3,2); for H:=0 to Bitmap.Width -1 do begin Wsk.rgbtRed := (Wsk.rgbtRed + Wsk2.rgbtGreen + Wsk3.rgbtBlue) div 3; Wsk2.rgbtGreen := (Wsk.rgbtGreen + Wsk2.rgbtGreen + Wsk3.rgbtBlue) div 3; Wsk2.rgbtBlue := (Wsk.rgbtBlue + Wsk2.rgbtGreen + Wsk3.rgbtBlue) div 3; inc(Wsk);inc(Wsk2);inc(Wsk3); end; end; end;
procedure Emboss(Bitmap : TBitmap; AMount : Integer); var x, y, i : integer; p1, p2: PByteArray; begin for i := 0 to AMount do begin for y := 0 to Bitmap.Height-2 do begin p1 := Bitmap.ScanLine[y]; p2 := Bitmap.ScanLine[y+1]; for x := 0 to Bitmap.Width do begin p1[x*3] := (p1[x*3]+(p2[(x+3)*3] xor $FF)) shr 1; p1[x*3+1] := (p1[x*3+1]+(p2[(x+3)*3+1] xor $FF)) shr 1; p1[x*3+2] := (p1[x*3+1]+(p2[(x+3)*3+1] xor $FF)) shr 1; end; end; end; end;
procedure MonoNoise(var Bitmap: TBitmap; Amount: Integer); var Row:^TRGBTriple; H,V,a: Integer; begin for V:=0 to Bitmap.Height-1 do begin Row:=Bitmap.ScanLine[V]; for H:=0 to Bitmap.Width-1 do begin a:=Random(Amount)-(Amount shr 1); Row.rgbtBlue :=IntToByte(Row.rgbtBlue+a); Row.rgbtGreen :=IntToByte(Row.rgbtGreen+a); Row.rgbtRed :=IntToByte(Row.rgbtRed+a); inc(Row); end; end; end;
procedure ColorNoise( Bitmap: TBitmap; Amount: Integer); var WSK:^Byte; H,V,a: Integer; begin Bitmap.PixelFormat:=pf24bit; for V:=0 to Bitmap.Height-1 do begin Wsk:=Bitmap.ScanLine[V]; for H:=0 to Bitmap.Width*3-1 do begin Wsk^:=IntToByte(Wsk^+(Random(Amount)-(Amount shr 1))); inc(Wsk); end; end; end;
Procedure GrayScale(var Bitmap:TBitmap); var Row:^TRGBTriple; // wskaźnik do rekordu reprezentującego składowe RGB Pixela H,V,Index:Integer; begin Bitmap.PixelFormat:=pf24bit; for V:=0 to Bitmap.Height-1 do begin Row:=Bitmap.ScanLine[V]; for H:=0 to Bitmap.Width -1 do begin Index := ((Row.rgbtRed * 77 + //77 to stała dla czerwieni Row.rgbtGreen* 150 + //150 stała dla zielonego Row.rgbtBlue * 29) shr 8); //29 stała dla niebieskiego Row.rgbtBlue:=Index; Row.rgbtGreen:=Index; Row.rgbtRed:=Index; inc(Row); { Nie wolno przypisywać X:=0 lub 1,2 bo to Wskaźnk!!! poruszamy się inc() lub dec()} end; end; end;
procedure Sepia ( Bitmap:TBitmap;depth:byte); var Row:^TRGBTriple; H,V:Integer; begin Bitmap.PixelFormat:=pf24bit; for V:=0 to Bitmap.Height-1 do begin Row:=Bitmap.ScanLine[V]; for H:=0 to Bitmap.Width -1 do begin Row.rgbtBlue :=(Row.rgbtBlue +Row.rgbtGreen +Row.rgbtRed)div 3; Row.rgbtGreen:=Row.rgbtBlue; Row.rgbtRed :=Row.rgbtBlue; inc(Row.rgbtRed,depth*2); //dodane wartosci inc(Row.rgbtGreen,depth); if Row.rgbtRed < (depth*2) then Row.rgbtRed:=255; if Row.rgbtGreen < (depth) then Row.rgbtGreen:=255; inc(Row); end; end; end;
Procedure Blur( var Bitmap :TBitmap); var TL,TC,TR,BL,BC,BR,LL,LC,LR:^TRGBTriple; H,V:Integer; begin Bitmap.PixelFormat :=pf24bit; for V := 1 to Bitmap.Height - 2 do begin TL:= Bitmap.ScanLine[V - 1]; TC:=TL; // to samo Scanline Bitmap.ScanLine[V - 1]; tylko oszczędniej TR:=TL; BL:= Bitmap.ScanLine[V]; BC:=BL; BR:=BL; LL:= Bitmap.ScanLine[V + 1]; LC:=LL; LR:=LL; inc(TC); inc(TR,2); inc(BC); inc(BR,2); inc(LC); inc(LR,2); for H := 1 to (Bitmap.Width - 2) do begin //Wyciągam srednią z 9 sąsiadujących pixeli BC.rgbtRed:= (BC.rgbtRed+ BL.rgbtRed+BR.rgbtRed+ TC.rgbtRed+ TL.rgbtRed+TR.rgbtRed+ LL.rgbtRed+ LC.rgbtRed+LR.rgbtRed) div 9 ; BC.rgbtGreen:=( BC.rgbtGreen+ BL.rgbtGreen+BR.rgbtGreen+ TC.rgbtGreen+ TL.rgbtGreen+TR.rgbtGreen+ LL.rgbtGreen+ LC.rgbtGreen+LR.rgbtGreen) div 9 ; BC.rgbtBlue:=( BC.rgbtBlue+ BL.rgbtBlue+BR.rgbtBlue+ TC.rgbtBlue+ TL.rgbtBlue+TR.rgbtBlue+ LL.rgbtBlue+ LC.rgbtBlue+LR.rgbtBlue )div 9 ; //zwiększam wskaźniki biorąc następne 9 pixeli inc(TL);inc(TC);inc(TR); inc(BL);inc(BC);inc(BR); inc(LL);inc(LC);inc(LR); end; end; end;
procedure Lightness( Bitmap:TBitmap; Amount: Integer); var Wsk:^Byte; H,V: Integer; begin Bitmap.PixelFormat:=Graphics.pf24bit; for V:=0 to Bitmap.Height-1 do begin Wsk:=Bitmap.ScanLine[V]; for H:=0 to Bitmap.Width*3-1 do begin Wsk^:=IntToByte(Wsk^+((255-Wsk^)*Amount)div 255); inc(Wsk); end; end; end;
procedure Darkness( Bitmap:TBitmap; Amount: integer); var Wsk:^Byte; H,V: Integer; begin Bitmap.pixelformat:=pf24bit; for V:=0 to Bitmap.Height-1 do begin WSK:=Bitmap.ScanLine[V]; for H:=0 to Bitmap.Width*3-1 do begin Wsk^:=IntToByte(Wsk^-(Wsk^*Amount)div 255); inc(Wsk); end; end; end;
procedure Threshold( Bitmap:TBitmap ; const Light:TRgbTriple; const Dark:TRgbTriple; Amount:Integer = 128); var Row:^TRGBTriple; H,V,Index:Integer; begin Bitmap.PixelFormat:=pf24bit; for V:=0 to Bitmap.Height-1 do begin Row:=Bitmap.ScanLine[V]; for H:=0 to Bitmap.Width -1 do begin Index := ((Row.rgbtRed * 77 + Row.rgbtGreen* 150 + Row.rgbtBlue * 29) shr 8); if Index>Amount then Row^:=Light else Row^:=Dark ; inc(Row); end; end; end;
procedure Posterize(Bitmap: TBitmap; amount: integer); var H,V:Integer; Wsk:^Byte; begin Bitmap.PixelFormat :=pf24bit; for V:=0 to Bitmap.Height -1 do begin Wsk:=Bitmap.scanline[V]; for H:=0 to Bitmap.Width*3 -1 do begin Wsk^:= round(WSK^/amount)*amount ; inc(Wsk); end; end; end;
procedure Mosaic(var Bm:TBitmap;size:Integer); var x,y,i,j:integer; p1,p2:pbytearray; r,g,b:byte; begin y:=0; repeat p1:=bm.scanline[y]; x:=0; repeat j:=1; repeat p2:=bm.scanline[y]; x:=0; repeat r:=p1[x*3]; g:=p1[x*3+1]; b:=p1[x*3+2]; i:=1; repeat p2[x*3]:=r; p2[x*3+1]:=g; p2[x*3+2]:=b; inc(x); inc(i); until (x>=bm.width) or (i>size); until x>=bm.width; inc(j); inc(y); until (y>=bm.height) or (j>size); until (y>=bm.height) or (x>=bm.width); until y>=bm.height; end;
procedure FlipHorizontal(var Bitmap:TBitmap); type ByteTriple =array[0..2] of byte ; // musimy czytać po 3 bajty żeby nie zamienić kolejności BGR na RGB var ByteL,ByteR:^ByteTriple; ByteTemp:ByteTriple; H,V:Integer; begin Bitmap.PixelFormat:=pf24bit; for V:=0 to (Bitmap.Height -1 ) do begin ByteL:=Bitmap.ScanLine[V]; ByteR:=Bitmap.ScanLine[V]; inc(ByteR,Bitmap.Width -1); for H:=0 to (Bitmap.Width -1) div 2 do begin ByteTemp:=ByteL^; ByteL^:=ByteR^; ByteR^:=ByteTemp; Inc(ByteL); Dec(ByteR); end; end; end;
procedure FlipVertical(var Bitmap:TBitmap); var ByteTop,ByteBottom:^Byte; ByteTemp:Byte; H,V:Integer; begin for V:=0 to (Bitmap.Height -1 ) div 2 do begin ByteTop:=Bitmap.ScanLine[V]; ByteBottom:=Bitmap.ScanLine[Bitmap.Height -1-V]; for H:=0 to Bitmap.Width *3 -1 do begin ByteTemp:=ByteTop^; ByteTop^:=ByteBottom^; ByteBottom^:=ByteTemp; inc(ByteTop); inc(ByteBottom); end; end; end;de
procedure Negative(var Bitmap:TBitmap); var H,V:Integer; WskByte:^Byte; //Wskaźnik do Bajta (nie trzeba do całego pixela bo i tak wszystko odwracamy) begin Bitmap.PixelFormat:=pf24bit; for V:=0 to Bitmap.Height-1 do begin WskByte:=Bitmap.ScanLine[V]; // V jest to pozycja danej linii bitmapy (od góry ) for H:=0 to (Bitmap.Width *3)-1 do begin WskByte^:= not WskByte^ ;// (odwracamy wartość na którą pokazuje wskaźnik) inc(WskByte);//Przesuwam wskaźnik end; end; end;
mount imagen.mdf /path/mount_directory -o loop=/dev/loop0