Posts

Showing posts from February, 2013

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>

sftp - How do I use an SSH File Transfer Protocol client (Cyberduck) through two ssh "points" -

i trying log in computer @ work through cyberduck. i can ssh computer fine must first ssh central system, ssh there computer. is there way allow cyberduck ssh work computer, i.e. ssh twice @ once? you can use e.g. putty set port forwarding, called ssh tunneling (for purposes such yours). see https://the.earth.li/~sgtatham/putty/latest/htmldoc/chapter3.html#using-port-forwarding alternatively can use sftp client supports natively, e.g. winscp . there's guide here: https://winscp.net/eng/docs/guide_tunnel note aside instructions, how using winscp native tunneling functionality (section section tunnel in winscp ), guide shows, how tunnel winscp via putty (section section tunnel using putty sftp/scp session ). if insist on using cyberduck, can replace winscp cyberduck in guide. (i'm author of winscp)

jquery - How to customize kendo grid update button? -

i newbie kendo web ui. want implement inline editing grid.when click add/edit button got inline form fields update button, want to unique id every row , customized update button functionality can update database. <table id="grid11" style="table-layout: fixed; display:none;"> <colgroup> <col style="width:10%"> <col style="width:20%"> <col style="width:20%"> <col style="width:20%"> <col style="width:30%"> </colgroup> <thead> <tr> <th><font style="font-weight:bolder; color:#7ea700; font-size:16px;">qty</font></th> <th><font style="font-weight:bolder; color:#7ea700; font-size:16px;">unit</font></th> <th><font style="font-

User input accepted whether they input uppercase OR lowercase in C++ -

absolute beginner here (first post) , finished assignment have had create program lets user create employee wages slip , displays them searching surname, forename, employee number, etc. i having problem if create record nancy davidson e.g. can output record if search nancy or davidson. if search nancy or davidson doesn't find it. i using struct store each employee details, writing them data file reading file display record. is there way can record still display if search nancy? this code search surname function: //record search employee surname void searchsurname(employee data[], int row) { string surname, again; double wholetot=0, wholenet=0; again = "y"; while (again=="y"||again=="y") { row=0; bool found = false; clrscr(); cout << "please enter employee surname : "; input(surname); clrscr(); cout << "surname search results "

In Rails ActiveRecord, joins does not work with has_and_belongs_to_many in namespaced models -

i have 2 models in namespace, service , instructor, both have many many relationship each other, defined through has_and_belongs_to_many: class scheduling::service < activerecord::base has_and_belongs_to_many :instructors end class scheduling::instructor < activerecord::base attr_accessible :first_name, :last_name has_many :instructor_availabilities scope :of_service, lambda { |service_id| joins(:services).where(:services => {:id => service_id})} has_and_belongs_to_many :services, :class_name => "scheduling::service" end in scope of_service, want of_service return instructors associated service. however, when running scope, error: activerecord::statementinvalid: pg::error: error: missing from-clause entry table "services" line 1: ...."id" = "instructors_services"."service_id" "services"... ^

c# - Find paragraphs by style in word 2010 using interop -

could point me in right direction, or show me how find paragraphs style name using word interop in c#.net. try loop this: using wn = microsoft.office.interop.word; //... wn::application wordapp; wordapp = new wn.application(); //... wn.document worddoc = wordapp.documents.open(filename); //open document list<string> selectedparagraphs = new list<string>(); for(int i=1;i<worddoc.paragraphs.count;i++) //numeration of paragraphs starts 1 { string wordp = worddoc.paragraphs[i].range.text; // paragraph text string words = ((wn.style)worddoc.paragraphs[i].get_style()).namelocal; //get paragraph style name if (words=="needed style") { selectedparagraphs.add(wordp); } }

r - Apply a different formula for each condition that is met in a certain data frame -

