Posts

Showing posts from June, 2013

iis - merge two asp.net applications into one keeping urls -

we have 2 asp.net apps e.g. server/app1/ , server/app2/. want merge these apps together, need keep old urls working. is possible have single app handling requests both server/app1/ , server/app2/ without installing root app? there solution?

Create data constructor for partially applied type in Haskell -

is possible create data constructor partially applied type in haskell? ghci session: prelude> data vector b = vector {x::a, y::b} prelude> :t vector vector :: -> b -> vector b prelude> type t1 = vector int prelude> :t t1 <interactive>:1:1: not in scope: data constructor `t1' prelude> let x = vector prelude> let y = t1 <interactive>:46:9: not in scope: data constructor `t1' i want create data constructor type t1 - possible? or have use newtypes, because not possible manually define such function? i'm little confused goal is, let's go through bit bit, , maybe i'll hit right point: :t tells type of variable ; makes no sense when applied type, since return passed. notice errors here tell :t expects kind of data value parameter: prelude> :t maybe <interactive>:1:1: not in scope: data constructor `maybe' prelude> :t (maybe integer) <interactive>:1:2: not in scope: data constructor `maybe&

linux - Finding the pattern and replacing the pattern inside the file using unix -

i need in unix.i have file have value declared , and have replace value when called. example have value &abc , &ccc. have substitute value of &abc , &ccc in place of them shown in output file. input file go &abc=ddd; if file found &ccc=10; no value name &abc; , age &ccc; output: go &abc=ddd; if file found &ccc=10; value name ddd; , age 10; try using sed. #!/bin/bash # input file command line argument. input_file="${1}" # map of variables values declare -a value_map=( [abc]=ddd [ccc]=10 ) # loop on keys in our map. variable in "${!value_map[@]}" ; echo "replacing ${variable} ${value_map[${variable}]} in ${input_file}..." sed -i "s|${variable}|${value_map[${variable}]}|g" "${input_file}" done this simple bash script replace abc ddd , ccc 10 in given file. here example of working on simple file: $ cat file.txt boo aaa abc duh abc ccc abcccc hmm $ ./replace.s

Why does the * xpath abbreviation not include text nodes? -

