Posts

Showing posts from September, 2013

javascript - In chrome extension content-scripts, how can I redirect the current window to a different url and still have the script continue -

i trying write extension goes through google voice inbox , gets phone numbers have ever contacted me. these numbers , them output them www.editpad.org. the issue if try redirect www.google.com/voice www.editpad.org, using window.location.href = "www.editpad.org" i have tried using background scripts like: //content script chrome.extension.sendrequest({redirect: "http://www.editpad.org"}); //background chrome.extension.onrequest.addlistener(function(request, sender, sendresponse) { chrome.tabs.update(sender.tab.id, {url: request.redirect}); sendresponse(); }); however, once redirects, seems script stops running (console.log doesn't work). believe it's because editpad.org not in manifest.json matching websites. if add matching websites, script redirect editpad.org, re-run , refresh on , over. how can redirect page editpad.org , still continue script left off say, "once you're on new page, start executing following function" m

php - Bootstrap to wordpress wont show the image correctly -

Image
i trying convert bootstrap theme wordpress theme , wordpress won't show image. made screenshots showing @ left theme in bootstrap , right 1 in wordpress. and code image container in wordpress don't know doing wrong have tried , nothing works. <div class="container-fluid"> <div class="row" data-fluid=".fluidheigt" data-float="true"> <div class="col-sm-5 imagecol"> <div class="image fluidheigt" style="background-image:url(<?php echo get_template_directory_uri();?>/img/img-our_impact.jpg)"> <img src="<?php echo get_template_directory_uri();?>/img/img-our_impact.jpg" alt="" class="img-responsive visible-xs" /> </div> </div> i have tried change class="img-responsive visible-xs" class="img-responsive.visible-xs" , this: the styles both same bootstrap , w

python 2.7 - boxplot() being tripped up by set_yticks() format -

Image
i trying make 2 boxplots on 1 figure, using plt.subplots() . have done multiple times, making following result: i had messed around scale , because plotting multiple sets of data range 0.0001 100, depending on dataframes being looped through graphing process, need have scale either in scientific format easy readability or in floats precision of 2 digits past decimal. solve this, produced following code: import pandas pd import numpy np import matplotlib.pyplot plt mindex=pd.date_range('07/01/2012', periods=96, freq='h') data00=np.random.rand(96)*20 data01=np.random.rand(96)*0.01 data10=np.random.rand(96)*20 data11=np.random.rand(96)*0.01 df00=pd.dataframe({'observed': data00},index=mindex) df01=pd.dataframe({'observed': data01},index=mindex) df10=pd.dataframe({'wrf': data10},index=mindex) df11=pd.dataframe({'wrf': data11},index=mindex) df0list=[df00,df01] df1list=[df10,df11] k in xrange(len(df0list)): #graphing df0list[k]

How to schedule my Apache Spark application to run everyday at 00.30 AM(night) in IBM Bluemix? -

hi & ibm bluemix team, using ibm analytics apache spark service in ibm bluemix. have developed apache spark application , want run everyday @ 00.30 in night. how schedule apache spark application run everyday @ 00.30 am(night) in ibm bluemix? you can use scheduling tool (crontab on linux) allow run spark-submit.sh script machine @ specific time.(in case 00:30am) a typical crontab entry this 30 0 * * * /<your-directory-where-spraksubmit.sh>/spark-submit.sh --vcap vcap.json --deploy-mode cluster --class org.apache.spark.examples.sparkpi --master https://169.54.219.20 spark-examples-1.6.0-hadoop2.6.0.jar refrence ibm spark-submit.sh https://console.ng.bluemix.net/docs/services/analyticsforapachespark/index-gentopic3.html crontab:- http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/ again can use tools of desire. thanks, charles.

theano - Adaptive learning rate Lasagne -

i using lasagne , theano library build own deep learning model following mnist example. can please tell me how adaptively change learning rate? i recommend having @ https://github.com/lasagne/lasagne/blob/master/lasagne/updates.py . if using sgd, can use momentum term (e.g. https://github.com/lasagne/lasagne/blob/master/lasagne/updates.py#l156 ) adaptively change learning rate. if want make non-standard, momentum implementation give enough hints how create similar on own.