lets example have following data frame called "df1" (which part of larger data frame example now): df1= [,1] [,2] [,3] 1 -0.5 1.3 1 -0.3 0.9 5 -0.2 0.2 2 0.4 0.5 0 0.5 1.1 2 1.1 0.1 1 -0.6 1.8 and have created following conditions: conda= df1[,2] >= 0 & df2[,3] > 1 condb= df1[,2] >= 0 & df2[,3] <= 1 condc= df1[,2] < 0 & df2[,3] > 1 condd= df1[,2] < 0 & df2[,3] <= 1 here comes question: how apply different function each condition met in df1. example: if conda met: df1[,1]=df1[,1]*1 if condb met: df1[,1]=df1[,1]*2 if condc met: df1[,1]=df1[,1]*3 if condd met: df1[,1]=df1[,1]*4 taking account example "df1", output data frame this: [,1] [,2] [,3] 3 -0.5 1.3 # in row condc met 4 -0.3 0.9 # in row condd met 20 -0.2 0.2 # in row condd met 4 0.4 0.5 # in row condb me

excel - Finding words that start with a specific sign -

i have few thousands rows in excel file line of text in each cell. in line of text, there word starts character "&". avoid using vba. if words start "&" same length, use "left" or "right". excel function advise me use extract these words? other question: if have 2 words start "&" in same cell, there way have 2 different functions, in 2 other cells, 1 looking first 1 starting beginning, other 1 looking last 1 starting end? thanks. regarding first question. in a1 there first string. put in b1 formula: =if(left(substitute(a1," &"," "),1)="&",mid(substitute(a1," &"," "),2,10000),substitute(a1," &"," ")) then drag down (copy formulas down) cells a2, a3 ecc.. take care of words preceded space , first word in cell. have out of special case (interpunctions ecc..) as: "bla bla,&word"

c++ power of integer, template meta programming -

i want make function returns power of integer. please read fmuecke's solution in power of integer in c++ . however, want generalize solution arbitrary type t. since c++11 has constexpr, guess possible. naively, tried like, template<class t, int n> inline constexpr t pow(const t x){ return pow<n-1>(x) * x; } template<class t> inline constexpr t pow<t, 1>(const t x){ return x; } template<class t> inline constexpr t pow<t, 0>(const t x){ return 1; } actually approach failed since partial specialization function template not allowed. and 1 more question. heard compiler whether constexpr function evaluated in compile time or not. how force compute general type. read somewhere 1 of simplest hack integral consts wrap in std::integral_const::value. solution using recursion: #include <iostream> template<class t> inline constexpr t pow(const t base, unsigned const exponent) { // (parentheses not requi

Redmine 2.3, ruby 2.0.0, nginx 1.4.1 with passenger 4.0.2 all HTTP POSTs fail -

i'm new nginx , attempting run redmine 2.3 using ruby 2.0.0, phusion passenger 4.0.2 , nginx 1.4.1. compiled passenger-install-nginx script on armv5te system in arch linux arm. i getting following in nginx log: (note: i've removed server name logs/configs) 2013/05/08 23:41:12 [notice] 1359#0: signal process started [ 2013-05-08 23:41:13.1325 1367/b6f9a000 agents/helperagent/main.cpp:554 ]: passengerhelperagent online, listening @ unix:/tmp/passenger.1.0.1363/generation-0/request.socket [ 2013-05-08 23:41:13.2641 1387/b6f26000 agents/helperagent/main.cpp:554 ]: passengerhelperagent online, listening @ unix:/tmp/passenger.1.0.1381/generation-0/request.socket [ 2013-05-08 23:41:13.3028 1392/b6faa000 agents/loggingagent/main.cpp:272 ]: passengerloggingagent online, listening @ unix:/tmp/passenger.1.0.1381/generation-0/logging.socket [ 2013-05-08 23:41:15.9700 1387/b59ff450 pool2/spawner.h:739 ]: [app 1408 stdout] [ 2013-05-08 23:41:43.5820 1387/b6b4a450 pool2/spawner.h:159

java - Sending Parameters to .net Restful WebService from Android -