in xpath expression $node/* why text nodes not included child nodes? because how xpath defined? is because how xpath defined? pretty much. in section 2.3 of xpath 1.0 spec , says: a node test * true node of principal node type. example, child::* select element children of context node, , attribute::* select attributes of context node. and further, in section 2.5 , says: * selects element children of context node

ember.js - EmberJS changing RESTAdapter -

i'm new emberjs might easy one. couldn't find answer date. i have api connect doesn't follow ember convention , can't change. i want able delete record. the ember convention /people/123 using delete http verb. when call person.deleterecord() need able call post /people/destroy/123 seems overriding possible unsure of direction take.

javascript - Add custom callback for a resource -

i'm using angularjs 1.1.5 , have service provider resource, there 1 use case returned response needs reparsed , info need normalized, special case resource used across project , it's not desired have use different resource or custom filter everywhere it's called. is there way add function when returning query or method, without affecting normal behavior. it should like, whenever there call resource method, execute callback transformations on data , return data expected. here way service implemented. factory('seccion', ['$resource', 'api_url', function($resource, api_url) { var seccion = $resource(api_url + 'secciones/:seccionid/:nestedresource/:nestedid', { seccionid: '@seccionid', nestedresource: '@nestedresource', nestedid: '@nestedid' }, { getwithnotas: { method: 'get', params: { nestedresource: 'notas',

Test manager, changed a shared step and all tests want to be re-recorded -

in microsoft test manager, have changed shared step , test cases used shared step have message "the action recording cannot loaded for..." happens if modify step in test case. there work-around don't have re-record steps(i changed shared step)? no, not really. in future best practice record action recordings shared steps separate action recording test case uses them. can record action recording shared step under organize > shared steps manager tab.

progress 4gl - setting a label after define -

i have display statement , display 1 of values if logical true. how can not display label of column (ie. blank) def var 1 char label "one" no-undo. def var 2 char label "two" no-undo. def var 3 char label "three" no-undo. def var 4 char label "four" no-undo. def var logic logi no-undo init no. display 1 2 3 4 when logic stream-io width 80. define variable 1 character no-undo initial "xyz". define variable 2 character no-undo initial "123". define variable f handle no-undo. define variable h handle no-undo. form 1 2 frame . f = frame a:handle. if 2 = "" do: h = f:first-child. walk_tree: while valid-handle( h ): if h:name = "two" do: h:label = "x". leave walk_tree. end. h = h:next-sibling. end. end. display 1 2 frame .

profile - JCR node type nt:file is not allowed as child's node type for parent node type -

i add 1 "soc:music" (nt:file) child node (same original "soc:avatar" node) exoplatform profile entity, fails when store jcr. google error, seems little mentions it. know how fix it? thanks. weird thing original "soc:avatar" node works well. <nodetype name="soc:profiledefinition" ismixin="false" hasorderablechildnodes="false"> ... <childnodedefinition name="soc:avatar" defaultprimarytype="nt:file" autocreated="false" mandatory="false" onparentversion="copy" protected="false" samenamesiblings="false"> <requiredprimarytypes> <requiredprimarytype>nt:file</requiredprimarytype> </requiredprimarytypes> </childnodedefinition> .. <childnodedefinition name="soc:music" defaultprimarytype="nt:file" autocreated="false" mandatory="false" onparentversion="c

layout - Avoid frequent updates in WPF custom control -

i writing custom control in wpf. control have several properties cause update of control's logical tree. there several methods of form: private static void onxxxpropertychanged(dependencyobject obj, dependencypropertychangedeventargs e) { ((mycontrol)obj).rebuildtree(); } suppose rebuildtree() method complex , lenghty , if users changes several properties, method called several times causing application slowdown , hanging. i introduce beginupdate() , endupdate() methods in windows forms fashion (to ensure update called once), practice disouraged in wpf. i know renderer have lower priority , flicker may not appear, still why spoil precious running time calling same update method multiple times? is there official best practice on how make efficient update of multiple dependency properties (without updating entire control after setting each one)? just set flag when of these properties change, , have refresh method queued dispatcher once. private static

google maps - android locationListener not working? -

i having trouble using loactionlistener in eclipse android. have been googling while can't seem see why shouldn't work. thing can think of maybe because testing device has no sim. (the internet provided via wifi). i have used this reference , still, nothing. could me problem. here relevant parts of activity: public class mainmenu extends activity implements locationlistener{ @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main_menu); themap = ((mapfragment)getfragmentmanager().findfragmentbyid(r.id.the_map)).getmap(); themap.setmaptype(googlemap.map_type_satellite); locman = (locationmanager)getsystemservice(location_service); } @override public void onlocationchanged(location location) { final double lat = location.getlatitude(); final double lng = location.getlongitude(); latlng lastlatlng = new l

XmlHttp Post in Excel VBA not updating website form -

Image
i routinely have search state of nv unclaimed property , put results in excel spreadsheet. trying automate process i'm limited using excel 2010 , vba. below url site i'm trying submit form using xmlhttp. url: https://nevadatreasurer.gov/upsearch/ i created class automate submitting forms on other websites no matter enter in postdata form never submitted. below submission, , method submit form. call class: cxml.openwebsite "post", "https://nevadatreasurer.gov/upsearch/index.aspx", _ "ctl04$txtowner=" & strsearchname class method: public sub openwebsite(stropenmethod string, strurl string, _ optional strpostdata string) pxmlhttp.open stropenmethod, strurl if strpostdata <> "" strpostdata = convertspacetoplus(strpostdata) pxmlhttp.setrequestheader "content-type", "application/x-www-form-urlencoded" pxmlhttp.send (strpostdata) else pxmlhttp.send end if 'cre

android - Updating widget frequently using alarm manager -

i have widget need update new content while device awake. i use alarm manager , set alarm type either elapsed_realtime or rtc, suggested on "app widgets" guidelines on android developer site. the problem need update widget every 5 seconds (probably configurable) while screen on. wherever searched people 5 seconds insane, haven't yet understand if gonna problem if update when device awake. there different approach can take problem? how clock widgets this? while experimenting realized when screen goes off alarm still triggers. stops triggering when device goes deep sleep, in case 5 seconds few anyway device have time go sleep. so did filter screen_on broadcast , schedule alarm every 5 seconds. filter screen_off broadcast , cancel alarm.

jquery - Formatting strings in Javascript - Translating function from python to javascript -

how format strings in javascript? wrote python code , i'm trying translate javascript i'm not sure how python code: def conv(t): return '%02d:%02d:%02d.%03d' % ( t / 1000 / 60 / 60, t / 1000 / 60 % 60, t / 1000 % 60 + 12, t % 1000) does javascript/jquery let similar this? , if so, how? thanks! what you're referring printf / string.format -like operation. unfortunately, javascript not have built-in way of doing (which bad, really). there are, of course, many libraries give kind of functionality. here's 1 of them (sprintf) follows printf syntax, , here's one uses format syntax.

ruby on rails - delayed job doing nothing -

when run rake:jobs work shows running... [worker(host:gregorys-macbook-air.local pid:17243)] starting job worker when run without .delay method runs fine... @post.processimages but when run .delay @post.delay(queue: "processimages").processimages nothing happens... i have delayed_job_web installed , no jobs show in queue any idea can causing this?

sql - Oracle mySQL : Cannot add foreign key constraint -

i creating database table. code not add 2 foreign keys reason, says cannot add foreign key constraints, i'll show tables i'm referring to. mysql> alter table program -> add seriesname varchar(100) not null, add startyear char(4) not null, -> add constraint program_seriesname_fk -> foreign key(seriesname) references series(seriesname), -> add constraint program_startyear_fk -> foreign key(startyear) references series(startyear); error 1215 (hy000): cannot add foreign key constraint series table has program table means 1:n (one-to-many relationship). therefore, 2 primary keys in series become 2 foreign keys in program. mysql> describe series; +------------+--------------+------+-----+---------+-------+ | field | type | null | key | default | | +------------+--------------+------+-----+---------+-------+ | seriesname | varchar(100) | no | pri | | | | startyear | char(4) | no | pri | | | | endyear

c# - Getting brightness of displayed screen or of a Texture2D - Unity3D -

in project, need brightness of screen being displayed. that, snapshot of screen , make texture2d to snapshot , convert use this: public void getscreen(ref texture2d screenshot){ rendertexture rt = new rendertexture(screen.width, screen.height, 24); camera.targettexture = rt; screenshot = new texture2d(screen.width, screen.height, textureformat.rgb24, false); camera.render(); rendertexture.active = rt; screenshot.readpixels(new rect(0, 0, sreen.width, screen.height), 0, 0); camera.targettexture = null; rendertexture.active = null; destroy(rt); } but still need brightness. suggestions accepted (about brightness and/or conversion). in advance. once have pixels, next step use pixels on image sample of them , build brightness them: http://docs.unity3d.com/documentation/scriptreference/texture2d.getpixel.html determining brightness bit of complex issue, depends on application. formula determine bri

c++ - Posix_Time Time Duration Doesn't have all the functions -

i trying use posix_time::time_duration find total number of milliseconds of time. looked @ code online, , found this: how print current time (with milliseconds) using c++ / c++11 . however, reason posix_time::time_duration doesn't have access total_milliseconds function, or several of functions (like is_negative, invert_sign, etc). wondering why case , how can fix it. included header file, #include , in code. have boost libraries installed on computer. thanks.

c# - The server is not operational -

this code i'm using connecting ldap using (direntry = new directoryentry(string.format("ldap://{0}/{1}", this.host, servername))) { direntry.refreshcache(); if (!string.isnullorempty(username)) { direntry.username = username; direntry.password = password; } if (direntry.properties.contains("objectguid")) { byte[] guiddatet = (byte[])direntry.properties["objectguid"].value; return new guid(guiddatet); } i "the server not operational" error message when run code. can please tell me i'm doing wrong. , there anyway replace above code direct ldap query. you should try breaking separate parts, it's easier manage logic, , easier locate errors occurring. go following approach in situation : create ldapconnection object can set options need setup networkcredential

ios - How to order a NSarray with a dictionary by its values -

this question has answer here: sort nsmutabledictionary 6 answers i have following nsarray has nsdictionary , need order them higher dictionary value goes on top. i've researched around can not find predicate sort nsdictionary. how achieve objective?? nsarray* result = @[@{ @"chest":[nsstring stringwithformat:@"%i",[chestr count]]}, @{@"back":[nsstring stringwithformat:@"%i",[backr count]]}, @{@"triceps":[nsstring stringwithformat:@"%i",[tricepr count]]}, @{@"biceps":[nsstring stringwithformat:@"%i",[bicepr count]]}, @{@"arms-other":[nsstring stringwithformat:@"%i",[armsr count]]}, @{@"legs":[nsstring stringwithformat:@"%i",[legsr

asp.net - Active Directory Development Environment -

i have requirement integrate asp.net web application active directory - want able authenticate , authorize ad. i realise relatively simple, want know how can simulate ad developing , testing against. don't have ad available me (right now) , don't cherish thought of setting if had hardware available run on. what other options available me? i've seen adam mentioned in couple of places doesn't seem provide federation services need (and seems little out dated). possible use azure this? want keep costs (time-wise money) minimum. i have managed set active directory environment suitable development using microsoft azure vm. a brief summary of steps went through working below. although sounds scary setting ad , adfs, windows server 2012 interface makes incredibly easier, barring few gotcha's mention below - takes while them install well. create new azure windows server 2012 vm , add endpoints http , https. install ad role on vm install adfs role on

osx - How to start/stop printer? -

how pause/unpause print queue using cups api? using cups api can check printer-state using cupsgetoption(). if returns value of 5, know printer stopped or paused. i'd unpause printer in case, there way this? you use cups' ipptool execute ipp operations : #!/usr/bin/env ipptool -tv ipp://localhost/printers/your_queue { operation resume-printer group operation-attributes-tag attr charset attributes-charset utf-8 attr language attributes-natural-language en attr uri printer-uri $uri } you might asked password though.

plsql - Dealing with PL/SQL Collections -

i have following declaration collection type t_table1 table of table_1%rowtype index binary_integer; tbl1_u t_table1; tbl1_i t_table1; this table keep growing , @ end, used in forall loop insert or update on table_1. now there might cases, want delete element. planning create procedure, take key (unique) , matched element if key found pseduo code for in tbl1_u.fist..tbl1_u.last loop if tbl1_u(i).key = key tbl1.delete(i); end if; end loop; my question is, once delete particular element, collection adjust automatically i.e., index replaced next element or particular index remain null/invalid , possibly give me exception if use in forall insert/update? i don't think can pass table_1%rowtype object procedure, have create record type ? any other tip regarding managing collection bull delete/update/insert appreciate. remeber, dealing 2 tables, if inserting/updating in table_1 means deleting table_2 , vice-versa. given ta

performance - Passing Scala Map as an argument to a function takes too much time -

i have scala companion object method accepts map parameter. in passes map function in different companion object no changes. , actual method call takes time when method execution fast (i measured everything). if don't pass map (use null instead) works fast, passing argument, actual method call slow. am missing something, , map being recreated , not reference passed? object contentelementparser { def parse(node: node, assets: map[string, asset]): option[contentelement] = { //some logic here assetparser.getasset(subnode, assets) //this call slow because of assets map } } object assetparser { def getasset(node: node, assetmap: map[string, asset]): asset = { //logic } } it's being passed reference. else going on--you're measuring first time use map, requires class loading (subsequent calls faster), or you're doing lots more work when pass map opposed null , or out of memory , you're measuring garbage collection

php - Easier method for writing to files -

is there better way of doing this?: $datastring2 = " $leder klarte orgkrim å fikk: ".$showcah." den ".$timed." "; $datastring3 = " $hacker klarte orgkrim å fikk: ".$showcah." den ".$timed." "; $datastring4 = " $driver klarte orgkrim å fikk: ".$showcah." den ".$timed." "; $datastring5 = " $weaponexpert klarte orgkrim å fikk: ".$showcah." den ".$timed." "; $datastringinfo = "$leder, $hacker, $driver, $weaponexpert klarte å oc med å få ".$showcah." tid: ".$timed.""; $datastringinfo .= "\n"; $datastring2 .= "\n"; $datastring3 .= "\n"; $datastring4 .= "\n"; $datastring5 .= "\n"; $fwrite0 = fopen("/home/nordic/www/logger/orgkrim/completed/oversikt.txt","a"); $fwrite1 = fopen("/home/nordic/www/logger/orgkrim/oversikt.txt","a"); $fwrite2 = fopen("

ruby on rails - Search field and box in Nav bar using zurb has black background -

Image
i ran weird bug ruby on rails app want display search field , button in navbar view looks image the problem has black in background search box , button. the following code below: <section class="top-bar-section"> <ul class="left"> <%= form_tag('/search') %> <li> <%= text_field_tag :query, nil ,:placeholder => "search designs", :id=>"nav_search_box" %> </li> <li> <%= submit_tag 'search', :class=>"round button", :id=>"nav_search_btn" %> </li> <% end %> </ul> </section> any insight on fixing bug appreciated! this explained in official docs, under other elements. http://foundation.zurb.com/docs/components/top-bar.html "can use small foundation button in nav, include has-form class parent li."

ruby on rails 3 - ActiveRecord sort children within parent -

is there way pre-sort children of parent through activerecord (rails 3.2.13)? so if have setup this class parent < activerecord::base has_many :children [...] class children < activerecord::base belongs_to :parent something like this: p = parent.where(:name => 'diana').includes(:children, :order => 'd_o_b desc') that way when call p.children getting array of objects ordered birth, , not database id. or need sort array afterward? in parent model, change has_many to: has_many :children, :order => 'd_o_b desc' then anytime access children association parent record ( e.g. , @parent.children ), they'll in descending order of date of birth.

To read MS Access 2010 mdb files with VB6 do I need to get an updated a driver? -

i writing vb6 program needs open ms access 2010 database (.mdb) "invalid file type" error when try. need updated driver(s)? the answer needed did not know "install vb6 sp6". had installed vb6 on new pc couple of years ago, , not aware of service pack let vb6 handle post ms access 1997 tables. anyway.

python - Installing packages within canopy venv -

i looking using canopy express ide. understanding uses backport of venv python 3 manage user-generated virtual environments , in addition being a virtual environment unto itself . want verify within virtual environments create in canopy, able install project-specific packages not included in express distribution using easy_install / pip described here . last link doesn't explicitly such package management works in user-created virtual environment, hence uncertainty. put simply, want (assuming projects 2.7-based) install canopy express once , use default python. various projects requiring packages express doesn't include, can create separate virtual environments , install such packages on as-needed basis. if can't this, other alternative see install canopy express in virtualenv environments on as-needed basis, , use environment's pip s install packages. any thoughts? yes, need install setuptools , pip venv. if use -s/--system-site-packages optio

ActiveAdmin Rails doesn't display entries for model named "Ads" -

i've got few entries in model named ad. when accessing model's url /admin/ads , can't see table rows because being given css id similar "ad_1" . inspecting source shows id has rule display:none in active admin style-sheet. can implement workarounds? thank help, unfortunately it's silly. adblock plus adds display:none #ad_1, #ad_2 , forth. disabling extension fixes issue.

rspec - VCR unhandled http request error -

my specs pass in master branch. if create new branch , modify code unrelated subscriptions, they'll fail this. way can them pass change vcr.rb have :record => :new_episodes . if leave option on, every time specs run have new modified data files cassettes end being committed dilute logs git. any suggestions on how handle this? lot of specs break based on matcher: describe "#change_plan_to", vcr: {match_requests_on: [:method, :uri, :body]} is matcher open changes? wasn't able specs pass other way stripe api calls. failure/error: @subscription.create_stripe_customer vcr::errors::unhandledhttprequesterror: ================================================================================ http request has been made vcr not know how handle: post https://api.stripe.com/v1/customers vcr using following cassette: - /users/app/spec/data/subscription/_change_plan_to/stripe_customer_subscription_plan_/name/.json

excel - .Find method does not work -

i trying use .find method find particular cell in datasheet using following code, worked before, don't understand why not working time... dim targetcell range activeworkbook.worksheets(2).activate set targetcell = activesheet.range("a: p").find(what:="summary total", lookin:=xlvalues, lookat:=xlwhole) the cell "i79".value = summary total could help? thank you! there shouldn't space between "a: p" , check there isn't space after "summary total" in cell.

javascript - what happens when i refresh a jquery mobile page -

what happens when jquery mobile page refreshed? use ajax fetch data in variable called "json" on page1 , when user clicks particular dynamically generated element, store id of clicked element in session variable , changepage() new jqm page2 use json.thepropertyiwant generate list, works fine, , forward buttons work if refresh page2 json.thepropertyiwant becomes undefined here error get: uncaught typeerror: cannot read property 'responsedata' of undefined i using multipage in single html5 page model edit: i have used variable name json , not json typed emphasize, think foolish! i have figured problem. mistake was assuming page refresh call pageinit page on works no differently normal html page refresh , triggers document.ready each time , pageinit page on. is there way listen pagerefresh event , override normal functionality? i believe generate dynamic content of page2 in event. believe event pageinit or pagecreate. events fire o

PHP Lamba-style function code throwing a slew of of undefined variable errors -

i'm using php create_function make lamba-style function contents defined heredoc style string. fine until moved code hostgator account. hostgator environment causing function fail. it looks heredoc working fine, , create_function seems executing. when function gets called, dumps ton of errors claiming every local variable undefined! i'm baffled! seen before? here's code: $func_code = <<<eot extract( shortcode_atts( array('style' => '','class' => '', 'id' => '', 'gutter' => 'm'), $atts ) ); $col_and_gutter = isset($gutter) ? 'needle-' . $gutter : 'needle-m'; switch ($gutter) { case 'ew': $gutter = 'col-extra-wide-gutter'; break; case 'w': $gutter = 'col-wide-gutter'; break; case 'm': $gutter = 'col-med-gutter'; break; case 'n': $gutter = 'col-narrow-gutter'; break; case 'no

eclipse - Android App: My Manifest accepts all screen sizes but the Samsung GT-S6500D can't install it -

i have app in google play store. have set manifest screen sizes accepts small, medium, large, , large (all of screen sizes). app install-able on i've come across both phones , tablets, except has mentioned samsung mini 2 (samsung gt-s6500d) doesn't let them install it. tells them app not compatible device. i've verified running android 2.3.6, , app works 2.3.3 or below. i've been told samsung galaxy tab 2 says not compatible. why happening?? is there missing allow phones / tablets use app? this manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="xxx" android:versioncode="xx" android:versionname="xx"> <uses-sdk android:minsdkversion="10" android:targetsdkversion="17" /> <uses-permission android:name="android.permission.write_external_storage"&

hadoop - Cloudera installation Doubts? -

i new cloudera, installed cloudera in system have 2 doubts, consider machine nodes using hadoop data, can install cloudera use existing hadoop without made changes or modifaction on data stored existing hadooop. i installed cloudera in machine, have 3 machines add clusters, want know, want install cloudera in 3 machines before add machines clusters ?, or can add node clusters without installing cloudera on purticular nodes?. thanks in advance can anyone, please give information above questions. answer questions - 1 . if want migrate cdh existing apache distribution, can follow link excerpt: overview the migration process require moderate understanding of linux system administration. should make plan before start. restarting critical services such name node , job tracker, downtime necessary. given value of data on cluster, you’ll want careful take recent ups of mission-critical data sets name node meta-data. backing data important if

How can i upload a file in a directory using ruby mine? -

this modal file data_file.rb class datafile < activerecord::base # attr_accessible :title, :body def self.save(upload) name = upload['datafile'].original_filename directory = "public/data" # create file path path = file.join(directory, name) # write file file.open(path, "wb") { |f| f.write(upload['datafile'].read) } end end this controller file class uploadcontroller < applicationcontroller def index render :file => 'app\views\upload\uploadfile.html.erb' end def uploadfile post = datafile.save(params[:upload]) render :text => "file has been uploaded successfully" end end and view file <h1>file upload</h1> <%= form_tag :action => 'uploadfile' %> <p><label for="upload_file">select file</label> : <%= file_field 'upload', 'datafile' %></p> <%= submit_tag "upload

multithreading - Why multithread program in Java slow and yet doesn't use much CPU time? -

my java program uses java.util.concurrent.executor run multiple threads, each 1 starts runnable class, in class reads comma delimited text file on c: drive , loops through lines split , parse text floats, after data stored : static vector static concurrentskiplistmap my pc win 7 64bit, intel core i7, has 6 * 2 cores , 24gb of ram, have noticed program run 2 minutes , finish 1700 files, cpu usage around 10% 15%, no matter how many threads assign using : executor executor=executors.newfixedthreadpool(50); executors.newfixedthreadpool(500) won't have better cpu usage or shorter time finish tasks. there no network traffic, on local c: drive, there enough ram more threads use, have "outofmemoryerror" when increase threads 1000. how come more threads doesn't translate more cpu usage , less time of processing, why ? edit : hard drive ssd 200 gb. edit : found problem was, each thread writes it's results log file shared threads, more times run app, larger

c++ - Correct way to diagnose mutex-related bottlenecks -

i'm working on application in shared data structure (an std::map ) both read , updated multiple threads. number of elements in map fixed @ initialization, values change keys not. use mutex , scoped lock, both provided boost, protect access: std::map<key,value> datamap; boost::mutex m; void set(key k, value v) { boost::scoped_lock sl(m); datamap[k] = value; } value get(key k) { boost::scoped_lock sl(m); return datamap[k]; } how determine if access map bottleneck? seems logical me time how long takes acquire mutex in each case, e.g. void set(key k, value v) { timer t; t.start(); boost::scoped_lock sl(m); t.stop(); cout << "time taken acquire mutex: " << t.elapsed() << endl; datamap[k] = value; } i expect that, when there low contention, average time taken should low, , contention increases (e.g. when there large number of threads), average time taken increase. is valid way of diagnosing whether access mutex bottlenec

php - How can I edit an iframe with proxy? -

i need edit iframe jquery i'm unable it. i tried with: $(document).ready(function(){ $("#iframe").on('load',function(){ $(this).contents().find('body').html('a'); }); }); this code doesn't work. edit the iframe related different domain. you answered own question. code doesn't work because of same origin policy . you can use php proxy bypass restriction. <?php $url = "http://example.com"; $domain = file_get_contents($url); echo $domain; ?> and use information in script. this question has more details issue. hope helps!

sqlhelper - Sql helper class in asp.net -

why should use sql helper class in our application.what difference between sql helper class , simple class.in situation sql helper should used.please define structure of class. sqlhelper intended consolidate mundane, repetitive code written time , time again in data access layer components of ado.net applications, this: using microsoft.applicationblocks.data; sqlhelper.executenonquery(connection,"insert_person", new sqlparameter("@name",txtname.text), new sqlparameter("@age",txtage.text)); instead of this: string connectionstring = (string) configurationsettings.appsettings["connectionstring"]; sqlconnection connection = new sqlconnection(connectionstring); sqlcommand command = new sqlcommand("insert_person",connection); command.commandtype = commandtype.storedprocedure; command.parameters.add(new sqlparameter("@name",sqldbtype.nvarchar,50)); command.parameters["@name"].value = txtname.

c++ - compiler error if MFC RUNTIME_CLASS argument has namespace -

i've got answer, see bottom. note: "_afxdll" not predefined case, linking statically mfc. i have code this: myclass.h namespace mynamespace { class cmyclass : public cmybase { declare_dynamic( cmyclass ) ... } } myclass.cpp using namespace mynamespace; implement_dynamic( cmyclass , cmybase) caller cmybase* pobject = new mynamespace::cmyclass(); .... pobject->iskindof(runtime_class(mynamespace::cmyclass)) when compile, i've got error: error c3083: 'classmynamespace': symbol left of '::' must type error c2277: 'mynamespace::cmyclass::{ctor}' : cannot take address of member function i investigated macro runtime_class , found expanded to: #define runtime_class(class_name) _runtime_class(class_name) #define _runtime_class(class_name) ((cruntimeclass*)(&class_name::class##class_name)) (cruntimeclass*)(&mynamespace::cmyclass::classmynamespace::cmyclass) ideally, if can expand follow

Laravel 4 issues with php headers and returning downloads in controller -

i'm using knplabs snappy pdf library generate pdf in laravel 4. works excellently when explicitly put code in routes.php file, when route controller , method code no longer works? missing something, or there more need if executing code in controller. route 'test1' works expected, route 'test2' refreshes browser , shows nothing, not errors. route.php <?php route::get('test1', function() { $pdf = new knp\snappy\pdf('/path/to/vendor/google/wkhtmltopdf-amd64/wkhtmltopdf-amd64'); $headers = array( 'content-type' => 'application/pdf', 'content-disposition' => 'attachment; filename="file22.pdf"', ); return response::make($pdf->getoutputfromhtml('<h1>works!</h1>'), 200, $headers); }); route::group(array('prefix' => 'trial'), function() { route::get('test2', 'mycontroller@download'); }); mycontroller.ph

android - App won't show up in physical device when debugging in eclipse -

this may silly question, it's starting getting on nerves. i develop regular adt in eclipse, , use motorola atrix 2 mb865 in 4.0.4 test. i have due drivers, , eclipse recognizes phone perfectly, , of times works should. lately when hit "run" in eclipse, shows in bottom right of eclipse "launching app ..." , says 100%, never opens it. looking @ console shows [2013-07-24 00:10:37 - moveo_android] ------------------------------ [2013-07-24 00:10:37 - moveo_android] android launch! [2013-07-24 00:10:37 - moveo_android] adb running normally. [2013-07-24 00:10:37 - moveo_android] performing co.aktio.moveo.android.splashactivity activity launch [2013-07-24 00:10:42 - moveo_android] uploading moveo_android.apk onto device 'xxxxxxxxxxxxxxxxxx' [2013-07-24 00:10:43 - moveo_android] installing moveo_android.apk... [2013-07-24 00:11:06 - moveo_android] success! [2013-07-24 00:11:08 - moveo_android] starting activity co.aktio.moveo.android.splashactivity o

select - Update table Data without using while loop in sql server 2005 -

in sql have table data below id type amount 1 type1 2000 2 type1 1000 3 type2 500 4 type3 3000 5 type1 2000 6 type2 500 7 type3 5000 8 type1 1000 and want datas in select statement below id type amount current 1 type1 2000 2000 2 type1 1000 1000 3 type2 500 500 4 type3 3000 3000 5 type1 2000 3000 6 type2 -500 0 7 type3 5000 2000 8 type1 -1000 4000 and on means each type must have current total amount based on amount type , need dont have while loop because takes long time execute for eg: in type 1 id amount current 1 2000-add 2000

php - Conditional Logic Form Validation -

i'm having issues writing logic script. can't seem wrap head around it. i have form contains 6 quantity fields, , 2 corresponding check boxes each quantity field. quantity fields referenced in variables $q1, $q2, $q3, $q4, $q5, $q6 . check boxes referenced in variables $c1_1, $c1_2, $c2_1, $c2_2 ... etc. the logic want achieve is, if input number quantity field, either 1 of 2 corresponding checkboxes must checked or form invalidates. my current code looks this: if( ($q1 !== "" && ($c1_1 == "" || $c1_2 == "")) || ($q2 !== "" && ($c2_1 == "" || $c2_2 == "")) || ($q3 !== "" && ($c3_1 == "" || $c3_2 == "")) || ($q4 !== "" && ($c4_1 == "" || $c4_2 == "")) || ($q5 !== "" && ($c5_1 == "" || $c5_2 == "")) || ($q6 !== "" && ($c6_1 == "" || $

vim - Replace end of line for lines that start with a particular pattern -

i have file in following format --some-xyz-code ; --somemore--xyz--code; comment = " demo" --somemore--code; --somemore--code; i want put semicolon @ end of line comment, keeping rest of line intact. try this: :g/^comment/ normal a; for every line matches comment @ beginning enter in insert mode @ end of line , append semicolon. explanation : :g selects every line matches following pattern ^comment , action after last slash, normal a;

iphone - UIPickerView Height customisation -

need display 4 uipickerview in viewcontroller. how can customise height? minimum height can given 162. can give 100 height each uipickerview? there framework or example available? try this: uipickerview *picker = [[uipickerview alloc] initwithframe: cgrectzero]; picker.showsselectionindicator = yes; picker.autoresizingmask = uiviewautoresizingflexiblewidth; cgsize ps = [picker sizethatfits: cgsizezero]; picker.frame = cgrectmake(0.0, 0.0, ps.width, ps.height + 100);

XPages - Dojo Validation Text Box - Customize Message -

when using dojo validation text box, if try submit xpage without entering value dojo validation text box, see message "this value required". there way of customizing message? (i wish have message in language) you can define customized message dojoattribute: <xe:djvalidationtextbox id="djvalidationtextbox1" value="#{viewscope.test}" required="true"> <xe:this.dojoattributes> <xp:dojoattribute name="missingmessage" value="your customized required message!"> </xp:dojoattribute> </xe:this.dojoattributes> </xe:djvalidationtextbox>

android - Transparent edit text view is different in 2.3 version and 4.2 version -

i'm struggling small problem, question using transparent edit text view in design part, in 4.2 version android device looking fine , good, if check same edit text in 2.3 version , below version showing black coloured edit text. edit text code. <edittext android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dip" android:layout_weight="1" android:alpha="0.3" android:background="@drawable/reg_edittext" android:ellipsize="end" android:ems="10" android:lines="1" android:scrollhorizontally="true" android:singleline="true" android:textcolor="#ffffff" /> here reg_edittext <?xml version="1.0" encoding="utf-8"?> <!-- res/drawable/rounde

java - Deploy Android chat server online -

i have created simple socket based chat application android devices in multiple android emulators connect server running on local machine. server has ip address , running on port. works fine. want deploy server online make visibile users. how can deploy server online user can connect through ip , port?

rubymine - why is form_ tag code is not working in ruby mine 5.4.3.2.1? -

i building ror application in ruby mine .but following doesn't seems run ` <%= form_tag upload_index_path({:action => 'uploadfile'}, :multipart => true) %> <p><label for="upload_file">select file</label> : <%= file_field 'upload', 'datafile' %></p> <%= submit_tag "upload" %> <% end %>` code in view file. trying build site can upload files. appears when click upload button file doesn't uploaded url changes. why that?? this controller code class uploadcontroller < applicationcontroller def index render :file => 'app\views\upload\uploadfile.html.erb' end def uploadfile post = datafile.save(params[:upload]) render :text => "file has been uploaded successfully" end end this model code class datafile < activerecord::base # attr_accessible :title, :body def self.save(upload) name =