Posts

javascript - Always show a DIV as soon as its not visible any more after scrolling down? -

i have info box (div) on screen when user opens website. user scrolls down , box not visible user longer, want box appear in top right corner time while scrolling. i know how make visible time (position: fixed). problem is, how know when not visible user ans more while scrolling? can use javascript, if helps. id prefer prototype js. thanks! you need make use of getboundingclientrect() , returns element's positions relative viewport. if top value below 0 , should fixed. html: <div id="stick"> should fixed… </div> css: #stick { position: absolute; top: 60px; } #stick.fixed { position: fixed; top: 0; } js: var stick = document.getelementbyid('stick'); window.onscroll = function(){ if(stick.getboundingclientrect().top < 0){ stick.classname = 'fixed'; } else if(stick.classname.indexof('fixed') < 0){ stick.classname = ''; } } here's demo . ...

Java finding start and end of each sub-sequence in an int array -

i have array containing sequence of numbers below, sequence of number of pixels in y axis (horizontal projection histogram): [ 0 0 3 13 16 16 18 19 19 18 14 10 8 0 0 0 0 0 7 13 15 16 19 20 18 17 14 9 0 0 0 0 ] ^ ^ start end how can find starting index , ending index of each sub-sequence in array? expect in example this: first sub-sequence: startindex = 2, endindex = 12 , second sub-sequence: startindex = 18, endindex = 27 . what have came with: for(int =0; i<pixels.length; i++){ system.out.println(pixels[i]); if(pixels[i] != 0) { start = i; system.out.println("start= " + start ); } else if(pixels[i] == 0){ end = i; system.out.println("end= " + end); } } i appreciate help. when iterating trough array, don't keep track if started sequence. with small change should work int start=-1; for...

javascript - bootstrap div background-image -

here code used <!doctype html> <html> <head> <title>registration</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <link href="twitter-bootstrap/docs/assets/css/bootstrap.css" rel="stylesheet"/> <link href="twitter-bootstrap/docs/assets/css/docs.css" rel="stylesheet"> <link href="twitter-bootstrap/docs/assets/js/google-code-prettify/prettify.css" rel="stylesheet"> <style type="text/css"> .container { width: 750px; height : 300px; margin-top : 50px; } </style> </head> <body> <div class = "container"> <div class = "well" style = "box-shadow : 0 1px 10px rgba(0,0,0,1.0);"> <form id = "reg" class = "form-horizontal" method = "post" action = "reg.php"> ...

Preserving metadata in resized image using PHP -

i have php script scans directory images, resizes finds , saves them overwriting originals. works except fact strips metadata image. i found toolkit can manipulate metadata including extracting , writing images. on this page explains how (at bottom of page). so added code having problems - not write metadata resized image. missing can't seem figure out (probably lack of coding skill) , wondered if can spot error , suggest correction. here relevant part of code: this used confirm images found , contain metadata - printing in html format echo " $file <br> " ; $filename = $file; $exif_data = get_exif_jpeg( $filename ); echo interpret_exif_to_html( get_exif_jpeg( $filename ), $filename ); here code resizes image , saves it, , should write meatada - doesn't $new_image = imagecreatetruecolor($new_width,$new_height); imagecopyresized($new_image, $tmp_image,0,0,0,0, $new_width, $new_height, $width, $height); //g...

python - Using generators to read two files in time priority -

i read on generators , wondering how use generators in this: there 2 files , each file has time column. each file sorted ascending time, , i'm looking grab lines in these files using time priority. instead of writing unsophisticated expression(see below) wondering if creating generator next() better/appropriate way read these 2 files in time priority. for line1 in file1: do_something try: if time1<time2: do_something continue else: do_something except: pass line2 in file2: do_something if time2>time1: break use heapq.merge def generate_timeline(file): line in file: time1 = extract_time_from_line(line) yield time1, line (time1, line) in heapq.merge(generate_timeline(file1), generate_timeline(file2)): process(line)

browser - convert responsive page to pdf with acrobat button -

couldn't decide if question better stack overflow or superuser, haven't got bites on superuser yet... i have adobe acrobat 9.0 pro, , that, convert web page pdf button displays in ie. use @ work review web pages , comment/markup changes, etc. when use on web page responsive (such http://microsoft.com ) resulting pdf shows page laid out if browser window sized down, stretches elements fit width of pdf. does know if because of rendering engine convert button uses? resulting pdf looks bit similar how page in quirks mode in ie9 (using f12 developer tools , choosing quirks mode document mode drop down.) help!

Attempting to hide a column of a html table using jQuery -

function func(id) { $(document).ready(function () { $(".toggle").click(function () { $("td:nth-child(" + id + ")>div").toggle(); }); }); return false; } am attempting hide column corresponding button clicked. code gets unexpected output both columns hiding when 1 button clicked. going wrong? <table border="1"> <tr> <th><button class="toggle" id="1" onclick="return func(this.id);" >hide</button></th> <th><button class="toggle" id="2" onclick="return func(this.id);" >hide</button></th> </tr> <tr> <td> <div>row 1, cell 1</div></td> <td><div>row 1, cell 2</div></td> </tr> <tr> <td><div>row 2, cell 1</div></td> ...