i trying send invoke webservice method took jagged array parameters. build array, passed null web service. here java class: package com.mitch.wcfwebserviceexample; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.client.clientprotocolexception; import org.apache.http.client.methods.httppost; import org.apache.http.entity.stringentity; import org.apache.http.impl.client.defaulthttpclient; import org.apache.http.message.basicheader; import org.apache.http.protocol.http; import org.json.jsonarray; import org.json.jsonobject; import android.os.asynctask; import android.os.bundle; import android.util.log; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.textview; import android.app.activity; public class mainactivity extends activity implements onclicklistener { private s

how to force variable declaration in javascript or how to check it? -

though can use variable without declaring in javascript, misuse of variable cause hard-to-solve errors. example, following code cause endless loop. for(i=0;i<100;i++){ document.write(fivetimes(i)); } ... function fivetimes(x){ i=5; return (i*x); } i'd know if there way force every variable in javascript declared before use. or knows how check variable declaration-before-using in tons of javascript files , blocks in huge web server. you can enable "strict mode" , can pass code through jslint (or jshint if have sensitive feelings :))these steps go long way toward making code execute predictably.

Bash: manipulating with strings (percent sign) -

what percent sign mean in bash when manipulating strings? example, ${0%/*} mean? if use @fedorqui's resource, you'll see going strip shortest match of /* end of first positional argument. example: example_foo(){ echo ${1%/*} } example_foo path/to/directory/sub_directory # => path/to/directory in example used second positional argument since first name of function.

android - called from wrong thread + inner classes .. strange behaviour -

i'd explain me why fails... my activity has inner class, apphelper, exports function setthrobber. simplicity have omitted init code, etc.. this function setthrobber meant called outside of ui thread, during network loads, report progress... then, classes use inner class apphelper method setthrobber so, network-loader thread. to surprise, first approach fails (see error @ end) , second succeeds. why isn't first 1 executed in ui thread , second 1 is??? more strange is, in error stack trace looks called ui thread, though android throws called wrong thread exception. why not both code chunks equivalent thread point of view? pd- tried handler.post() same result! pd2- apphelper class instantiated inside oncreate thanks in advance !! public class myapplication extends activity { private progressdialog progressdialog; void setthrobber_internal (string message) { progressdialog.setmessage(message); } public class apphelper { public s

html - cURL post data to click a button -

i looking use curl post data click button webpage need update regularly. i tried following curl command doesn't seem click button: curl -x post 'url_in_here' --verbose --user-agent $user_agent --cookie $cookies --cookie-jar $cookies --data "eventsource=update_" the form details: <form name="mainform" method="post" enctype="multipart/form-data" action="default.html"> <input type="hidden" name="eventsource"/> and button: <input type="button" onclick="return do_submit('update_');" name="update_" value="update"> any appreciated

textures - OpenGL Terrain Texture3D Map -

in opengl trying map terrain 8 512x512 images using texture3d blended texture change. opengl forces me allocate 512x512x512 array instead of 512x512x8 can solution but opengl forces me allocate 512x512x512 what gave idea? 512×512×8 valid 3d texture size. terrains might @ gl_texture_2d_array, initialized glteximage3d well, doesn't interpolate between layers, usefull in situations.

three.js - ThreeJS: the texture appears partially flat -

this test page http://www.aleaweb.com/3d/ as can see book has leather texture on spine , flat color on front , it's single object, know why texture applied incorrectly? has modeling or javascript programming? this piece of code regarding book var texture2 = three.imageutils.loadtexture( "textures/pelle.jpg"); texture2.wraps = three.clamptoedgewrapping; texture2.wrapt = three.clamptoedgewrapping; texture2.needsupdate = true; texture2.repeat.set( 1, 1 ); texture2.anisotropy = maxanisotropy; //var material = new three.meshphongmaterial({ color: 0xeeeeee, map:texture2, shininess: 100, bumpmap: texture2, bumpscale: 2, metal:false }); var materialarray = []; materialarray.push(new three.meshbasicmaterial( { color: 0xffffff })); materialarray.push(new three.meshphongmaterial( { map: textureb })); materialarray.push(new three.meshphongmaterial( { map: texture2, bumpmap:texture2 })); var dicebluematerial = new three.meshfacematerial(materialarray); var loader = new th

c# - Special characters for dynamic objects? -

is there limitations on kind of characters can use create property dynamic object? is there list of characters cannot use (e.g. / * @)? suppose have: dynamic eo = new expandoobject(); then if expand object through c# syntax, need follow c# rules, example: eo.validcsharpidentifier = 42; eo._ok = 42; eo.æ = 42; but if expand eo casting idictionary<,> , can use other characters: ((idictionary<string, object>)eo).add("notvalidc#identifier", 42); ((idictionary<string, object>)eo).add("42", 42); ((idictionary<string, object>)eo).add("/", 42); ((idictionary<string, object>)eo).add("*", 42); ((idictionary<string, object>)eo).add("@", 42); ((idictionary<string, object>)eo).add("", 42); as see, strange identifiers possible. string must object though, null reference cannot used (as in .add(null, 42) /* illegal */ ). there seems no restriction on name used. string k

c# - Single backslash in JSON serialized -

i need send string in format using mvc json serialization "america\/new_york" but when create string string timezone = @"america\/new_york"; return json(new { timezone = timezone }) in result get: { "timezone":"america\\/new_york" } how can it? edited. if write @"america\/new_york" ; error "unrecognized escape sequence" if write @"america/new_york"; "timezone":"america/new_york" they same, json serializer adding escape character. if deserialize object, call obj, do; console.writeline(obj.timezone); //outputs "america\/new_york" the same true whatever use display in view. in c# @ before string literal precompiler directive not use escape characters. if remove @ have write "america\\/new_york" in order produce output "america\/new_york" . to clarify further; string = @"america\/new_york"; string b = "america

c++ - Makefile C++11 error -

i'm learning makefiles. tried writing own 1 after little reading. problem is, errors connected c++11 standard, though put compiler flag needed makefile. here error: /usr/include/c++/4.6/bits/c++0x_warning.h:32:2: error: #error file requires compiler , library support upcoming iso c++ standard, c++0x. support experimental, , must enabled -std=c++0x or -std=gnu++0x compiler options. and here makefile: cc = g++ ld = g++ name = app obj_dir = obj src_dir = src cxx_flags = -std=c++0x src = $(shell find $(src_dir) -type f -regex ".*\.cpp") obj = $(subst $(src_dir), $(obj_dir), $(addsuffix .o, $(basename $(src)))) all: $(name) $(name): $(obj) $(ld) $< -o $@ $(cxx_flags) $(obj_dir)/%.o: $(src_dir)/%.cpp $(cc) $< -o $@ $(cxx_flags) clean: rm $(name) $(obj_dir) -rf notice i've put cxx_flags after checking out other questions on stack overflow, no avail. still same error. it's make ignoring flag. there solution this? and yes, can

linux - Check if directory exists not working -

i have textfile (qrs.txt) contains dir names (one per line) , on server in same directory script have folders corresponding names text file. this script: #!/bin/bash while read p; if [ ! -d "$p" ]; echo "error $p" >> log.txt else echo "good" >> log.txt fi done < qrs.txt qrs.txt: 1992300000183805 1992300001176204 1992300002145500 1992300003104507 1992300004104902 1992300005133703 1992300006117802 1992300007144501 1992300008172803 1992300009189005 1992300010146307 1992300011151700 1992300012190007 1992300013126802 1992300014111508 1992300015193908 when if statement inside loop returns error incorrect because can see folders exist. when take out of loop , check 1, works fine... when echo $p on same line error, can see file name checking indeed correct. what missing here..? edit: screenshot of qrs.txt in hex mode: http://i.snag.gy/25mqj.jpg resolved! my qrs.txt in [dos] format once convert

ios - How to constrain uicollectionviewflowlayout to a specified frame -

Image
i'm new uicollectionview. though i've watched wwdc talks on i'm still unclear how achieve layout. i'm trying constrain flow layout square bottom aligned window's rootviewcontroller (see image). however, when setting uiedgeinsetsmake(200, 10, 10, 10) understand should compress top portion of flow layout, instead happens flow layout compressed top , bottom. additionally, i'm not sure how use -(nsarray *)layoutattributesforelementsinrect:(cgrect)rect or -(cgsize)collectionviewcontentsize create layout. -(id)init { self = [super init]; if (self) { self.scrolldirection = uicollectionviewscrolldirectionhorizontal; self.itemsize = cgsizemake(75, 75); self.sectioninset = uiedgeinsetsmake(100, 10, 10, 10); } return self; } what results are: what i'm trying acheive: i think frame of collection view different need .set properly

android - Showing a DialogFragment object from an on click inside a button listener -

i trying showing dialogfragment object on click inside button listener. here code of activity should start dialog: import android.os.bundle; import android.app.activity; import android.content.context; import android.content.intent; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; public class mainactivity extends activity { button button1; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); addlistenertobutton1(); } private void addlistenertobutton1(){ final context context = this; button1 = (button) findviewbyid(r.id.button1); button1.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { dp ciao = new dp(); ciao.show(this,"mydp"); } }); } } and here's code of dialog: public class dp ext

