Posts

Showing posts from January, 2014

chat - Get conversation list using Sinch API & iOS SDK -

i have develop messaging app , came across sinch messaging sdk. had downloaded ios sdk , tried sinch instant messaging sample app. able send messages , messages. need know: can conversation list using sinch sdk latest message each conversation show in list? how can differentiate incoming chat messages different users. in sample see 1 chat messages screen populates messages different users. so, have property in sinch sdk differentiates conversations? is there possibility create group name, group image group chat? , how sinch api possibly maintain these group chat , single chat message? no, think of delivery mechanism messages, not mailbox. look @ senderid in messages, differentiate sending. you can implement feature sendmessagewithheaders , sinch im not channel discussion group, more suited multirecipient messages.

Explain C++ pointer initialization -

int value = 3; int *pvalue1 = &value; int *pvalue2(pvalue1); cout << (*pvalue1) << " " << (*pvalue2); in above code if have noticed have written int *pvalue2(pvalue1); instead of int *pvalue2 = new int; pvalue2 = pvalue1; still working , giving proper result. can 1 explain me of default function or constructor getting called in case? int *pvalue2(pvalue1); is equivalent to int* pvalue2 = pvalue1; just assign pvalue2 pvalue1 (assign pvalue2 address of variable value ).

java - how to configure a maven project to read from a config.properties file? -

i have servlet dao class has following constructor: public dao() { env = new hashtable<string, string>(); env.put(context.initial_context_factory, "com.sun.jndi.ldap.ldapctxfactory"); env.put(context.provider_url, "ldap://localhost:1389"); env.put(context.security_authentication, "simple"); env.put(context.security_principal, "cn=directory manager"); env.put(context.security_credentials, "secret"); } i've written following config.properties file in source/main/resources : initial_context_factory=com.sun.jndi.ldap.ldapctxfactory provider_url=ldap://localhost:1389 security_authentication=simple security_principal=cn=directory manager security_credentials=secret how configure pom.xml file tell maven use config.properties ? here, resolved adding plugin block: <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>properties-maven-plugin</artifact...

php - Substr 0, -1 return only one character -

i have problem substr() function. $a = ad26tm7i; use this: $b = substr($a, 0, -1); var_dump($b[0]); produce "a". have 5.3.27 php version. know why? on page click ok. help. it because vardump first letter. var_dump($b[0]); gives first letter of string of $b. use var_dump($b);

linux - What permissions are required for scp -

google fails me. permissions need set file make scp -able somewhere? thought read access enough, although can secure-copy file account, collaborators cannot download file test scp username@host.com:/path/to/test test $ ls -aln drwxrwxrwx 3 15016 200 2048 jul 8 13:35 . drwxrwxrwx 3 15016 200 2048 jul 6 18:02 .. -rwxr-xr-x 1 15016 200 0 jul 8 13:35 test

c++ - What does ## (double hash) do in a preprocessor directive? -

#define define_stat(stat) \ struct fthreadsafestaticstat<fstat_##stat> statptr_##stat; the above line take unreal 4, , know ask on over unreal forums, think general c++ question warrants being asked here. i understand first line defines macro, not versed in preprocessor shenanigans in c++ , i'm lost on there. logic tells me backslash means declaration continues onto next line. fthreadsafestaticstat looks bit template, there's #'s going on in there , syntax i've never seen before in c++ could tell me means? understand may not have access unreal 4, it's syntax don't understand. ## preprocessor operator concatenation. so if use define_stat(foo) anywhere in code, gets replaced with struct fthreadsafestaticstat<fstat_foo> statptr_foo; before code compiled. here example a blog post of mine explain further. #include <stdio.h> #define decode(s,t,u,m,p,e,d) m ## s ## u ## t #define begin decode(a,n,i,m,a,t,e) int b...

Sending a message to a contact on another Android device -

while building first android app (a simple game), came across (most newbie) problem: my app needs send message contact (chosen contact list) via own server. same app installed on contact's device, needs retrieve message. the problem facing contact "identification". how can app identify contact such 1 device sends message "id", , device polls messages intended same "id? maybe there kind of id associated contact having android device? thanks (and sorry newbie question :) you can try push notifications service, using google cloud messaging. first device can send http request containing message server manages request , sends message second device, or more 1 device. you can find tutorial here https://developers.google.com/cloud-messaging/

node.js - why does Javascript comparison not work with objects? -

