Posts

Showing posts from September, 2014

c# - match pattern for startswith -

i want regex match in c# check whether string starts part of pattern. if pattern "abc...ghi" valid strings can in format "a","ab","abcdef","abcxyxghi" this sample code. regex has in pattern make work string pattern = "abc...ghi" code = "a" //valid code = "abc" valid code = "abcde" //valid code = "abcxxx" //valid code = "abcxxxghi" //valid code = "abcxxxghiaa" //invalid code = "b" //invalid regex.ismatch(code, pattern) you can use ? , make optional part of regexp. final regexp string be a(b(c(.(.(.(g(h(i?)?)?)?)?)?)?)?)? the final string quite messy can create automatically the visualization of above regexp here http://www.regexper.com/#a(b(c(.(.(.(g(h(i%3f)%3f)%3f)%3f)%3f)%3f)%3f)%3f)%3f

microsoft dynamics - Select Statement Vs Find in Ax -

while writing code can either use select statement or select field list or find method on table fetching records. wonder of statement helps in better performance it depends on need. find() methods must return whole table buffer, means, of columns projected buffer returned it, have complete record selected. need single column, or few. in such cases can waste select whole record, since won't use columns selected anyway. so if you're dealing table has lots of columns , need few of them, consider writing specific select statement that, listing columns need. also, keep in mind select statements project few columns should not made public. means should not extract such statements method, because imagine surprise of consuming method , trying figure out why column x empty...

Storing Images in java project dynamically -

i working on website in java. when login website have use_case fetch images other websites , show them in website. problem don't want show images storing url, because url may change , in case images won't displayed. so, want store or write url image in location. way, next time when login website, wll fetch image location. so, question store these images. if store images in tomcat webapps folder next time when build project folder deleted. storing in tomcat webapps folder not approach , not suffice purpose. can't use database same. , please elaborate i want store or write url image in location mean that.

want to refer to some cousin child value in xml path -

this xml doc <ct> <child 1> 10 </child 1> <child 2> 20 </child 2> </ct> <th> <child 3> 100 </child 3> <child 4> 200 </child 4> </th> <ct> <child 1> 30 </child 1> <child 6> 40 </child 6> </ct> <th> <child 7> 300 </child 7> <child 8> 400 </child 8> </th> i want fetch value 30 have used following xpath root/parent/th../ct/child1 i cannot change root/parent/th fixed according requirements can change rest of xpath starting ../ct/child1 you have error in xpath expression: not /th../ /th/../ also, /root/parent/th selects 2 th elements , it's not clear 1 should used because both of them have preceding ct child1 child. straightforward answer is /root/parent/th[last()]/preceding-sibling::ct[1]/child1 i.e. first preceding sibling element ct of last th. but...

How to query the feeds of a specified video on youtube? -

for example, need feeds of video: https://www.youtube.com/watch?v=179m7qya7oo , how should query? i need because want embed videos app, want write tool query following properties make sure can use it: yt:accesscontrol media:restriction media:price there api retrieving information single video: https://gdata.youtube.com/feeds/api/videos/videoid?v=2

sql server - SQL Query - Multiple Table Join With Grouping Functions that Keep Branch Structure -

i have exhausted search solution , post question see if solution exists. i need write report show debits , credits per branch. report needs show if branches have had no dbs or crs. for simplicity have scaled down tables try highlight issue. my first table holds branch data branchno branchname 1 main 2 mgorogoro 3 arusha my second table holds debit transactions txid narrative amount date branchno 1 test 1 50.00 2014/11/26 1 2 test 2 20.00 2014/11/27 3 i've written sql statement gives me results need:- declare @get_dates cursor; declare @date varchar(10); declare @tbl table ( debitoutcount int, branchcode varchar(250), txdate varchar(10) ) --declare @tbl table(idx1 varchar(50), idx8 varchar(50), idx3 varchar(50)) set @get_dates = cursor select debits_out.date debits_out group debits_out.date...

java - storing image as physical file on server -