video streaming - FFmpeg: Generating .ts files and adding Metadata to them -

before following steps: create metadata: id3taggenerator -o 1.id3 -artist "emma stone" id3taggenerator -o 2.id3 -artist "patricia clarkson" create file saying place metadata in file: 68 id3 /path/to/file/1.id3 78 id3 /path/to/file/2.id3 segment files , include metadata mediafilesegmenter -f video -m meta.txt video.mp4 more detail: http://jmacmullin.wordpress.com/2010/11/03/adding-meta-data-to-video-in-ios/ i want similar this, ffmpeg. i wondering if first segment file .ts files , add metadata directly those? i having trouble finding solution on website. or resources great. thanks! you can use -metadata flag ffmpeg -i maida.mp2 \ -metadata title='obelisk' \ -metadata album='2003-09-03: maida vale, london, uk' \ -metadata artist='the mars volta' \ -metadata label='' \ -metadata date='2003' \ maida.flac

ruby on rails - Exception Notification -

i trying make exception notifier. installed gem , put code in production.rb: config.action_mailer.delivery_method = :sendmail # defaults to: config.action_mailer.sendmail_settings = { :location => '/usr/sbin/sendmail', :arguments => '-i -t' } config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true config.middleware.use exceptionnotifier, :email_prefix => "error 500", :sender_address => %{"notifier" <support@example.com>}, :exception_recipients => %w{my@mail.com} this doesn't throw error, not send mail either. please. i've replaced: config.action_mailer.delivery_method = :sendmail # defaults to: config.action_mailer.sendmail_settings = { :location => '/usr/sbin/sendmail', :arguments => '-i -t' } with: config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_sett