this question has answer here: object comparison in javascript [duplicate] 10 answers i have simple code here. the intention of verify user user wrote post , allow verified user edit post. exports.edit = function(req, res){ post.findbyid(req.params.post_id, function(err, post){ if(err){ return res.json({ type:false, message:"error!" }); }else if(!post){ return res.json({ type:false, message:"no post id" }) }else{ console.log(req.user._id, typeof req.user._id); console.log(post.author.user_id, typeof post.author.user_id); if(req.user._id === post.author.user_id){ // doesn't work!! return res.json({ type:false, me...

Remove the blank space caused by images in beamer - TeX - LaTeX Stack Exchange

Image
i making beamer presentation in need remove figure , replace items in itemize list. however, when remove image completely, there blank space between first , third point (second point after removal of item 2, contains figures). how can rid of space? below frame. \begin{frame} \frametitle{title} \begin{block}{block 1} \begin{overlayarea}{\textwidth}{0.85\textheight} \begin{itemize} \item<1-> item 1. \item<2-4> item 2. \begin{figure} \includegraphics<2> [width=6.5cm, height=2.5cm]{image 1} \includegraphics<3> [width=6.5cm, height=2.5cm]{image 2} \includegraphics<4> [width=6.5cm, height=2.5cm]{image 3} \end{figure} \item<5> item 3 \only<5> abcd \item<5> item 4 \end{itemize} \end{overlayarea} \end{block} \end{frame} i tried placing figure environment in only<2-4> . d...

playframework - Is it possible to set excluded folders for IDEA from SBT? -

i have large multi module sbt project. 1 module play2 project. now, default, intellij idea excludes whole target folder , idea's own compiler not run compile goal sbt, tries figure out itself. leads important play2 parts routes , reverse routers not built. when run sbt compile console, these components built, since in target folder excluded in idea default, idea ignores in there. every time when switching git branches (the play2 project in 1 branch of now) have go project structure , adjust excluded folders manually. is somehow possible have idea figure out itself, , call sbt compile when rebuilding project?

javascript - jQuery variable is not being populated before ajax function. -

please take @ [fiddle][1]. i trying tables selected checkbox contained in given div. tables sent variable $content ajax function before being sent mail function. however, when click send button, getting error - content not defined. jquery('#search-query-send').click(function(){ jquery('.selectthis input:checked').each(function() { var content = jquery(this).parents('div.apartment-entry-container').html(); var email = jquery('#email').val(); }); jquery.ajax({ url:"http://www.greenmonkeypublicrelations.com/scpads/wp-admin/admin-ajax.php", type:'post', data:'action=apartmentsearchemail&email=' + email + '&content=' + content, success:function(result){ //got back...

r - Convert column name to var name -

i have 2 data frames (df1 & df2). 1 data frame has 1 column 1000 rows, , second data frame has 1000 columns. want make df1 column 1 row content var name df2. default names there df1/2 v1, v2.... here examples: df1 v1 b c d df2 v1 v2 v3 a1 b1 c1 a2 b2 c2 a3 b3 c3 final output should this df3 b c a1 b1 c1 a2 b2 c2 a3 b3 c3 names(df3) "a" "b" "c" set names() of df2 vector of df1: df3 <- df2 names(df3) <- df1$v1 assumes rows of df1 , columns of df2 same length.

c# - Cannot Access Command in WPF UserControl's DataGrid Row -

i not able execute command (testcommand) in user control may because datagrid of usercontrol using filedetailslist(list) the following wpf form , using mvvm <window> <tabcontrol> <tabitem header="result"> <usercontrol:filesearchresult></usercontrol:filesearchresult> </tabitem> </tabcontrol> </window> the below user control <usercontrol> <grid> <grid.rowdefinitions> <rowdefinition height="*"></rowdefinition> <rowdefinition height="30"></rowdefinition> </grid.rowdefinitions <datagrid grid.row="0" itemsource="{binding filedetailslist}"> <datagrid.columns> <datagridtemplatecolumn> <datagridtemplatecolumn.celltemplate> <datatemplate> ...

Android : Drive app and Intent.ACTION_GET_CONTENT -

i import files installed google drive app app using intent.action_get_content , mimetype of intent set "*/*". i able other installed app dropbox,onedrive , box, not google drive. here code : intent action = new intent(intent.action_get_content); action.putextra(intent.extra_local_only, true); action = action.settype("*/*").addcategory(intent.category_openable); startactivityforresult(intent.createchooser(action, "upload file from..."),constants.file_chooser_request_code ); thanks. very late answer need remove action.putextra(intent.extra_local_only, true); in order see google drive option in picker.

java - Spring autowired bean for @Aspect aspect is null -

i have following spring configuration: <context:component-scan base-package="uk.co.mysite.googlecontactsync.aop"/> <bean name="simpleemailsender" class="uk.co.mysite.util.email.simple.simpleemailsenderimplementation"/> <aop:aspectj-autoproxy/> then have aspect: @aspect public class syncloggingaspect { @autowired private simpleemailsender simpleemailsender @afterreturning(value="execution(* uk.co.mysite.datasync.polling.poller+.dopoll())", returning="pusher") public void afterpoll(pusher pusher) { simpleemailsender.send(new pusheremail(pusher)); } } this aspect works (i can hit breakpoint on afterpoll) simpleemailsender null. unfortunately cannot find clear documentation on why is. (for record, simpleemailsender bean exists , correctly wired other classes) following things confuse me: is context:component-scan supposed picking @aspect? if surely spring managed bean, ...

how to find a particular redis key memory size in lua script -

redis.call('select','14') local allkeys = redis.call('keys','orgid#1:logs:email:uid#*') = 1 , #allkeys ,1 local object11 = redis.call('debug object',allkeys[i]) print("kk",object11[1]) end here "debug object" run on redis-cli, if want run through lua script on multiple key. send error this. (error) err error running script (call f_b003d960240545d9540ebc2319d863221045 3815): wrong number of args calling redis command lua script debug object not bet . shows serialized length of value, size of object once stored on rdb file. to have hint size of object in redis, need resort more complex techniques, can approximation. need run: type object encoding the object-type specific command length. sample few elements understand average string length of object. based on 4 informations, need check redis source code check different memory footprints of internal structures used, , math. not easy... a m...

mysql - How make use of EXPLAIN keyword? I got the following result -

i did add explain keyword in front of query had no idea how use query optimization. output looks : https://drive.google.com/file/d/0b070x_hytgdbr195rey3q0e3mvu/view?usp=sharing first line -- table scan (see nulls , all) 2nd , 4th line -- index scan ("using index"), rather costly since 10k rows needed. what not tell whether other index(es) more efficient. nor tell whether reformulating query help. please provide select can there, plus tie more things explain. more links: http://myxplain.net/ http://www.sitepoint.com/using-explain-to-write-better-mysql-queries/

vba - Excel Macro Sometimes Breaks? -

i've made macro duplicate excel spreadsheet when run once won't run again? sub add_week() 'copy worksheet dim test worksheet sheets(1).copy after:=sheets(sheets.count) set test = activesheet 'extend date jamesdata = range("d2") firstdate = datevalue(jamesdata) seconddate = dateadd("w", 7, firstdate) range("d2").select activecell.formular1c1 = seconddate 'change sheet name newname = range("d2").text test.name = newname end sub try code. sub add_week() dim newdate string 'copy last sheet sheets(sheets.count).copy after:=sheets(sheets.count) 'extend date newdate = dateadd("w", 7, datevalue(range("d2"))) 'the main problem here, because sheet name can't accept "/, \ , single quote" 'return value "dateadd" method include slash default. 'so, change "dd-mmm-yy...

roo gem - Getting uninitialized constant Student::Roo error while importing csv file in rails -

i have application on want provide feature import records csv , excel file formats. using roo gem it, @ time of importing gives error "uninitialized constant student::roo". here code : student.rb def self.import(file) spreadsheet = open_spreadsheet(file) header = spreadsheet.row(1) (2..spreadsheet.last_row).each |i| row = hash[[header, spreadsheet.row(i)].transpose] product = find_by_id(row["id"]) || new product.attributes = row.to_hash.slice(*accessible_attributes) product.save! end end def self.open_spreadsheet(file) case file.extname(file.original_filename) when ".csv" roo::csv.new(file.path, nil, :ignore) when ".xls" roo::excel.new(file.path, nil, :ignore) when ".xlsx" roo::excelx.new(file.path, nil, :ignore) else raise "unknown file type: #{file.original_filename}" end end student_controller.rb : def import student.import(params[:file]) #puts @session[:current_o...

java - Paypal - Donate option does not appear on create button -

Image
i want add donate button website, when i'm creating button, choicebox not list donation option. how can solve this. it may based on country paypal account in. not every country has ability create donate button in paypal. if going use different button donate image, suggest buy button can leave price field blank in buy button if you'd user can enter own desired amount.

activerecord - Ruby on Rails Redmine Active Record::Record not found for select pages -

i've started @ new company uses redmine , i've been asked upgrade 2.3.3 3.0.3 - complete novice ruby , rails seems ok far. i've installed instance of 3.0.3 , updated database using mysqldump. seems have largely worked, random wiki pages on new redmine don't work - 404 error in browser. everything else has succeeded - user credentials, config application, many projects, issues etc, , in fact many wikis - not of them. have been unable interpret getting error logs. my environment details are: centos 6.5 / red hat 4.4.7-11 (tried on both, result same) ruby 1.9.3 rails 4.2.1 redmine 3.0.3 the output production log app below - activerecord::recordnotfound (couldn't find versions 'id': (all, {:include=>:attachments}) [where `versions`.`project_id` = ?] (found 0 results, looking 2)): lib/redmine/hook.rb:119:in `block (2 levels) in render_on' lib/redmine/hook.rb:117:in `map' lib/redmine/hook.rb:117:in `block in render_on...

PHP: can't upload files to google cloud storage! (error 400) -

i've written short php script in order upload local file google cloud storage bucket, using php client library ( https://github.com/google/google-api-php-client ). can authenticate, can list remote content, can't upload anything, since obtain error 400 ("uploads must sent upload url"). this full script, modified following tutorial found online: <?php require_once "/var/www/local/google-api-php-client-master/src/google/autoload.php"; // api google library define('gapi_client_id', 'xxx.apps.googleusercontent.com'); define('gapi_email_address', 'yyy@developer.gserviceaccount.com'); define('gapi_api_key', 'xxxmyapikeyxxx'); define('gapi_project_id', 'projectid'); // certificate file define('key_file_location', '/var/www/local/passphrase.p12'); // bucket name $bucket = "mybucketname" // remote file name $file_name = "test.mp3"; // file upload $local_f...

sql - Oracle find values in varchar -

is there chance find exact value in varchar using oracle sql? i need find exact value in string (see output). this sql output: rights (varchar) ----- #1 ( id in ( 1560 , 1760 , 1860 , 20200 , 3530, 16000 ) ) #2 ( id in ( 1600 , 20000 , 100000 ) ) i want filter example string 1600 , 1660 . in case #2 should shown. i tried and table1.rights '%1600%' of course doesnt work because shows me #1 wrong. i found using split cant integrate http://lalitkumarb.com/2014/12/02/split-comma-delimited-string-into-rows-using-oracle-sql/ any ideas? i found using split cant integrate http://lalitkumarb.com/2014/12/02/split-comma-delimited-string-into-rows-using-oracle-sql/ good see following blogs , articles :-) no need split string, use like in following way consider space before/after 1600 , no other characters: sql> data(str) as( 2 select '#1 ( id in ( 1560 , 1760 , 1860 , 20200 , 3530, 16000 ) )' dual union 3 select ...

mysql - MariaDB copy table query runs quicker than original table -

scenario is: maria db on cluster i have table, updated twice day, when query takes 6-7 seconds, (it not big table on 100k of rows), when make copy of table , run same query comes 0.7 seconds. now tried optimize original table no luck. there indexes , btree. have feeling when copy table index straighten speak. anyone have idea? tried few suggestions no luck. (copied comment) select sql_no_cache value1, tbl1.c, src, group_concat( distinct round( tbl1.price, 4 ) order tbl1.purdate desc, tbl1.acttime desc separator ' - ' ) purchase, concat_ws (" ", curdef.country , curdef.currname) defin tbl1 left join curdef on tbl1.curr = curdef.curr purdate between date_sub("2015-07-06",interval 1 day) , "2015-07-06" , curdef.curr_def not null , base = "usd" group curr,curdef.curr_id order tbl1.curr asc, tbl1.feeddate desc; here...

ios - Segue in swift based on a logic -

i want show 1 of 2 views in swift based on if statement when application first launches how do logic if signupconfirmed == true { // have show 1 view } else { // have show view } one way can initiate viewcontroller identifier below code: var signupconfirmed = true @ibaction func signuppressed(sender: anyobject) { if signupconfirmed { // have show 1 view let storyboard = uistoryboard(name: "main", bundle: nil) let vc = storyboard.instantiateviewcontrollerwithidentifier("first") as! sviewcontroller self.presentviewcontroller(vc, animated: true, completion: nil) } else { // have show view let storyboard = uistoryboard(name: "main", bundle: nil) let vc = storyboard.instantiateviewcontrollerwithidentifier("second") as! tviewcontroller self.presentviewcontroller(vc, animated: true, completion: nil) } } update: you can perform action in appdelegate.swift ...

Asp.Net HtmlBeginForm() Jquery submit does not work -

i want display partial view using ajax, after form submitted. need listen submit event, , fire ajax display partial view. note: not need submit form using jquery or ajax, need catch event , fire ajax. however, jquery function $("form").submit() not work! i've put breakpoint in chrome debugger , not fired. problem? here code: p.s. form consists of comboboxes user can select application name , version, charts of performance testing results displayed partial view using ajax. @model performancedashboard.models.applicationdashboardviewmodel <h3>per application</h3> <br /> @using (html.beginform("index", "home", formmethod.post, new { id = "form" })) { // @html.antiforgerytoken() <div class="selector-label"> @html.labelfor(model => model.applicationnames) </div> <div class="selector-combobox"> ...

jquery - Using bind, apply or call in JavaScript Example -

i'm dynamically creating table row full of checkboxes using javascript in function populateparametertr(parameters) . in function, set event handler such when checkbox made active, hidden input field created in togglehidden function. what i'm having trouble trying call togglehidden create these hidden input elements after checkbox created, ie not in event handler. reason being: want these hidden input fields when checkboxes loaded first time. understanding calling togglehidden() results in this pointing global scope. i've had @ bind , call , apply see if below: togglehidden(display, parametercontainer).bind(checkbox); can advise me if can done. i'm looking @ example exercise head around using these methods. code: var populateparametertr = function(parameters) { var checkboxes = $('<td></td>'); (var in parameters) { var display = parameters[i].display; var checkbox = $('<input>').attr({ ...

c# - Silverlight Checkbox binding - change checked state in View Model property -

i'm pulling what's remaining of hair out trying work in silverlight works out of box in wpf. i have checkboxes on form represent items - checked property bound bool in viewmodel (one viewmodel per item). when checkbox checked adds item list in viewmodel - before happens want perform validation (in case count how many items in list in other viewmodel, , if reached limit show user message) , if validation fails don't add list , uncheck box. when runs, after validation check done in bool property setter can see value set false, not reflected in checkbox in ui in silverlight checkbox remains checked. in wpf issue not occur. the following code demonstrates issue - brevity instead of performing validation i'm forcing box unchecked when checked. xaml <usercontrol x:class="checkboxtest.sl.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmln...

returning variables F#(canopy) easiest way -

member x.logovani(window : string) = let weburl = ref "" let actwindow = ref "" "login" &&& fun _ -> browser.switchto().window(window) |> ignore weburl := currenturl() actwindow := browser.currentwindowhandle return {|weburl,actwindow|} end hello question how pass weburl , actwindow easiest way, because way of return not working. want call function logovani pass function var window , recieved weburl , actwindow so fixed this member x.logovani(window : string) : string ref = let weburl = ref "" browser.switchto().window(window) |> ignore weburl := currenturl() weburl end

asp.net mvc - Redirect to Error Page Fail on Application Error in Global.asax (MVC) -

i having hard time trying redirect error handling controller when application error encountered in global.asax. here routecollection routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( "default", // route name "{controller}/{action}/{id}", // url parameters new { controller = "home", action = "index", id = urlparameter.optional } // parameter defaults ); routes.maproute( "defaulterror", "{controller}/{action}/{id}", new { controller = "hndlerror", action = "allerrors", id = urlparameter.optional } ); and global.asax application_error has this this.context.response.clear(); this.context.clearerror(); //this.response.redirect("~/hndlerror/allerrors") // 1 works !!! this.response.redirecttoroute( new { controller = "hnd...

php - Performance of $_SERVER['DOCUMENT_ROOT'], or define("SITE_ROOT", ""]); -

i need store document root used across application i have 2 options, please mind explaining quicker , why? or indeed if there better way achieve this. define("site_root", "/"]); $_server['document_root']."/path/to/file" so include created as; require(site_root.'/path/to/file'); require($_server['document_root']."/path/to/file"); to use: define("site_root", "/"); //typo removed is little little bit faster than: $_server['document_root'] . "/path/to/file" since concatenate something, constant bit faster. think falls under micro management , don't think biggest performance issue in code. even if "biggest performance issue", difference small can decide, want use , think more readable.

hadoop - How to read all the data of Common Crawl from AWS with Java? -

i'm totally new hadoop , mapreduce programming, , i'm trying write first mapreduce program data of common crawl. i read data of april 2015 aws. example, if want download data of april 2015 in command line, do: s3cmd s3://aws-publicdatasets/common-crawl/crawl-data/cc-main-2015-18/segments/1429246633512.41/wat/*.warc.wat.gz this command line work, don't want download data of april 2015, want read "warc.wat.gz" files (in order analyze data). i try create job, this: public class firstjob extends configured implements tool { private static final logger log = logger.getlogger(firstjob.class); /** * main entry point uses {@link toolrunner} class run hadoop * job. */ public static void main(string[] args) throws exception { int res = toolrunner.run(new configuration(), new firstjob(), args); system.out.println("done !!"); system.exit(res); } /** * builds , runs hadoop job. *...

r - Detect numerics in string -

i have data in following format: january 2015 2014 may 2012 2011 na wherever there year, insert "december" in front of it. don't want insert "december" in front of "na". may know how in r? you may try below sub function. sub("^(\\d+)$", "december \\1", df$x) ^ - start of line anchor helps match boundary exists @ start of line. \\d+ - matches 1 or more digits. () around \\d+ helps capture particular digit characters. may refer chars present inside capturing group in replacement part using backrefernce. \\1 refers chars present inside first capturing group. $ - end of line anchor. regex match strings has digit chraacters. or sub("^(\\d{4})$", "december \\1", df$x) \\d{4} matches 4 digit chars.

angular material - Is it possible to position content on the same row as md-tab? -

Image
i'm trying place simple logo img next row of tabs, seems default behavior tabs take horizontal space if isn't required display tabs. tried using layout="row" on containing div, made tabs disappear leaving image. possible? edit: in response @nitin below - code not quite i'm asking. see picture of codes results. let me clarify. i'd image on same horizontal tab buttons, red-underlined text is. so: one 2 (some space) image { (some tab content) } this work <md-content class="md-padding"> <md-tabs md-dynamic-height md-border-bottom> <md-tab label="one"> <md-content class="md-padding"> <h1 class="md-display-2">tab one</h1> </md-content> </md-tab> <md-tab label="two"> <md-content class="md-padding"> <h1 class="md...

excel - Class won't work -

i'm learning work classes in vba. i'm attempting write 1 gets true used range. code in class module looks this: option explicit private mysheet range public property cltrueusedrange() range set cltrueusedrange = trueusedrange(mysheet) end property public property let cltrueusedrange(byref wssource range) mysheet = wssource end property private function trueusedrange(byref wssource worksheet) range dim rlastcell range wssource set rlastcell = .cells.find(what:="*", after:=.cells(1, 1), lookin:=xlformulas, lookat:= _ xlpart, searchorder:=xlbyrows, searchdirection:=xlprevious, matchcase:=false) set trueusedrange = .range("$a$1:" & rlastcell.address) end end function when try run it, error message, stating: byref type mismatch what not correct in refrences in code? your function expects sheet, not range . need: set cltrueusedrange = trueusedrange(mysheet.worksheet) or change code below, , pass worksheet whe...

python - Corrupt files when creating HDF5 files without closing them (h5py) -

i using h5py store experiment data in hdf5 container. in interactive session open file using: measurement_data = h5py.file('example.hdf5', 'a') then write data file using self-written functions (can many gb of data couple of days experiment). @ end of experiment close file using measurement_data.close() unfortunately, time time happens, interactive session ends without me explicitly closing file (accidentally killing session, power outage, crash of os due other software). results in corrupt file , loss of complete data. when try open it, error: oserror: unable open file (file signature not found) i cannot open file in hdfview, or other software tried. is there way avoid corrupt file if not closed explicitly? i've read using statement here , i'm not sure if help, when session unexpectedly ends. can restore data in corrupt files in way? there repair program available? always opening , closing file every write access sounds pretty unfavorab...

go - How to filter the elements in the given data using golang? -

this input data: name dept college a1 cse sr1 a2 cse sr2 a3 ece sr1 a4 eee sr3 a5 ece sr1 a6 mech sr2 a7 cse sr1 a8 eee sr1 a9 ece sr3 a10 mech sr3 a11 eee sr1 expected output: if filter college name (for example: --flag=sr3 ) output should print under sr3 , names , depts there. a4 eee a10 mech you need design data model data. have several alternatives here simple 1 struct 3 fields: name, department , college. data in array. read data structures here: https://golang.org/doc/effective_go.html#data you need initialise data structure. maybe have input in text file? can use methods of fmt or bufio read it. they need read command line arguments - them os.args . the filter data , output result. simple for loop on slice 1 if in it. use println output result. sample code: package main import ( . "fmt" "os" ) type record struct { nam...

ios - Objective C Validation -

i've been watching wwdc 2014 advanced ios application architecture , patterns , found interesting , suited case. specially validation part. in example app i've check if team build way. checks be: more 4 players two female, 2 male etc so i've created far: @protocol dexvalidator <nsobject> @required - ( bool ) validate:(nserror * __autoreleasing *)error; @end //implements procotol dexvalidator @implementation dexvalidatorhasfourplayers - ( bool ) validate:(nserror *__autoreleasing *)error { if( _team.length != 4 ) *error = .... return _team.length == 4 } @end so far can see how works, came part didn't understand. talks composition , creates , overall validator checks this: //implements procotol dexvalidator @implementation dexvalidatorteam - ( instancetype ) init { ... _hasfourplayers = [dexvalidatorhasfourplayers new]; ...morechecks... ... } - ( bool ) validate:(nserror *__autoreleasing *)error { ... }...

asp.net - Random numbers in Gridview -

i want on need create gridview (40 rows 10 columns) on asp.net using vb.net , generate , display random numbers between 1 50 in gridview should refresh every 2 seconds. need button turn on , off refresh timer. can 1 or put me right direction? this stored procedure shed light , lead path move forward. using mssql 2014 express, hope can consider moving mssql access. create procedure [dbo].[procgetrandoms] -- procedure name begin drop table randoms create table randoms --your columns ( 1 varchar(20), 2 varchar(20), 3 varchar(20), 4 varchar(20), 5 varchar(20), 6 varchar(20), 7 varchar(20), 8 varchar(20), 9 varchar(20), ten varchar(20), ) declare @row int = 0 while @row < 40 begin -- desired rows set @row = @row + 1 insert [dbo].[randoms] ([one] ,[two] ,[three] ,[four] ,[five] ,[six] ,[seven] ,[eight] ,[nine] ,[ten]) values (--using newid() function first 3 rows abs(checksum(newi...

Rewrite defines as c++ -

hy, it's possible rewrite 2 definitions c++ code functiom? want remove #define define 1: #define do_all_block_ip(iter) \ ((iter) = m_block_ip.begin(); (iter) != m_block_ip.end(); ++(iter)) define2 : #define do_all_block_exception(iter) \ ((iter) = m_block_exception.begin(); (iter) != m_block_exception.end(); ++(iter)) not directly - syntax do_all_block_ip(iter) {/* code here */} not valid if do_all_block_ip function. you use new c++ range syntax, long don't need use iterator directly (only values): for(auto& value : m_block_ip) { // code here } if must use function reason, pass functor, , use lambda expression define that: // definition (assuming m_block_ip vector of block_ip_t) void do_all_block_ip(std::function<void(std::vector<block_ip_t>::iterator)> f) { for(auto iter = m_block_ip.begin(); iter != m_block_ip.end(); iter++) f(iter); } // alternate definition *may* more efficient, more cumbersome temp...

angularjs - Karma Unit Test Error [Phantom Browser] -

i create project using jhipster , combine theme bought themeforest. when try create war, got error this. theme's component error when tested karma phantomjs 1.9.8 (mac os x) error typeerror: 'undefined' not function (evaluating '$.fn.vectormap') @ /volumes/permanent/sts-workspace/emsv2/src/main/webapp/scripts/libs/jquery/jvectormap/jquery-jvectormap-world-mill-en.js:1 phantomjs 1.9.8 (mac os x) error typeerror: 'undefined' not object (evaluating '$.fn.tooltip.constructor') @ /volumes/permanent/sts-workspace/emsv2/src/main/webapp/scripts/libs/jquery/popover/bootstrap-popover.js:37 phantomjs 1.9.8 (mac os x) error typeerror: 'undefined' not object (evaluating '$.fn.tooltip.constructor') @ /volumes/permanent/sts-workspace/emsv2/src/main/webapp/scripts/libs/jquery/popover/popover.js:32 how did install theme? usually, when installing client dependency in jhipster, use bower takes care of updating index.html ,...

regex - Vbscript Regular expression, find all between 2 known strings -

i select texts between 2 know strings. example following text *starthere *general settings * text1 * text2 *endhere i select texts between "*starthere" , "*endhere" using vbscript. final output looks following *general settings * text1 * text2 i know simpler using regex since there multiple instances of such pattern in file read. i tried following /(.*starthere\s+)(.*)(\s+*endhere.*)/ /(*starthere)(?:[^])*?(*endhere)/ but dont seem work , selects start , end strings together. lookforward , backword dont seem work either , iam not sure if have support vbscript. this code using: 'create regular expression object dim objregexp set objregexp = new regexp 'set our pattern objregexp.pattern = "/\*starthere\s+([\s\s]*?)\s+\*endhere\b/" objregexp.ignorecase = true objregexp.global = true until objfile.atendofstream strsearchstring = objfile.readline dim objmatches set objmatches = objregexp.execute(strsearchstring...

javascript - jQuery alphabetical only with numeric -

i'm having difficulties jquery validation. need make input validation alphabetical numeric , shouldn't validate if put numeric value. for example: lorem ipsum 123 should valid, lorem ipsum should valid, 123 shouldn't valid. i use code doesn't work properly. e.find('.alphanum').keypress(function(e) { var regex = new regexp("^[a-za-z0-9 ]+$"); var str = string.fromcharcode(!e.charcode ? e.which : e.charcode); if (regex.test(str)) { return true; } e.preventdefault(); return false; }); this might useful: /^(?:[a-za-z0-9 ]*[a-za-z ][0-9]*)+$/ it same thing 1 provided qwertiy, might simpler understand (which, imho, quality in when comes regular expressions...). what happens form non-capturing group of 0 or more allowed characters, 1 required character, , 0 or more allowed not required characters, , match group. if don't want allow only-whitespace strings either, move space second third characte...

html - How to clear form fields after a submit in laravel -

<div class="form-group"> <label>class</label> <input type="text" class="form-control text-capitalize" name="user_class" value="{{input::old('user_class')}}" placeholder="class"> <div class="col-sm-12"> @foreach($errors->get('user_class') $user_class) <div class="alert alert-danger error">{{$user_class}}</div> @endforeach </div> </div>

ibm midrange - Parameter OBJ is cut off in call to GRTOBJAUT from CL program -

i have made cl program simplify changing owner, usrprf , permissions object. utilizes grtobjaut among others changes. here's parameter definitions: pgm parm(&libobj &type &owner &usrprfown &user1 &auth1 + &user2 &auth2 &user3 &auth3) ... dcl var(&libobj) type(*char) len(21) dcl var(&type) type(*char) len(10) dcl var(&user1) type(*char) len(10) dcl var(&auth1) type(*char) len(10) ... this how call grtobjaut: grtobjaut obj(&libobj) objtype(*all) user(&user1) + aut(&auth1) however, first 10 characters of &libobj passed grtobjaut. have verified in debugger passing instance mylib/test1234 results in grtobjaut obj('mylib/test') , despite &libobj containing full string. according documentation should proper syntax grtobjaut command, allowi...

c - Execution of Sleep () in Xlib programming -

i have used sleep() in below section of code. however, surprise found sleep() executed first , 2 lines used printing pixels executed. means, getting both pixels printed out @ same time after 1 second wait in beginning. however, supposed this, print pixel, wait 1 second, , print next pixel. reason? well, writing x11 server display program. #include<xlib.h> #include<sys/time.h> ---------------- other header files ---------------- int main () ------------variables , few lines of code x11 graphics xdrawpoint(.....); sleep(1); xdrawpoint(.....); ---------- few other stuffs end xlib buffers requests (like drawing operations), , flushes buffer if necessary. can use xflush after drawing first pixel.

c - Iterating over bson array of subobjects -

i wanna iterate on drmdata values in bson object: var loadedbson = { // fields drmdata : [ [0.1,3.1415], [0.2,3.1417], [0.3,3.1418], [0.4,3.1419] ] } here code 2 versions: bson *loadedbson = ejdbloadbson(coll, &_oid); bson_iterator it; bson_type bt; bt = bson_find(&it, loadedbson, "drm_data"); if (bt != bson_array) error(); bson_iterator it_sub; bson_iterator_subiterator(&it, &it_sub); // go inside "loadedbson.drmdata" while (bson_iterator_more(&it_sub)) { bt = bson_iterator_next(&it_sub); if (bt != bson_object) continue; bson_iterator it_sub_2; bson_iterator_subiterator(&it_sub, &it_sub_2); // version 1 started - not work bt = bson_find(&it_sub_2, loadedbson, "val_i"); if (bt != bson_int) // gdb: bt == bson_eoo - bad continue; int val_i = bson_iterator_int(&it_sub_2); bt = ...

regex - QUERY_STRING exact match -

how make exact match partial url, like: page_id=11 301 xyz.com page_id=118 remains page_id=118 i have rewritecond %{query_string} page_id=11 works 118 , 11 in too. you can use condition: rewritecond %{query_string} (^|&)page_id=11(&|$) [nc]

ms office - How can I add folder to outlook without permission to root folder -

i trying add shared folder ms outlook 2010. when file=>open=>open use's folder there no issue. folder appears uncomfortable use mailbox that. main issue when added additional mailbox cannot access it. message cannot display folder. microsoft outlook cannot access specified folder location. operation failed. object cannot found. i think have not permission root folder of mailbox , why cannot folder(which mailbox). unfortunately cannot check if have permission. is there way add folder permanently? you need owner full mailbox access add mailbox existing or new outlook profile (this "permanent" way). otherwise owner of mailbox need use delegate options share 1 or more of default outlook folders (sharing other non-default folders aren't possible). once access shared folder should added navigation module folder type can access later. if owner doesn't share full mailbox or via delegates, don't have access folders , cannot view them. ...

c int comparrison for finish loop -

Image
i have following function do while loop inside: void getfivenumericvalues() { int validationresult; char input[5]; { printf("please enter 5 digits:\n"); validationresult = scanf("%s", &input); printf("validation result: %d\n", validationresult); } while (validationresult != 1); // while (!(validationresult == 1)); // while (validationresult > 1 || validationresult < 1); } the loop doesn't finish when validationresult == 1 . missing here? input[] small hold 5 character string, since needs hold terminating '\0' in addition 5 input characters. if entering 5 characters have buffer overflow , undefined behaviour. change @ least: char input[6]; furthermore line: validationresult = scanf("%s", &input); should be: validationresult = scanf("%s", input); since input pointer. or better yet: validationresult = scanf("%5s",...

javascript - Qualtrics: Empty button appended by jquery refreshes page -

i'm attempting implement experiment in qualtrics, i've run against wall. a button appended qualtrics question using jquery refresh page, regardless of whether or not .click or .event have been defined. in design has effect of wiping responses participant has given until point, last thing want happen. my code complicated (a.k.a. poorly written) post here. can replicate error creating new survey consisting of single 'descriptive text' question , attaching code. here jq refers jquery qualtrics.surveyengine.addonload(function(){ /*place javascript below line*/ jq('.questionbody').append('<button>this shouldn\'t anything</button>') }); this link example of above. https://sydneypsy.qualtrics.com/se/?sid=sv_1zgmxfent0ykxbr why happen? know prevent it? source: robbrit this default behaviour of button. if want change it, this: $("button selector").click( function(event) { event.preventdefault();...

javascript - How can I detect the animationend event on a pseudo element? -

i know how detect animationend event regular dom element, how do pseudo-element? i know event animationend , how attach pseudo-element handler using event? i have tried following, can't seem work. document.queryselector("#someselector:after").addeventlistener("animationend",...,false) how can in vanilla javascript? :after pseudo-elements can't selected though they're part of dom, because, in short, they're not part of dom. being said, possible event triggers you'd expect, they're fired on "parent" of :after . for example, if have :after on dom element id of 'containybox' , can grab dom element , trigger on animationend . event fire when :after 's animation ends. var containerbox = document.getelementbyid('containybox'); containerbox.addeventlistener('animationend', function() { console.log("animation ended!"); }); full working snippet: var containerbox...

json - Use AsyncTask or Thread for frequent read/write operations - Android -

i have built android app allows user create new levels game making. level maker app allows user save new levels , preview levels have saved. when user saves level, app generates jsonobject represents level, writes jsonobject.sostring() value local file (either shared preferences file or plain old .txt file - don't know better yet). when user wants preview existing levels, app reads in json strings levels file, converts each json bitmap (json -> viewgroup -> bitmap), displays bitmaps in listview . right using 2 asynctasks : 1 writing , 1 reading. don't know if potentially spawning 5-10 new threads per minute, though (one each time user saves new level), , don't know if bad thing far system resources goes. here's question: because may need write levels file 5-10 times per minute, better start new asynctask each time user saves new level, or should create 1 background thread , execute runnables on each time user saves or previews levels? asynctas...

broadcastreceiver - Android Wifi broadcast receiver not working as expected -

i have wifi ssid whenever phone connects new wifi network. registered following receiver `registerreceiver(this.mybroadcast, new intentfilter(wifimanager.supplicant_connection_change_action));` this part of code works perfectly. in onreceive method, networkinfo info = intent.getparcelableextra(wifimanager.extra_wifi_info)); always returns null. tried extra_network_info well, returns null. i can't use this.registerreceiver(this.mybroadcast, new intentfilter(connectivitymanager.connectivity_action));, as service stop/start after n minutes , using generate event on every restart of service. any ideas how can solve issue? you can create broadcast within activity step 1 : @override public void onresume() { registerreceiver(); super.onresume(); } private void registerreceiver() { intentfilter filter = new intentfilter(); filter.addaction(connectivitymanager.connectivity_action); filter.addaction(wi...

Sql Query for Updation on Selection -

i created 2 table follows table forgerock : id status amount name date 1 0 4500 ram 04/02/2012 2 0 2000 shyam 05/09/2013 4 0 1500 ghanshyam 08/06/2015 table forgerock1 : id status amount name date 3 0 4500 gopal 04/02/2012 2 0 8000 radheshyam 15/11/2013 4 1 1500 ghanshyam 08/06/2015 sql query select f1.id, case when f1.status = 1 f1.status else f2.status end status, case when f1.status = 1 f1.amount else f2.amount end rank, f1.name, case when f1.status = 1 f1.date else f2.date end date forgerock f1 inner join forgerock1 f2 on f1.id = f2.id , f1.name=f2.name union select id, status, amount, name, date forgerock id not in (select distinct id forgerock1) union select id, status, amount, name, date forgerock1 id no...