i getting problem in storing images fetched url.the problem store image on server , path given on database.how store images on server physical files , later on retrieve image on jsp page. you should make folder in project, use folder store physical files , give path in action. online example here store image database specific folder. download code here - project url your modification not store in db store in folder, example if have stored files in folder "images" system.out.println(request.getrealpath("/")+"images\"+"yourfilename"+".jpg"); above code give path of physical path on server. your question possible duplicate of struts2: how store images outside of webapp , save path db? storing images in java project dynamically

watchkit - Apple Watch Main menu screen in the Emulator -

Image
when launch watch app, shows watch app screen designed. how can see home screen of apple watch in emulator. this not possible, @ least not yet. in xcode have choose target scheme (app or glance) want run in simulator. i think apple not want show apple watch might before released.

jquery - Google maps in bpopup by ajax -

i use bpopup plugin ajax popups. need display popup google map. displaying popup without problem. js $(document).on('click', '.aboutbranch', function(e){ e.preventdefault(); $.ajax({ type: 'post', url: '/ajax/show-branch', data: {delivery_id: ..., branch_id: ...}, success: function(html) { $('#branchbox').html(html); $('#branchbox').bpopup(); } }); }); in template append ajax #branchbox simple. there stuff around google map too. experimented sync , async loading map. both didn't works. sometime map loaded no. timeout didn't help. have experiences append google map ajax loaded content (even bpopup) ? advice. template <div id="map_canvas" style="width: 100%; height: 400px;"></div> <script type="text/javascript"> function initialize() { var mapoptions = { center: { lat: parsefloat(latfromphp), lng: parsefloat(lngfromphp)}...

Java to Wsdl Mapping in Windup Tools -

i trying deploy sample weblogic application in jboss 7.1.1 final. needed use windup tools. in windup tool shows **java wsdl mapping ** following code. don't know is. googled it, still no progress. please me out here. lengthy code, more thousand lines. have given sample. <?xml version='1.0' encoding='utf-8'?> <j2ee:java-wsdl-mapping xmlns:j2ee='http://java.sun.com/xml/ns/j2ee' xmlns:xsi='http://www.w3.org/2001/xmlschema-instance'> <j2ee:package-mapping> <j2ee:package-type>spclink</j2ee:package-type> <j2ee:namespaceuri>a url here</j2ee:namespaceuri> </j2ee:package-mapping> it's mapping tells webservices provider how de/serialize java objects from/to xml. it's generated java, or other way, wsdl can generate java objects. guess it's done manually. should able find matching java classes in source. i think nowadays can rely on annotations, , on default ...

VBA in Excel Run-time error '91': Object variable or With block variable not set -

i'm new vba , i'm using colour code graph based on values. when step through code works, when try , run end-to-end error. appreciated. the program stops @ "for = 1 activechart.seriescollection.count activechart.seriescollection(i)" error!!! sub updchartcolours() dim long dim num1 integer dim num2 integer dim num3 integer dim num4 integer dim num5 integer dim num6 integer num1 = sheet1.cells.item(19, "e").value num2 = sheet1.cells.item(21, "e").value num3 = sheet1.cells.item(23, "e").value num4 = sheet1.cells.item(25, "e").value num5 = sheet1.cells.item(27, "e").value num6 = sheet1.cells.item(29, "e").value = 1 activechart.seriescollection.count activechart.seriescollection(i) if = 1 , num1 = 1 .interior.color = rgb(255, 0, 0) elseif = 1 , num1 = 2 .inte...

erlang - Best way to log access to web pages -

one of website using nitrogen cowboy server. log every access web pages apache access.log. best way ? each underlying webserver differently (or not @ all) - simple_bridge not yet have abstracted. so in case of cowboy, you'll have rig yourself. if you're using newer build of nitrogen (if have file site/src/nitrogen_main_handler.erl ), can edit file manually log yourself. example, using erlang's error handler, add simple like: log_request() -> error_logger:info_msg("~p: [~p]: ~p", [{date(), time()}, wf:peer_ip(), wf:url()]). run() -> handlers(), log_request(), %% <--- insert before wf_core:run() wf_core:run(). then whatever happens log can handled configuring error_logger write disk ( http://erldocs.com/17.0/kernel/error_logger.html?i=13&search=error_logger#logfile/1 ) if use older nitrogen (which have site/src/nitrogen_cowboy.erl ), edit file, once again before wf_core:run() call. alternatively, hooks option c...

.net - Better approach to execute procedure at Dot Net front end -

i have form built in c#.net , has got approx 40 controls, controls datavalues comes sql server database. of following better approach write 1 procedure , add queries each controls in procedure execute sequentially , result dataset , loop controls , bind each datatable. for example: connection.open dataset ds = executeproc("someproc") control1.datasource=ds.tables(0) control2.datasource=ds.tables(1) control3.datasource=ds.tables(2) . . . . connection.close write procedure each control , bind them, threading technology execute parallely, in case each procedure need open , close connections each procedure when executed. for example: all running parallely: connection.open dataset ds = executeproc("someproc1") control1.datasource=ds.tables(0) connection.close connection.open dataset ds = executeproc("someproc2") control2.datasource=ds.tables(0) connection.close connection.open dataset ds = executeproc("someproc3") control3.data...

javascript - Web Sql select statement not able to extract third column -

demo i unable retrieve third value of row showing undefined when displayed using alert box .what trying achieve insert 4 rows table , retrieve them required sorted based on column html <div id="status" name="status">status message</div> javascript var db = opendatabase('mydb', '1.0', 'test db', 4 * 1024 * 1024); var msg; db.transaction(function (tx) { tx.executesql('create table if not exists logs (id unique, log text,log1 text)'); tx.executesql('insert logs (id, log,log1) values (1, "foobar","sa")'); tx.executesql('insert logs (id, log,log1) values (2, "logmsg","da")'); msg = '<p>log message created , row inserted.</p>'; document.queryselector('#status').innerhtml = msg; }); db.transaction(function (tx) { tx.executesql('select * logs', [], function (tx, results) { var len = results.r...

ios - Invalid top-level type in JSON write in Swift -

i'm trying put using afnetworking. need send array of participants in competition, i'm getting "invalid top-level type in json write in swift" error. json generate perfect, , if try using rest client works. here's code: func sendusers(oncomplete: (nserror?) -> void) { var error: nserror? var jsondata: nsdata = nsjsonserialization.datawithjsonobject(self.createdictionaryofparticipations(), options: nsjsonwritingoptions.allzeros, error: &error)! var jsonstring: string = nsstring(data: jsondata, encoding: nsutf8stringencoding)! println("json: \(jsonstring)") if self.requestmanager == nil { self.requestmanager = afhttprequestoperationmanager(); } self.requestmanager?.responseserializer = afjsonresponseserializer(); let requestserializer = afjsonrequestserializer() self.requestmanager?.requestserializer = requestserializer; self.requestmanager?.requestserializer.setvalue("application/json"...

Calling r.("quit()") from robjects closes the python process as well -

i'm using robjects execute r script python. when r finishes leaves behind many temporary files. can't modify r script don't see there reference tempfile() assume coming library r script using. tried deleting these files python @ end of script run locked process. assumed if there live r interpreter running, closing release these files. tried calling robject.r("quit()") killed python process well. ideas why? how can close r interpreter robjects? prefer not kill r interpreter using os.

equinox - OSGI Service components With same interface -

i need create service components same interface. mean have different implementations same interface. tried create 2 components same interface either 1 active. i using equinox declarative. have better design solve problem? please find configuration below. component1.xml <?xml version="1.0" encoding="utf-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="comp1"> <implementation class="com.demo.impl.componeimpl"/> <service> <provide interface="com.demo.icomponent"/> </service> </scr:component> component2.xml <?xml version="1.0" encoding="utf-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="comp2"> <implementation class="com.demo.impl.comptwoimpl"/> <service> <provide interface="com.demo.icomponent"/> ...

c# - Fetching data from database and populating a dropdownlist from a List<object> in MVC -

i have model: public partial class userrole { public int id { get; set; } public int userid { get; set; } public int roleid { get; set; } public int status { get; set; } public virtual user users { get; set; } public virtual role roles { get; set; } } public partial class user { public user() { roles = new list<selectlistitem>(); } public long id { get; set; } public string email { get; set; } public string password { get; set; } public system.datetime reg_date { get; set; } public byte validated { get; set; } public virtual icollection<userrole> userroles { get; set; } public int roleid { get; set; } public string rolename { get; set; } public ienumerable<selectlistitem> roles { get; set; } //public ienumerable<role> roles { get; set; } } public partial class role { public int id { get; set; } public string rolename { get; set; } public string desc { get;...

java - How to transform string with objects and array indexes into json -

i receive program map string representation of elements: map<string,string> properties = new hashmap<string,string>() {{ put("news[0].title", "title 1"); put("news[0].body", "body 1"); put("news[1].title", "title 2"); put("news[1].body", "body 2"); }}; i need render freemarker-template. in question freemarker-flat-structure-of-passing-parameters-transfer-to-array-of-objects we decided impossible parse kind of values in freemarker. freemarker can eval json. so need know how transform map objects or json. need that: { "news": [ {"title": "title1", "body": "body1"}, {"title": "title2", "body": "body2"} ] } names of parameters in map unknown, not "news", not "title" , "body", don't know. may there libraries...

javascript - Get a dropbox and textbox values inside table using jQuery -

i'm trying easy thing. values 1 table row onfocus event. have bad practice assignment, insert database without button click i've decided use onfocus event last cell in row. the problem i'm new jquery , javascript i'm having troubles getting dropbox , textbox selected , input values variables pass later code-behind using ajax. can me problem? to keep simple html 1 of rows, others same , table static: <table class="default-table" id="tbltest"> <tr> <td> <select name="client" class='client'> <option>choose client</option> <option>client 1</option> <option>client 2</option> </select> </td> <td> <select name="project" class='project'> <option>choose project</option> <op...

c# - what's the correct way to use locking in AppFabric -

i've got service updates appfabric cache 8000 objects every 4 hours. read table, creates object every record , stores in cache. while cache being updated 1 object @ time consumers can still request objects cache. there's not information available this, want know if following code correct way lock , store cache objects in appfabric while other threads can query cache: // caching part private static void cachedealers(dictionary<key<string>, dealer> dealers) { datacache cache = cache.instance.dealercache; foreach (key<string> key in dealers.keys) { cacheobject(cache, key.tostring(), dealers[key], mdealerregionname); } } private static void cacheobject(datacache cache, string key, object obj, string region) { datacachelockhandle lockhandle; if (cache.getandlock(key, timespan.fromseconds(10), out lockhandle) == null) { cache.put(key, obj, timespan.maxvalue, region); } else { cache.puta...

linux - C Socket program example - Error on binding: Already in use -

i have following example code using linux sockets: void serve_request(int newsockfd) { char buffer[256]; int n; /*if connection established start communicating*/ bzero(buffer, 256); n=read(newsockfd, buffer, 255); if(n<0) { perror("error reading socket"); } printf("here message: %s\n",buffer); /*write response client*/ n=write(newsockfd,"i got message", 18); if(n<0) { perror("error writing socket"); exit(1); } //close(newsockfd); } int main(int argc, char* argv) { int sockfd, newsockfd, portno, clilen; char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; /*first call socket function*/ sockfd=socket(af_inet, sock_stream, 0); setsockopt(sockfd, sol_socket, so_reuseaddr, 0, 0); if(sockfd<0) { perror("error opening socket"); exit(1); } /*initialize socket structu...

node.js - How to insert long value in mongo using node? -

i need insert long value attribute in mongo. var sequences = this.db.collection('sequences'); sequences.insert( { _id: "test_seq", value: 1 }, done); but inserting value integer, how make long? use mongodb long class. this. const long = require('mongodb').long; var sequences = this.db.collection('sequences'); sequences.insert( { _id: "test_seq", value: long.fromint(1) }, done); take here more details mongo-db has default types gives values, that's why it's inserted integer.

sql server - Not inserting more than 300 characters using MSSQL query with PHP, using Zend_db_adapter -

when try insert string containing more 300 characters shows blank page , not return php error. i using zf 1 - zend db adapter mssql server 2012. $db = zend_db_table::getdefaultadapter(); $insert = "insert tbloffer (legal_restrictions) values ('more 300 character string')"; $stmt = $db->prepare($insert); $stmt->execute(); my database column datatype nvarchar(max) in place of $insert = "insert tbloffer (legal_restrictions) values ('more 300 character string')"; $stmt = $db->prepare($insert); $stmt->execute(); try one $data = array('legal_restrictions'=> 'more 300 character string'); $db->insert('tbloffer',$data);

java - How to work with annotation based properties in Spring -

i use 'someotherproperty' value inside someifacedaoimpl but when debug, it's null, inside bean definition , inside bean constructor well. tried use @value annotation inside class not work either. however, database values works fine , available inside jdbctemplate bean. my properties file contains database.url=jdbc:mysql://localhost:3306/databasename database.username=root database.password=password someotherproperty=helloworld my configuration class: @configuration @profile("production") @componentscan(basepackages = { "com.packagename" }) @propertysource({"classpath:packagename.properties"}) public class contextconfig { @value("${database.url}") private string url; @value("${database.username}") private string username; @value("${database.password}") private string password; @value("${someotherproperty}") private string someotherproperty; @bean(name ...

c# - How to 'delay' observable sequence by one value? -

in reactive extensions, how can 'delay' observable sequence 1 value? example: original: 2 3 5 7 9 delayed: 2 3 5 7 to clear, want delay sequence 1 step. isn't same delaying constant time. try this: var delayedbyone = source.zip(source.skip(1), (x, _) => x); but may need avoid running 2 concurrent sources if have cold observable source: var delayedbyone = source.publish(s => s.zip(s.skip(1), (x, _) => x));

osx - Trying to install ruby 1.9.3 -

i have ruby 2.1.4 on machine, installed using rvm. need work on project using ruby 1.9.3, when try install using rvm following error on machine: warning, new version of rvm available '1.26.3', using older version '1.26.0'. can disable warning with: echo rvm_autoupdate_flag=0 >> ~/.rvmrc can enable auto-update with: echo rvm_autoupdate_flag=2 >> ~/.rvmrc ruby-1.9.3-p550 - #removing src/ruby-1.9.3-p550.. searching binary rubies, might take time. no binary rubies available for: osx/10.10/x86_64/ruby-1.9.3-p550. continuing compilation. please read 'rvm mount' more information on binary rubies. checking requirements osx. warning: can't open config file: /usr/local/etc/openssl/openssl.cnf certificates in '/usr/local/etc/openssl/cert.pem' date. requirements installation successful. installing ruby source to: /users/jean/.rvm/rubies/ruby-1.9.3-p550, may take while depending on cpu(s)... ruby-1.9.3-p550 - #downloading ruby-1.9.3-p55...

javascript - Split arrays from object and use in underscore template -

below response server using $.getjson. want able call each array separately can use underscore js template output data. how can split arrays out or call each array separately perform necessary loop show both kept , passed data? { kept: [ 0: { counter: "1", image: "image1.png", name: "alias" }, 1: { counter: "1", image: "image2.png", name: "lorem" } ], passed: [ 0: { counter: "1", image: "image3.png", name: ""dolores"" }, 1: { counter: "1" image: "image4.png" name: ""quisquam"" } ] } you can kept , passed in template because these object properties, this <script type="text/template" id="tp...

weblogic12c - Weblogic 12c setting PermSize when using NodeManager -

we have windows server 2012 64bit + weblogic 12c setup. adminserver requires higher permsize when being used 64bit os, need modify "setdomainenv.cmd" (as described in other questions here on stackoverflow). when starting adminserver through usual "startweblogic.cmd" script, uses settings in "setdomainenv.cmd" sets permsize etc. successfully, when using nodemanager "startserver()" command, not. i read in documentation fact 1 can control parameters loaded on startup of managed server (with nodemanager), did not find right way it. i hope can achieve consistent behaviour when starting managed server (and adminserver) through nodemanager or manually. any ideas? update: i checked what's going on when starting managed server and(!) in comparison what's going on when starting adminserver. result: adminserver process (it starts 'javaw.exe' instance in contrast 'java.exe' instance managed server) never get's pass...

amazon sns - How to set TTL attribute in SNS with publish method (PHP-SDK) -

i using aws-sdk-php sending notification,i have search through documentation couldn't find example. i have tried following code still not able set ttl notification(had tried data type number well): refer: http://docs.aws.amazon.com/sns/latest/dg/sns-ttl.html#sns-ttl-console $response = $client->publish(array( 'targetarn' => 'my arn', 'subject' => 'test notification', 'messageattributes'=>array( 'aws.sns.mobile.gcm.ttl' =>array( 'datatype' => 'string', 'stringvalue' => '10', ) ), 'message' =>json_encode(array( 'message'=>'new message !', )), )); a...

php - WordPress get post thumbnails in a custom pattern -

right have each post 2 sizes thumbnail: $big = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'thumbnail_600x200' ); $small = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'thumbnail_200x100' ); what trying achieve display posts using next pattern: post 1 - [big thumbail] post 2 - [small thumbail] post 3 - [small thumbail] post 4 - [big thumbail] post 5 - [small thumbail] post 6 - [small thumbail] actually posts shown big - small - small - big - small -small , on. any idea? thank you this post foreach: <?php foreach ($posts $post) { $big = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'thumbnail_600x200' ); $small = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'thumbnail_200x100' ); if ( $big ) { ?> <img src="<?php echo $big['0']; ?>" /> <?php }else{ ?> <img src=...

angularjs - How can I assign table column headers from a different array in ngGrid? -

my incoming json separated 'headers' , 'rows'. e.g.: { "headers": ["id","timestamp from","blah1","blah2"], "rows": [["69517737","1416932540011285849","104220.00","170968251000.000:a000"], ["69517738","1416932540012427614","119375.00","170968251001.000:a001"]] } i'm wondering how can apply headers columndefs when setting gridoptions... part of code looks this: $scope.tableheaders = res.headers; $scope.tabledata = res.rows; //then... $scope.gridoptions = { data: 'tabledata'//, columndefs: 'tableheaders' }; the rows load fine, if uncomment columndefs, doesn't work. tried directly adding $scope.tableheaders columndefs. idea if possible add columndefs basic array above, or have manipulate header data object first? example in documentation shows array objects....

Android Lollipop 5.0 Bluetooth Low Energy central role's bad performance -

since recent release of android 5.0 lollipop experiencing bad performance of bluetooth low energy api in nexus 4 device. previous os version (android 4.4.4 kit-kat) worked charm, , same app run on 5.0 has following behavior: frequently not detect advertising packet peripheral. the advertising_interval of peripheral 20ms, app should detect @ least 1 advertising in 60ms in worst case. have tried bluetoothlescanner (with scan_mode_low_latency settings) not use deprecated mbluetoothadapter.startlescan(mlescancallback) no success. when does, when try connect gatt server does. i have checked ble sniffer connection_request packet not sent peripheral. it seems i'm not 1 kind of errors , other users have posted similar questions . know has happened? -- update 1: (2014/12/17) have tested same app nexus 5 running lollipop , connects gatt server. every time send connection request, never because peripheral not receive packet. before upgrading nexus 5 lollipo...

python - PyBrain Deprecation Warning -

i getting deprecation warning whenever call splitwithproportion() function in pybrain. below warning: /usr/local/lib/python2.7/dist-packages/pybrain-0.3.1-py2.7.egg/pybrain/datasets/sequential.py:45: deprecationwarning: using non-integer number instead of integer result in error in future return self.getfield(field)[seq[index]:] does knows how solve this? reading, problem numpy library. running numpy 1.9. warning occurs when use pybrain sequential data set. thanks it turns out problem not lie pybrain @ all. using pybrain dataset fed confusion matrix frm scikit-learn. deprecation problem scikit learn confusion_matrix class. so, if using confusion matrix of 0.14 version of scikit-learn, may encounter error. upgraded version of scikit-learn 0.15 , problem vanishes.

Javascript inside LD JSON -

i'm wondering if it's possible execute javascript inside ld+json script. example "window.location.hostname" <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "website", "url": "http://" + window.location.hostname } </script> no, scripts of type "application/ld+json" won't executed. but, this: <script> var el = document.createelement('script'); el.type = 'application/ld+json'; el.text = json.stringify({ "@context": "http://schema.org", "@type": "website", "url": "http://" + window.location.hostname }); document.queryselector('body').appendchild(el); </script>

c - How do I check if the line is over? -

i ran problem today. can't find way check if line in file on , words read next 1 already. read word word file using fscanf, process word need , print out file there problem. for example data file is: hello, how doing? and result file shows: hello, how doing? but need words in same lines took them. please keep in mind need words 1 one, why don't use getline() here code of how read words file: while( fscanf(file, "%s", a) != eof ) { check(a, b, &a); // edit words , put them in b string // printed write file } thank tips! read line string getline() or fgets() , use sscanf words out of string.

asymptotic complexity - How can I implement a collection with O(1) indexing and mutability in Haskell? -

if i'm counting occurences of characters in string, implement using array in imperative language, such following: char values[256]; char c; while (c = readchar()) { values[c] += 1; } i can see how in haskell using data.vector.mutable , provides fast implementation of int-indexed mutable arrays. but how using haskell no additional packages and/or extensions? of in other words, how can implement fast o(1) collection indexing , mutability? the implementation of vector uses internal ghc functions called primops. can find them in package ghc-prim hard-wired ghc. provides, among others, following array functions: newarray# :: int# -> -> state# s -> (#state# s, mutablearray# s a#) readarray# :: mutablearray# s -> int# -> state# s -> (#state# s, a#) writearray# :: mutablearray# s -> int# -> -> state# s -> state# s these functions implemented ghc itself, lowlevel. primitive package provides nicer wrappers of these functions. arra...

html - Problema with ng-click function -

i trying make product configurator website. i'm using mean @ point have problem angularjs. i proceed explain program. in application have 3 buttons first step of configuration. when click one, angularjs send web next 3 buttons (the values of buttons depends on first 1 click). , here arrives problem, last buttons doesnt seems work. after clicking first button call function $scope.getoption2 , returns this: htmlsstring= '<div><button id="btns2-1" ng-click= getoption3(1)>1</button></div>'+ '<div><button id="btns2-2" ng-click= getoption3(2)>2</button></div>'+ '<div><button id="btns2-3" ng-click= getoption3(3)>3</button></div>'; and way print on screen: $scope.option2 = $sce.trustashtml(pruebahtml); but function $scope.getoption3 never called when click in 1 of buttons. i have simplified code, essenti...

java - Transaction Management in Hibernate with DAO Design Pattern -

i have many tables, every table,we have dao interface , daoimplementation class. example dao interface public interface cancelpolicydao { public cancelpolicy insertcancelpolicy(cancelpolicy cpdao)throws channeldispatcherexception; public cancelpolicy updatecancelpolicy(cancelpolicy cpdao)throws channeldispatcherexception; public void deletecancelpolicy(cancelpolicy cpdao)throws channeldispatcherexception; public cancelpolicy findbycancelpolicydata(integer id, integer offsetum, integer nights, float poram, byte ispercent)throws channeldispatcherexception; public cancelpolicy findbycancelpolicyid(integer id)throws channeldispatcherexception; } example daoimplementation class public class cancelpolicydaoimpl implements cancelpolicydao { @override public cancelpolicy insertcancelpolicy(cancelpolicy bean) throws channeldispatcherexception { session ses = null; try { ses = hibernateconnector.getinstance().getsession(); ses.save(bean); ses....

visual studio 2013 - Import a namespace for a whole project -

i replace functionalities in several classes of existing project. possible use keyword imports (or using in c#) globally project? meaning example specify "imports system.math" somewhere in project settings , expect namespace available in classes of project afterwards. if not possible, can somewhere set default imports automatically add "imports system.math" class create on?

php - warning division by zero woocommerce category -

i'm function, on single product page works fine. on category page keeps telling me: 'warning: division 0 in' . help! add_filter( 'woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2 ); function woocommerce_custom_sales_price( $price, $product ) { $percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 ); if ($percentage < 0) { return null;} else { if (is_product()) { return $price . sprintf( __('<br><span style="font-size:14px;font-weight:bold; color:#ef4136">-%s de desconto</span>', 'woocommerce' ), $percentage . '%' );} else { return $price . sprintf( __('<span style="font-size:14px;font-weight:bold; color:#ef4136">-%s de desconto</span>', 'woocommerce' ), $percentage . '%' );} } } function woocommerce_custom_sales_pric...

excel vba - Create list of all Main folders and indicate if they have subfolders with data. one main folder on each line -

i have searched forum while in search of vba script can scan parent folder-structure , make hyperlink each subfolder data. example of folder-structure : folder-template each folder. default no folders contain data (and there "- empty") once copy data folder, remove '- empty'. each folder contain 16 sub-folders. if sub-folder has no data, says 'empty' (numerical, "1.data - emtpy", "2. address - empty", "3. info" (no '-empty' has data..). i need list 1 main-folder pr line, , hyperlink sub-folders if contain data. found snip scans through folders , generate hyperlink each folder, hope in going 1 level deeper? sub listallfolders() dim objfso object dim objfolder object dim objsubfolder object dim integer dim folder string dim friendlyname string dim checkfolder string checkfolder = "notset" 'create instance of filesystemobject set objfso = createobject("scripting.filesystemobject") ...