Run R script from Python -

i want run r-script python script. r-script required projection of lat lon coordinates in different coordinate system. have considered 2 options this. in first option parse lat , lon coordinates r-script shown below. r-script returns x , y python script, can't figure out how this. project<-function(lat,lon){ library(sp) library(rgdal) xy <- cbind(x = lon, y = lat) s <- spatialpoints(xy) proj4string(s) <- crs("+proj=longlat +ellps=wgs84 +datum=wgs84 +no_defs") snew <- sptransform(s, crs("+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +no_defs")) x <- coordinates(snew)[1] y <- coordinates(snew)[2] return(x,y) } for second option i've considered using r-script @ bottom lat , lon in it. try run python subprocess.popen('rscript project.r', shell=true).wait() not seem work. not write xy.txt file. if run cmd line, however, r-script job. can me out 1 of

AES C# File Encryption - stream writes only 16 bytes -

here piece of code, should encrypt file , write cryptograph new file. code similiar example found @ microsoft msdn webpage. byte[] inputbuffer = new byte[inputfilestream.length]; byte[] outputbuffer = new byte[inputfilestream.length]; inputfilestream.read(inputbuffer, 0, (int)inputfilestream.length); icryptotransform encryptor = aesinstance.createencryptor(aesinstance.key, aesinstance.iv); using (memorystream memorystream = new memorystream()) { using (cryptostream stream = new cryptostream(memorystream, encryptor, cryptostreammode.write)) { using (streamwriter encrypted = new streamwriter(stream)) { encrypted.write(inputbuffer); } outputbuffer = memorystream.toarray(); outputfilestream.write(outputbuffer, 0, (int)outputbuffer.length); } } outputfilestream.close(

java - Questions on object declaring and a few image import statements for making a basic game -

so friend , making very basic game fun, going top down (about 45 degree angle) there lumberjack chopping down trees. basic , kinda lame i'm aware getting semi-advanced java. to start decided needed sprites trees realized no matter rectangle white pixels around tree, cut out part of background image. wanted take every pixel white (whitespace/negative space), make pixels transparent. looked @ ton of codes , 1 saw code below, worked don't quite understand it. import java.awt.*; import java.awt.image.*; import javax.swing.*; public class simpleframe extends jframe { jpanel mainpanel = new jpanel() { imageicon originalicon = new imageicon("image.png"); imagefilter filter = new rgbimagefilter() { int transparentcolor = color.white.getrgb() | 0xff000000; public final int filterrgb(int x, int y, int rgb) { if ((rgb | 0xff000000) == transparentcolor) { return 0x00ffffff & rgb; } else {

algorithm - C - reverse a number -

i coding in c on linux, , need reverse number. (eg: 12345 turn 54321), going convert string using itoa , reverse that, it's lot easier string manipulation, turns out itoa non standard , isn't included in gcc. there way of doing binary rotation style thing on decimal numbers , if not approach should take? int n; scanf("%d",&n); int rev=0,rem; while(n>0) { rem=n%10; //take out remainder .. becomes 5 12345 rev=rev*10+rem; //multiply current number 10 , add remainder. n=n/10; //divide number. becomes 1234. } printf("%d",rev);

Html select fails to drop down in simple case in Firefox, Safari and Chrome. IE OK -

the "select" in following html works in ie9.0 fails drop-down when clicked in firefox 10.0, safari 5.1.7 , chrome 26.0. why? i'm facing problem in more complex web page , have spent time isolating down simple case. remaining elements , styling appear need present problem occur. <h1>a</h1> <div style="margin-top: 3px; float: right;"> <select> <option value="1">b</option> <option value="2">c</option> </select> </div> <div style="position: relative;"> d </div> here answer. relatively positioned d element on top of select box. can select if click @ bottom of it. try setting select have z-index higher relatively positioned div, or changing width of div. a solution: <h1>a</h1> <div style="margin-top: 3px; float: right;"> <select> <option value="1">b</option>

Can GDB be used to print values of allocatable arrays of a derived type in Fortran 90? -

this question has answer here: fortran print allocatable array in gdb 3 answers i have following data structure in fortran90 program: type derivedtype character(100) :: name = ' ' integer :: type = 0 real(kind(1.0d0)) :: property = 0.0 end type derivedtype type (derivedtype), allocatable, dimension(:) :: arrayofderivedtypes when try debug , print values in gdb like: (gdb) p arrayofderivedtypes(1)%name i non-sensical values (often strings of zeros, forward slashes , letters), or wrong values (like arrayofderivedtypes(1)%name = 9, when know = 2). how can gdb print correct values? background i aware of: this bug: http://sourceware.org/bugzilla/show_bug.cgi?id=9395 this branch of gdb: http://sourceware.org/gdb/wiki/projectarcher and blog post on printing allocatable arrays: http://numericalnoob.blogspot.be/2012/0

Using 2 Javascripts on one page -

i added javascript menu website (see link below) alpineglass.biz/alpinesample.html and trying add pop request form jotform.com. when add 2 javascripts page, menu pictures stick when scrollover , don't show sub menus. (see link below) alpineglass.biz/contactus.html how both work? here code menu: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="jquery.easing.1.3.js"></script> <script type="text/javascript"> $(function() { /** * each menu element, on mouseenter, * enlarge image, , show both sdt_active span , * sdt_wrap span. if element has sub menu (sdt_box), * slide - if element last 1 in menu * slide left, otherwise right */ $('#sdt_menu > li').bind('mouseenter',f

python - make matplotlib draw() only show new point -

so have 3d graph scatterplot updating point going through dataframe. have add new point ever .1 seconds. here code: ion() fig = figure() ax = fig.add_subplot(111, projection='3d') count = 0 plotting = true while plotting: df2 = df.ix[count] count += 1 xs = df2['x.mean'] ys = df2['y.mean'] zs = df2['z.mean'] t = df2['time'] ax.scatter(xs, ys, zs) ax.set_xlabel('x label') ax.set_ylabel('y label') ax.set_zlabel('z label') ax.set_title(t) draw() pause(0.01) if count > 50: plotting = false ioff() show() how can show new point on live-updated graph. right starts 1 point , adds , until there total of 50 points on graph. so want there never more 1 point on graph , have point changing iterates through. how can this? ion() fig = figure() ax = fig.add_subplot(111, projection='3d') count = 0 plotting = true # doesn't need in loop ax.set_x

javascript - Displaying time in JSON file on JS Timeline -

i working on developing widget using timeline js template. have able receive events in json format. now, working on receiving them local file. able receive events include date, having trouble getting time work. suggestions have found not seem working. can help? here json test file: "events": [{ "start": "2013-03-18", //need add time here "end": "2014-03-18", "title": "test a", "color": "green", "description": "this test", "image": "", "link": "" }, ... ]} typical date format "yyyy-mm-dd hh:mm:ss.mmm" , these can passed javascript new date(x) constructor (where 'x' is) browsers don't format. want / instead of - , 't' blank separates date , time. see this: highcharts: x-value date for more details can @ fiddle here one way shown there seems work in lots of browsers: var d = '2013

php - regular expression for commenting out all print statements in a file if followed by a particular string -

i have file looks similar this: <?php print "hello world" . "<br/>"; print "foobar" . "<br/>"; ... // process parameter if ($var) { print $var . "<br/>"; } ... print "foo" . "<br/>"; ... print "bar" . "<br/>"; ... >? i need regular expression comments out print statements, if said statements appear after process parameter comment. i'm using perl process file above, way. i've come following regex it's not working: ~(?s)(// process parameter.*?)print(.*?\?\>)~$1//print$3~gi do need use regex conditional? appreciate help. thank you. thank suggestions. did figure out, though. ~(?s)(?<=// process parameter.*?)(print.*?)~//$1~gi i'm using look-behind assertion s option treat string single line. matches print if followed contents of look-behind assertion.

google provisioning api - Deleting a sub organization -

i running issue when try delete sub organizations. i following error (customer id removed) execution of request failed: https://apps-apis.google.com/a/feeds/orgunit/2.0/custid/qa%2ftesting%2fmoar%2bgroups "} i using google apps c# library , calling this orgservice.deleteorganizationunit(customerid, "qa/testing/moar+groups"); the response body "1301: entity not exist" i taking path directly feed organizations , passing delete , still failing... idea going on here? is name of ou "qa/testing/moar+groups" or "qa/testing/moar groups"? should passing true name of ou library, should take care of url encoding it.

javascript - analyse a .aspx site with paging with __doPostBack function -

i want analyse data of webpage, here's problem: site has more pages gets called __dopostback function. how can "simulate" go page further , analyse site, , on.. at time analyse data jsoup in java - i'm open use other language if it's necessary. a postback-based system (.net, prado/php, etc) works in manner keeps complete snapshot of browser contents on server side. called pagestate. attempt manipulate client not javascript-capable sure fail. what need javascript-capable browser. easiest solution found use framework firefox written in - xul - create such desktop application. create desktop application single browser element in it, can script application without restrictions of security container. alternatively, use greasemonkey plugin bidding. latter bit easier started with, it's limited since it's running on per-page basis. with both solutions have access page's dom gather data , can fire events (like clicking on button). unfortu

c++ - How to return positive error code from ATL to VB6? -

i have checked out answer at: how can return both error string , error code vb6 atl activex control? i able return custom negative error codes, ie severity bit set, , custom error message. but, able generate code vb6 present positive # err.number user find easier use. i'm pretty sure can done since microsoft's dao 3.6 dll able to. example, returns err.number= 3078 err.description "the microsoft jet database..." if table not exist. note have implemented isupporterrorinfo, etc. error reporting. annotating mark's answer bit. he's right using facility_control. in addition must ensure error code larger 512 doesn't interfere vb6 runtime error codes. use this: hresult makevb6error(uint errcode) { assert(errcode > 0 && errcode < 65536 - 513); return make_hresult(severity_error, facility_control, errcode + 513); }

mysql - php script for upload image not working -

i have edit page allow users upload profile image using forms problem keep getting the format not acceptable if image type 1 of accepted format. this code if(isset($_post['parse_var']) == "pic") { if(!$_files['filefield']['tmp_name']) { $errormsg = '<font color= "#ff0000">please browse image before press button.</font>'; } else { $maxfilesize = 51200;//in bytes = 50kb if($_files['filefield']['size']>$maxfilesize) { $errormsg = '<font color="#ff0000">your image large, please try again.</font>'; unlink($_files['filefield']['tmp_name']); } elseif(!preg_match("^.(gif|jpg|png)$/i^",$_files['filefield']['name'])) { $errormsg = '<font color="#ff0

java - InputStream.read() is either missing or adding a value in my buffer - How come? -

i've created following procedure in run() method of connectedthread taken bluetoothchat sample. // read inputstream byte[] buffer = new byte[16]; int offset = 0; while(buffer.length-offset != 0) { int bytesread += mminstream.read(buffer, offset, buffer.length-offset); offset += bytesread; } // stuff contents of buffer the buffer loaded in 16 bytes gradually expected reason @ 10th byte in array 0 inserted , shifts remaining part of package(and such corrupting entire package) here example of happening the following sent other client : [-11, 126, -16, -30, -92, 110, -26, 13, 22, 91, -31, 32, 54, -125, -112, 45] this receive : [-11, 126, -16, -30, -92, 110, -26, 13, 22, 91, 0 , -31, 32, 54, -125, -112] as can see, 0 pushed in 10th byte , rest of package shifted right(cutting off last byte) as part of debugging process tried having breakpoint @ bytesread += mminstream.read(buffer, offset, buffer.length-offset) , our surprise entire original message receiv

weblogic - Configuration of WebMethods Client to connect to WebSphere JMS (not WebSphere MQ) -

currently have setup 2 queues on websphere 7. 1 sending , 1 recieving messages. i have configured activation spec on receiving queue , messages consumed fine message bean. also have written client can run on separate jvm can send messages fine queue. i sure queues work. now want know how can connect them webmetods. know webmethods supports jboss , weblogic no support websphere. i should able working providing: provider url - "iiop://172.17.13.65:2809" connection factory - "jms/connectionfactroy" queue name- "jms/inqueue" , initial context - "com.ibm.websphere.naming.wsninitialcontextfactory" (at least client using) is there has resolved issue? , steps took? thank in advance help. we able implementation happen. to solve web methods had import jar files client jms: com.ibm.ws.ejb.thinclient_7.0.0 + com.ibm.ws.orb_7.0.0 + com.ibm.ws.sib.client.thin.jms_7.0.0 and use bootstrap of type provider_url: "iiop://natas

apex code - Salesforce creating incorrect HMAC SHA1 value -

i'm trying generate hmac value within salesforce using crypto generatemac function, result doesn't match other utilities. for example, i'm trying hash value hash me using key ac67ad3b8771bf63d4fa9582845a18f921514f36 . i'm expecting result 66fe419859ac42ad88354dfa52f2196a26d767e1 , it's 7d1f56c728dfefdcb9edb72b7c0c8df2acf1cae9 . my apex code is: blob mac = crypto.generatemac('hmacsha1', blob.valueof('hash me'), blob.valueof('33a1211c0ee01511ccba1e456bb95503')); string hasedvalue = encodingutil.converttohex(mac); i'm guessing issue related converting to/from binary or maybe related case, cannot match expected result. my expected result based on result http://hash.online-convert.com/sha1-generator , couple other online hmac calculators. the other option base 64 encode: encodingutil.base64encode(mac); i'd surprised if generatemac + converttohex aren't working you. they've worked me. i'm sure y