firefox - Exact difference between add-ons, plugins and extensions -

what exact difference between plugins, add-on , extensions. have read lot , confused, example see these 4 definitions: 1-fire-fox says "add-ons collective name extensions, themes , plugins" (see https://support.mozilla.org/en-us/questions/790919 ) 2-www.differencebetween.net says "plug-in , add-on extensions ... plug-in term used when referring third party software (interact program) flash player ... 3- wikipedia ( https://en.wikipedia.org/wiki/plug-in_%28computing%29 ) says plugin being deprecated. 4-i have read in website plugins larger add-ons , consist add-on concept. also have read answer provided in firefox add-on vs. extensions vs. plugins , http://colonelpanic.net/2010/08/browser-plugins-vs-extensions-the-difference/ however want understand these differences in firebreath plugins execute automatically through user's consent , add-on should install manually. think plugin embed in htm page while add-on in form of separated file xpi in fire-fox

javascript - d3 bar chart with custom x axis and bar width -

i want create bar chart custom bar width tried following code not aware if right way do. also want update bar chart new data how can it? to update tried - https://jsfiddle.net/eqr8deef/ var margin = { top: 25, right: 40, bottom: 35, left: 85 }, w = 500 - margin.left - margin.right, h = 350 - margin.top - margin.bottom; var padding = 10; var colors = { 0: ["local", "#377eb8"], 1: ["global", "#4daf4a"] }; var dataset = [{ "global": 1468604556084, "local": 100, }, { "local": 11500, "global": 1313048950629 }, { "local": 11500, "global": 1213048950629 }, { "local": 11500, "global": 1113048950629 }, { "local": 11500, "global": 1123048950629 }, { "local": 11500, "global": 1013048950629 }]; var xscale = d3.scale.ordinal() .domain(d3.range(dataset.length)) .rangeroundband

javascript - Google Places API library is not returning photo_reference attribute -

i'm using google places api details of place, it's not returning photo_reference attributes photos. why?? here's how i'm calling it: var request = { placeid: 'chijn1t_tdeuemsrusoyg83fry4' }; service = new google.maps.places.placesservice(document.createelement('div')); service.getdetails(request, callback); function callback(placed, status) { console.log( placed ); console.log( json.stringify(placed) ); if (status == google.maps.places.placesservicestatus.ok) { console.log( placed ); } } and here's response { "address_components":[ { "long_name":"5", "short_name":"5", "types":[ "floor" ] }, { "long_name":"48", "short_name":"48", "types":[ "street_number" ]

ios - Xcode Instrument screen goes black when recording -

Image
when time profile, after pressing record, screen goes black (should dynamic changed when play app). have encountered same problem? open preferences in instruments , uncheck use deferred mode check box,then restart instruments.😬

c++ - SQLExecute always returning "[Microsoft][SQL Server Native Client 10.0]String data, right truncation" in parameters more than 8k sized -

when execute sqlexecute function returns me "[microsoft][sql server native client 10.0]string data, right truncation" when parameter has more 8k bytes. paste code below. i'm trying do: store xml file in column declared varbinary(max) through stored procedure via odbc drivers (visual c++ 2008) in sql server 2008 r2. sp converts varchar varbinary calling set @xml_file_bin = convert(varbinary(max), @xml_file) works fine if try pasting whole xml int sql server management studio. think wrong binding in sqlbindparameter. code: char* cxmlbuf; contains buffer retcode = sqlbindparameter( hstmt, //statementhandle 1, //parameternumber sql_param_input, //inputoutputtype sql_c_char, //valuetype sql_char, //parametertype sql_desc_length, //columnsize 0, //decimaldigits cxmlbuf, //parametervalueptr buflenght, //bufferlength &cbxml //s

php - Function sometimes skipping first lines when reading Word doc -

i've been using useful tool reading word documents submitted accepted answer here: how extract text word file .doc,docx,.xlsx,.pptx php it works quite apart omits first few lines of text .doc files. here function read .doc file: private function read_doc() { $filehandle = fopen($this->filename, "r"); $line = @fread($filehandle, filesize($this->filename)); $lines = explode(chr(0x0d),$line); $outtext = ""; foreach($lines $thisline) { $pos = strpos($thisline, chr(0x00)); if (($pos !== false)||(strlen($thisline)==0)) { } else { $outtext .= $thisline." "; } } $outtext = preg_replace("/[^a-za-z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext); return $outtext; } it seems issue part: $pos = strpos($thisline, chr(0x00)); if (($pos !== false)||(strlen($thisline)==0)) while correctly removes parts of document aren't

css - Bootstrap affix navbar only works on refresh -

i'm trying create website friend of mine (for learning purposes also). , i'm trying create affix navbar bootstrap. (btw i'm coding on cloud9 using ruby on rails). if preview site, affix navbar works fine, after clicking on link in navbar, navbar stays on position below banner. through inspecting element, found out affix classes don't appended navbar anymore, after clicking 1 of links. i've spent hours trying , fixing nothing seems work. so hope 1 of guys can me out. in advance. the code application.html.erb is: <!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>nl-renovatie</title> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> <

c# - How to properly remove a column from AspNetUsers table that was created during a migration with Package Manager Console? -

Image
i added new table identity's database, , think messed because in aspnetusers table have new column thats foreign key new table , don't want in there. best way remove new column? this how started off public class applicationuser : identityuser { ... public virtual superadminhistory superadminhistory { get; set; } } this class public class superadminhistory { [databasegenerated(databasegeneratedoption.identity)] public int superadminhistoryid { get; set; } public string superadminidcreator { get; set; } public string createdadminid { get; set; } public string datecreated { get; set; } public string modifiedby { get; set; } public string modifieddate { get; set; } public bool isactive { get; set; } } and added applicationdbcontext : identitydbcontext public system.data.entity.dbset<superadminhistory> superadminhistory { get; set; } i when package manager c

sql - My INNER JOIN is filtering out too much -

my inner join filtering out or can't see difference is. i trying consolidate 2 tables 2 different databases on same server. my first step find values match: select intl.* tbldata intl inner join [db].dbo.tbldata on intl.dataid = us.dataid , intl.anotherid = us.anotherid , intl.datavalue = us.datavalue , intl.textvalue = us.textvalue , intl.defaultvalue = us.defaultvalue , intl.ratevalue = us.ratevalue , intl.yetanotherid = us.yetanotherid i've checked columns , same type , same varchar values. query should bring matching values. however... not case. returning 200+ records, if run query after insert 200+ records temp table: select intl.dataid tbldata intl left join tempdatatable tdt on tdt.dataid = intl.dataid , tdt.anotherid = intl.anotherid , tdt.datavalue = intl.datavalue , tdt.textvalue = intl.textvalue , tdt.defaultvalue = intl.defaultvalue , tdt.ratevalue = intl.ratevalue , tdt.yetanotherid = intl.yetanother

php - AngularJS automated routes -

i use lightweight php framework @ job uses mvc architecture, url's built /controller/action/ . in between using same php framework , angularjs + rest api in project start developing on free time. i've familiarized myself basics of angularjs , built structure + authentication tokens. i created route splitting window.location.href, when controller needs parameters, should wildcard. can done? or stuck manually creating route params? .when('/' + controller + '/' + action, { templateurl: '/assets/layouts/' + controller + '/' + action+ '.html', controller: controller + methodpath }) edit: controller not nescessary if init in view element, methodpath method first letter capitalized creating controller usersregister, path /users/register well, figured out. find out rest of path , include them in when . rough example , should extended set default method if 1 not found, such main or index . var location =

apache spark - PySpark createExternalTable() from SQLContext -

using spark 1.6.1. have bunch of tables in mariadb wish convert pyspark dataframe objects. createexternaltable() throwing. example: in [292]: tn = sql.tablenames()[10] in [293]: df = sql.createexternaltable(tn) /home/charles/spark-1.6.1/python/lib/py4j-0.9-src.zip/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name) 306 raise py4jjavaerror( 307 "an error occurred while calling {0}{1}{2}.\n". --> 308 format(target_id, ".", name), value) 309 else: 310 raise py4jerror( py4jjavaerror: error occurred while calling o18.createexternaltable. : java.lang.runtimeexception: tables created sqlcontext must temporary. use hivecontext instead. @ scala.sys.package$.error(package.scala:27) @ org.apache.spark.sql.execution.sparkstrategies$ddlstrategy$.apply(sparkstrategies.scala:379) @ org.apache.spark.sql.catalyst.planning.queryplanner$$anonfun$1.apply(querypla

AutoHotKey: Accessing an array of coordinates -

in autohotkey, i've defined global array as: tab_index_array := [] further down in script call function build table: buildtabindexarray() { global ; coords of each of 8 selectable tabs on screen tab_index_array.push(332,490) tab_index_array.push(378,490) tab_index_array.push(433,490) tab_index_array.push(486,490) tab_index_array.push(557,490) tab_index_array.push(611,490) tab_index_array.push(685,490) tab_index_array.push(745,490) } this seems pretty straight forward me, however, when i'm trying access table, ever blank (empty) values. clicktab(which_tab) { global coords_ := [] tab_str := tab_index_array[which_tab] stringsplit, coords_, tab_str, "," x_ := coords_[1] y_ := coords_[2] splashtexton,,, %x_% "`n" %y_% settimer, killsplashtext, -5000 ;setmousedelay, slow_click_wait_time ;sendevent {click, %x_%, %y_%} ;setmousedelay, click_wait_time } what doing wrong? want grab coordinates out of arr

sql server - T-SQL extract image from Max(Date) -

i have pictures in database need extract. image column of type varbinary(max) . i tried several examples using either join or subquery no avail. query developed work if wasn't image. using distinct , max(date) still can't eliminnate older image. many ids have multiple pictures. using max(date) extract recent date, adding in picture eliminates filtering. the query looks this: select distinct id, image, datemodified, getdate() images type = 'b' id image datemod type 1 0x789 01-02-2014 b 1 0x791 11-12-2015 b <-- tgt record 2 0x675 12-01-2015 5 0x324 06-26-2015 b <-- tgt record if use max(datemodified) , forces group by , still doesn't eliminate older images. need newest type 'b' image each id. working on sql server 2012. what need output image, id, datemodified, todaysdate (getdate) pretty sure want this. with sortedresults ( select id , image , datemod , typ

computer vision - Face recognition using PCA on Matlab -

i'm trying classify set of images using pca on matlab. training set contains ~1800 images of 380 persons, each image person's unique label (id). testing set contains ~750 images of same 380 persons (different images), each image person's corresponding label (id). images 160 x 128 pixels. my code follows. img_train{i} contains i-th original image in training set, img_test{i} contains i-th original image in testing set. euclide_dist = zeros(total_trainimagefiles,1); num_correct_labels = 0; % reshape 2d training images 1d image vectors train_img = zeros(irow*icol,total_trainimagefiles); = 1 : total_trainimagefiles temp = reshape(img_train{i}',irow*icol,1); train_img(:,i) = temp; end % calculate mean image vector mean_face = mean(train_img,2); % subtract mean face training images centred_data = train_img - repmat(mean_face, 1, total_trainimagefiles); % determine eigenvectors , eigenvalues using svd [u, d, v] = svd(centred_data,0); d = 10; % generate

javascript - Counters show permanently even if onclick -

i have following entry in table: <tr> <td class="right-middle user">name</td> <td class="right-middle done"> <div onload="clickcounter()" id="result"></div> </td> <td class="right-middle check"> <img src="img/check.png" onclick="clickcounter()"> </td> <td class="right-middle undone"> <div onload="addcounter()" id="result2"></div> </td> <td class="right-middle uncheck"> <img src="img/uncheck.png" onclick="addcounter()"> </td> </tr> and following javascript: function clickcounter() { if (typeof (storage) !== "undefined") { if (localstorage.clickcount) { localstorage.clickcount = number(localstorage.clickcount) + 1; } else {

android - Adding distance to a GPS coordinate -

i'm trying generate points @ random distances away fixed point using gps. how can add distance in meters gps coordinate? i've looked @ utm gps conversion there simpler method achieve this? i'm working on android platform in case. cheers, fgs p0(lat0,lon0) : initial position (unit : degrees ) dx,dy : random offsets initial position in meters you can use approximation compute position of randomized position: lat = lat0 + (180/pi)*(dy/6378137) lon = lon0 + (180/pi)*(dx/6378137)/cos(lat0) this quite precise long random distance offset below 10-100 km edit: of course in java math.cos() expects radians use math.cos(math.pi/180.0*lat0) if lat0 in degrees assumed above.

c# - NCrunch is launching the ApprovalTests DiffReporter -

how ncrunch stop launching diffreporter when running tests in background, diffreport when manually run test? i've been trying working while now, none of combinations i've tried giving me results i'm looking for. leaving [usereporter(typeof(diffreporter))] attribute commented out. when test starts failing come , un-comment until fix issue, comment out, getting cumbersome methods multiple [testcase] . i've been reading on approvaltests blog, seems should possible. my diff software beyond compare, , code looks this: testproject/assemblyinfo.cs [assembly: usereporter(typeof(ncrunchreporter))] testproject/classtests.cs public class classtests { [test] //[usereporter(typeof(diffreporter))] [testcase(1, 1)] [testcase(1, 2)] [testcase(2, 1)] [testcase(3, 1)] public void testcase(int errornumber, int ) { using (approvalresults.forscenario(errornumber, testcasesubtestnumber)) { var results = dosomething

javascript - JQueryUI autocomplete doesn't update its data-attribute from the select box -

example $('select').change(function(){ $('#auto').attr('data-id',$(this).val()) }) $('#auto').autocomplete({ delay: 1000, source: function( request, response ) { alert($(this.element).data('id')) return false } }) <select name="category"> <option value="a">a</option> <option value="b">b</option> <option value="c">c</option> </select> <input id="auto" data-id="a" type="search"/> i want update auto-input data attribute when select option in selectbox. is there way prevent auto-complete input caching data attribute? input able update data-id first time change option b in selectbox. when change b c , input still alerting b instead of c . $(this.element).data('id') not appropriate way of getting latest data attribute? what picking value dir

ios - UISearchBar in UISearchController slips to the right when tapped -

Image
i have uisearchbar inside uisearchcontroller pushes right when tapped. this how search bar looks after initial setup below code use setup search bar inside uiviewcontroller //set self object recieve updates of uisearchresultscontroller self.searchresultsupdater = self; //hide navigation bar during presentation of uisearchcontroller. self.hidesnavigationbarduringpresentation = yes; //set delegates uisearchbar , uisearchcontroller self.delegate = self; self.searchbar.delegate = self; //set scope bars not exist self.searchbar.scopebuttontitles = [nsarray array]; //some additional settings can configured self.context.definespresentationcontext = yes; self.dimsbackgroundduringpresentation = no; [self.searchbar sizetofit]; self.tableview.tableheaderview = self.searchbar; self.context.edgesforextendedlayout = uirectedgetop; self.searchbar.clipstobounds = yes; once user presses on search bar, behaves this. all of other controllers working, fine. it's 1 controller

php - How to install Zend 2.4.8 on wamp in windows 7? -

i have failed install zend 2.4.8 on wamp server in windows 7 32 bit. can 1 suggest me right way install zend 2.4.8 configeration. ? ! i have tried more , more. there no proper way can find solve problem. there many tutorial no 1 working me. also advanced ! by telling steps make answer sooo long. provide best link refer , complete successfully. you can download zend framework on here. , may need composer too. zf little hard install , understand beginner(freshers) specially working first time in framework specially zend framework 2 installation.there many website providing step install zend framework in windows machine haven't put installation step keep in mind freshers. tutorials install zend framework in wamp composer , php environment variable fix

If javascript bool is true, show HTML -

how show html based upon javascript boolean? have html shows "all ok" in span. need show html based upon result of javascript query. what i'd (similar using server code) <script> if (mypreviouslydefinedvariable == true){ <span>yes</span> } else { <span>no</span> } </script> please note, whilst i'm showing simple span actual code large block of html. know "convert" html javascript hoping avoid this, similar rendering partial in mvc.net you can't embed html directly javascript (it creates javascript syntax error illegal javascript). html page doesn't work way. can use document.write() insert javascript page @ current point of execution or can use other dom manipulation methods modify current page script. for example, this: <script> if (mypreviouslydefinedvariable) { document.write("<span>yes</span>"); } else { document.write("<span>no</span&g

php - Codeigniter Contact form submit returning timeout -

hi wondering if give me insight why codeigniter contact form times out on submit? i understand beginner error feel overlooking. have provided controller , view. i have email.php setup in config file well, various helpers , libraries loaded. thank in advance! controller <?php class contactform extends ci_controller { public function __construct() { parent::__construct(); $this->load->helper(array('form','url')); $this->load->library(array('session', 'form_validation', 'email')); } function index() { //set validation rules $this->form_validation->set_rules('name', 'name', 'trim|required|xss_clean|callback_alpha_space_only'); $this->form_validation->set_rules('email', 'emaid id', 'trim|required|valid_email'); $this->form_validation->set_rules('subject', 'subject', &

informatica - Keeping Data Integrity, Losing leading zero, dropping zero off money, converting number to month -

i mapping oracle views output csv file. used expression transformation apply rules. here have been struggling with database value -> output csv value 0023 -> 23 23.00 -> 23 23-01 -> 23-jan for 0023, leading 0 lost, varchar in view, string in sq , string in flat file. tried lpad(value, 4, '0') nothing works for money, string in flat file, tried to_decimal(hourly_rt, 2) in transformation, did not work. the 23-01, concat 2 fields together, concat(concat(value1,'-'), value2). value1 , value2 varchars in view , string in sq. not sure how value2 got converted month. any appreciated. thanks. the output csv file has values expect. when opening file in excel, formatting values that. try opening csv file in notepad or other text editor.

Combine a PostgreSQL EXCLUDE range constraint with a UNIQUE constraint -

in postgresql, how combine exclusion constraint on range column unique constraint on other, scalar columns. or put way, how ensure range overlap check done in combination unique check on other columns? for example, have: create table reservation ( restaurant_id int, time_range tsrange ); i want make sure each restaurant_id , there no overlapping time_range s. i know can create exclusive range constraint this: create table reservation ( restaurant_id int, time_range tsrange exclude using gist (time_range &&) ); but how make sure time_range check scoped restaurant_id ? create table reservation ( restaurant_id int, time_range tsrange, exclude using gist (restaurant_id =, time_range &&) ); note need install extension btree_gist because gist index not have equality operator default: http://www.postgresql.org/docs/current/static/btree-gist.html

excel - How to pass Variable from Python to VBA Sub -

i trying call vba sub python code convert excel files in specified folder xls xlsm format. i can use following code when not using variable in vba , works well. python code: import os import win32com.client xl=win32com.client.dispatch("excel.application") xl.workbooks.open(filename="c:\users\name\documents\personal.xlsb", readonly=1) xl.application.run("personal.xlsb!module1.xlstoxlsmfinal" xl.application.quit() # comment out if excel script closes del xl vba code: public sub xlstoxlsmfinal() ' goes through sub folders of specified folder , created xlsm(macro enabled version) of xls documents dim fso, ofolder, osubfolder, ofile, queue collection set fso = createobject("scripting.filesystemobject") set queue = new collection path = "c:\users\name\documents\monthly reports\16.06 reports\agent reports" queue.add fso.getfolder(path) while queue.count > 0 set ofolder = queue(1)

swift - iOS: Core Data light weight migration is throwing error -

in 1.0 version of app, have created core data db named "myapp.sqlite". when core data light weight migration same name "myapp.sqlite", getting below error terminating app due uncaught exception 'nsinternalinconsistencyexception' , reason: 'can't modify immutable model below code // mark: - core data stack lazy var applicationdocumentsdirectory: nsurl = { let urls = nsfilemanager.defaultmanager().urlsfordirectory(.documentdirectory, indomains: .userdomainmask) return urls[urls.count-1] }() lazy var managedobjectmodel: nsmanagedobjectmodel = { // managed object model application. property not optional. fatal error application not able find , load model. let modelurl = nsbundle.mainbundle().urlforresource("myapp", withextension: "momd")! return nsmanagedobjectmodel(contentsofurl: modelurl)! }() lazy var persistentstorecoordinator: nspersistentstorecoordinator? = { print("hello") /

c# - WPF binding TextBox to integer property without throwing exception -

i binding textbox.text int property: <textbox text="{binding lines, updatesourcetrigger=propertychanged}" /> private int _lines = 10; public int lines { { return _lines; } set { _lines = value; } } everything works expected simple code, there validation textbox. there exception system.formatexception thrown in output log. question is: there elegant way rid of exception without reimplementing everything myself? mean validators, convertors, etc. ton of code not call int32.tryparse instead of int32.parse . not exception thrown , handled wpf big problem, full log makes finding actual problems more difficult. the question isn't clear, assume referring exception occurs if user enters invalid text (i.e. non-numeric, non-integer data). afaik, wpf not include built-in control restricts user input. options are: use 1 of the several third-party implementations of wpf masked text-box control . host system.windows.forms.maskedtextbox contr

c# - Performance issues in processing loop -

while iterating through dataset of 3000 float values , running inner loop, code runs through first 10% in seconds takes 20 minutes complete last 90%. number of new objects created has been reduced as practical. calling gc.collect(); gc.waitforpendingfinalizers(); @ fixed intervals in outer loop resulted in no change. how can fast performance maintained through entire loop? actual class used instead of object. public method: public static float [] compute ( ref float [] sourcedata , ref object [] referencedata, ref float [] progress ) { int count = 0; float [] result = new float [sourcedata.length]; float inverselength = 1f / ((float) sourcedata.length); ( int = 0; < sourcedata.length; i++ ) { progress [0] = ( (float) ) * inverselength ; result[i] = computedatum (ref sourcedata [i], ref referencedata); if (count++ == 100) { cou

Combine strings in multidimensional array and keep key - PHP -

i have array: array(1) { ["comments"]=> array(244) { [113]=> array(2) { [0]=> string(40) "2016-07-15 09:27 | on track done" [1]=> string(40) "2016-07-15 09:56 | done on track" } } } and want make array: array(1) { ["comments"]=> array(244) { [113]=> array(1) { [0]=> string(80) "2016-07-15 09:27 | on track done 2016-07-15 09:56 | done on track" } } } i need keep key [113] , merge values. need comments in 1 array. in example there 2 comments, more. i tried array_merge, array_value , loop. couldnt it. a more general algorithm : <?php // sample data. $arr = array( "comments" => array( 0 => array( "2016-07-15 09:27 | on track done", "2016-07-15 09:56 | done on track" ),

java - PGP signature format reader -

in project need verify pgp clear signed signatures using corresponding public key. while did manage find code (for example: https://github.com/cjmalloy/openbitpub/blob/64485d64a699eb6096f01b27d5f7e51dd726602f/src/main/java/com/cjmalloy/obp/server/pgp/pgputil.java ), operates on low level , looks pretty horrible. i thinking, perhaps there exist specialized parsers can consume -----begin pgp public key block-----xxx-----end pgp public key block----- , -----begin pgp signed message-----xxx-----begin pgp signature-----xxx-----end pgp signature----- blocks can check signatures in more declarative way? i've found related pemreader class bouncycastle.openssl package nothing pgp-related far. i thinking, perhaps there exist specialized parsers can consume -----begin pgp public key block-----xxx-----end pgp public key block----- , -----begin pgp signed message-----xxx-----begin pgp signature-----xxx-----end pgp signature----- blocks can check signatures in more de

java - Unable to correctly generate checksum -

i trying calculate simple checksum , i'm doing checksum test. public void readfile() { byte counter = 0; byte[] data = new byte[68]; while(x.hasnextint()) { data[counter++] = (byte)x.nextint(); if(counter == 67) break; } int sum = 0; (int = 0; < 67; i++) sum += (data[i] & 0xff); system.out.println((int)(sum & 0xff)); //checksum //perform checksum test. data[counter] = (byte)(sum & 0xff); sum = 0; (int = 0; < 68; i++) sum += (data[i] & 0xff); system.out.println((int)(sum & 0xff)); //checksum test } i reading first 67 integer values of file , saving them inside byte array. integers < 256. variable 'x' file reading. however, when perform checksum test, value outputted isn't 0. not able diagnose computing incorrectly. i'm not sure you're trying do. first 67 characters, calculate checksum, , assume 67, plus checksum,