Posts

Showing posts from July, 2013

c# - MigraDoc table border issue with left indent -

Image
i'm trying create pdf document using migradoc, , facing issues table borders when table contains left indent. i'm passing data following functions render table. public void addtable(int _inumberofcolumns, double leftind) { table = section.addtable(); if (leftind != 0d) { table.format.leftindent = leftind; } (int = 0; < _inumberofcolumns; i++) { column col = table.addcolumn(); } } in above method i'm passing double value parameter leftind . is, believe, cause of issue. and code add cells follows. i'm passing bool variables decide if cells border needs visible or not... (to add row i'm calling row = table.addrow(); ) public void addcolumn(int _icellnum, int icolspan, double dcellwidthinpt, system.drawing.color color, bool btopborder, bool bleftborder, bool bbottomborder, bool brightborder) { cell = row.cells[_icellnum]; if (icolspan > 0) { cell.mergeright = icolspan-1

c++ - overriding istream and ofstream -

im having trouble overriding << , >> operators file stream. struct reading { int hour; double temp; reading() : hour{ 0 }, temp{ 0 } {}; reading(int h, double t) : hour{ h }, temp{ t } {}; }; ifstream& operator<<(ifstream& ifs, const reading& reading) { return ifs << '(' << reading.hour << ',' << reading.temp << ')' << endl; } ofstream& operator>>(ofstream& ofs, reading& reading) { ofs >> reading.hour; ofs >> reading.temp; return ofs; } i don't have problem when try override iostream in same manner, file stream. indicated i'm doing wrong please? you seem have confused ifstream (short in -filestream) input , ofstream (short out -filestream) output.

java - ConcurrentModificationException is thrown when it should not -

any ideas on why lines = newremaininglines.size(); would throw exception? lines is int using store size of arraylist newremaininglines(); i realize not enough give definitive answer, perhaps explanation on helpful. don't see how code concurrently modifying int. int = 0; polines.clear(); itemlines.clear(); lines = newlines.size(); //polines should contain lines not relating items while(!newlines.get(i).equals(itemstart) && < lines){ polines.add(newlines.get(i)); i++; } list<string> newremaininglines = newlines.sublist(i + 1, lines); newlines.clear(); = 0; lines = newremaininglines.size(); //itemlines should contain lines relating items while(!newremaininglines.get(i).equals(poend) && < lines){ itemlines.add(newremaininglines.get(i)); i++; } list<string> finalremaininglines = newremaininglines.sublist(i + 1, lines); = 0; lines = finalrem

Swift self in static method -

i want use self in static method class type, i'm getting compile time error. here test code: protocol jsonmappable { static func map(json: anyobject!) -> self } class model : jsonmappable, mappable { required init?(_ map: map){ } func mapping(map: map) { } static func map(json: anyobject!) -> self { return mapper<self>().map(json) } } so in static method map want use self class type, tried self.type, i'm getting same error. don't want use class name, because need method use subclass class name when called on subclass . example if have: class subclass : model { } and call: subclass.map(json) i need have subclass in method instead of model . i'm wonder if possible do? protocol { static func f()->self } // class should conform protocol a, returned type should b final class b: { static func f() -> b { return b() } } let b = b() let c = b.f() i don't see

Best practices to define Xcode Preprocessor Macros for Multi Projects WorkSpace in iOS -

i have multiproject workspace in xcode. i setup preprocessor macros accessible projects according main project target. i have mainproject target1 , target2 i access preprocessor macros of target1 , target2 in other projects. how possible?

c# - HTML to PDF convertion issue -

i have 2 problems when converting html (mvc razor page) pdf non utf8 characters. 1) generating pdf chinese characters 2) whenever enable addition of css files exception " input string not in correct format." when comment own css , use getdefaultcss, error doesn't show , pdf being generated chinese characters appear question marks (?) here code: public static byte[] buildpdfcontent<t>(t model, string template, controllercontext context) { corecontroller controller = (corecontroller)context.controller; var html = controller.renderrazorviewtostring(template, model); memorystream msinput = new memorystream(asciiencoding.default.getbytes(html)); memorystream msoutput = new memorystream(); string fontawesomecss = httpcontext.current.server.mappath("/content/css/font-awesome.min.css"); string bootstrapcss = httpcontext.current.server.mappath("/content/css/bootstrap.css"); string sitecss = httpcontext.current.serve

php - Eloquent relation pivot table with table -

i read laravel documentation couldn't understand well. have structure on database. pricetable - contains info peiod of promotional prices , default price. product - wich contains info products. and pricetable_product - wich contais foreign keys of product , pricetable , respective price. example: pricetable | pricetable_product | product id | description | pricetable_id | product_id | price | product_id| name 1 | default | 1 | 1 | 5.00 | 1 | test 2 | promotional | 2 | 1 | 3.50 | and @ order table can have multiples products, want know if possible relation order table, pivot table pricetable_product, because need information of table belongs price when product sold. thanks. first of may define relations between product , pricetable. product model (app\product.php) <?php namespace app; class product extends model { protected $table = 'products';

php - Dynamically created directory returns "Array" 1 in 1000 times -

i'm fixing old code supposed create directory customer based on customer's last name. 999 out of 1000 times works expected every , "unable create base directory" error message , debug shows me $file_directory in case "array" instead of "\\network\path\order_data\1234567890_smith" . could explain how code work vast majority of time still consistently fail .1% of instances? or other code? thanks! note: did not write code tring leave close original possible edit had typo in previous code think tliokos , fluinc had point wanted fix mistake code: <?php $file_directory = build_directory($customer, $uid); if(!is_dir($file_directory)){ //check make sure not exist if(!mkdir($file_directory)){ mail("debug@example.com","unable create base directory","$file_directory"); } } function build_directory($customer, $uid){ if($customer->related_orders){ $rel

c - Pointer to pointer doesn't work in tree copying algorithm -

i'm trying write tree copy function in c: void tree_copy(treenode *source, treenode **dest) { treenode *newtree; //the new tree created using root treenode **bkup = &newtree; //pointer pointer, keep backup of head of newtree /* code create new tree traverses using *newtree , leaves *newtree pointing @ last node created *bkup still contains address of head node, right? */ *dest = *bkup; //assign new tree created parameter } //i'm trying invoke this: int main(void) { treenode *t1, *t2; create_tree(&t1); //tested, written function create tree. no bugs. tree_copy(t1, &t2); preorder(t2); //tested, written function preorder traversal. } the node supposed contain newly created tree's root (t2) still remains null after operation. why happening? wrong in logic in backing starting node of new tree? any appreciated. treenode *newtree; treenode **bkup = &newtree; bkup

android - Missing POM in upload gradle maven flavours -

i'm designing aar library android , facing issue. since introduce flavors, pom files no longer uploaded. aar files still correctly uploaded without pom, library can't used. here part of build.gradle file : uploadarchives { repositories.mavendeployer { snapshotrepository(url: nexus_mavensnapshot) { authentication(username: nexus_username , password: nexus_password) } addfilter('legacyrelease') { artifact, file -> artifact.attributes.classifier.equals("legacyrelease") } addfilter('nbrelease') { artifact, file -> artifact.attributes.classifier.equals("nbrelease") } pom('nbrelease').artifactid = project.archivesbasename + "-nb"; pom('legacyrelease').artifactid = project.archivesbasename + "-legacy"; } } the article found pertinent : https://discuss.gradle.org/t/how-c

ruby on rails - Return all hashes based on user id as key -

i got array hashes. inside hashes has unique user id. need return of user's likes: p = post.first all_likes = p.likes # returns: [0][1][2] etc # inside hash looks like: [0] #<like:0x007f81d3dfb310> { id: => 4, user_id: => 1, like_sent: => 1 # 1 } let's assume all_likes has many users , need user_id: 1 's total like_sent . how that? all_likes.find {|f| f["user_id"] = current_user.id } # returns 1 hash. need return if more found. so if "jason" likes post 10 times, need grab total likes. how return matching hashes . that's perfect question. try all_likes.where 'user_id = ?', current_user.id and find method has different syntax, this: all_likes.find :all, :conditions => ['user_id = ?', current_user.id] look docs

android - Music player controlled from ADB -

i writing automation scripts android device, communicate device on adb. know if there music player can play mp3 , controlled via adb. i need following controls - start mp3 playback stop mp3 playback toggle repeat mode is possible achieve same via google music player in android m? in android m, can play mp3 using following command - am start -a android.intent.action.view -d <filename> -n com.google.android.music/.audiopreview -f 1 it starts playback correctly, not able stop or play in loop. have tried following stop music: adb shell input keyevent 127

ember.js - How to use ES2015 Template strings in an Ember helper -

ember > 2.0 + ember suave telling me: "requiretemplatestringsforconcatenation: using manual concatenation strings not allowed @ helpers/svg-icon.js" import ember 'ember'; export function svgicon(iconname) { return ember.string.htmlsafe("<svg class='icon-x'><use xlink:href='#icon-" + iconname + "'></use></svg>"); } export default ember.helper.helper(svgicon); i've come meetup ember.string.fmt discussed , sounded promising ~ has been deprecated , suggests use es2015 template strings. reading here: http://babeljs.io/docs/learn-es2015/ i unclear how 'manual' concatenation works - problem - , well, whole thing. return ember.string.htmlsafe("<svg class='icon-x'><use xlink:href='#icon-${iconname}'></use></svg>"); ? implementation , reasoning happily accepted.

Firebase - splitting tables between secure and insecure fields -

is there best practice structuring firebase tables/objects between secure data fields (which users not trusted update themselves) , insecure data, may set themselves? for example, user should free change name or preferences inside own users object, should not free change settings such if they're paid user, email confirmed, etc. or user specific example, user.name should editable user directly, while user.email should changed via our own api, update firebase's record. this seems must common requirement, because see in every table need. e.g. have users , have projects , have tasks within project, etc. , each of data types, there fields user-editable , ones not. so type of approach best practice? here 2 possibilities: secure_data: users: user1: email: user2: projects: tasks: insecure_data: users: user1: name: user2: projects: tasks: or: users: user1: secure: email: insecure: name: projects: projec

sonarqube - Sonar throws "fail to execute es search request" -

we upgraded our sonar instance 5.0.1 5.1.2 we getting "fail execute es search request" error popup when click issues link. error-snapshot 2015.10.27 12:23:35 error web[o.s.s.w.webserviceengine] fail process request http://sonar.pe.int.thomsonreuters.com/api/issues/search?p=1&ps=50&s=file_line&asc=true&extra_fields=actions%2ctransitions%2cassigneename%2creportername%2cactionplanname&facets=severities%2cresolutions%2cresolutions&resolved=false&componentuuids=8858dbaa-94ca-4293-9a81-e432028be3e0 java.lang.illegalstateexception: fail execute es search request '{"from":0,"size":50,"query":{"filtered":{"query":{"match_all":{}},"filter":{"bool":{"must":[{"missing":{"field":"resolution"}},{"terms":{"project":["8858dbaa-94ca-4293-9a81-e432028be3e0"]}},{"has_parent":{"query":

Autofac: cannot resolve dependency using factory after ContainerBuilder.Update() -

my problem want use func<> factory resolve dependency. , in if use containerbuilder update() (i need mocking services in integration tests), factories still resolve outdated instances. i created simple scenario reproduce problem: class program { static void main(string[] args) { var containerbuilder = new containerbuilder(); containerbuilder.registertype<test>().as<itest>(); containerbuilder.registertype<test1factory>().as<itestfactory>(); containerbuilder.registertype<testconsumer>().asself(); var container = containerbuilder.build(); var tc1 = container.resolve<testconsumer>(); var cbupdater = new containerbuilder(); cbupdater.registertype<test2>().as<itest>(); cbupdater.registertype<test2factory>().as<itestfactory>(); cbupdater.update(container); var tc2 = container.resolve<testconsumer>(); conso

regex - Regular expression to fetch lines evaluating only one part of a string, java -

i'm trying find regular expression match part of pattern for example text : goodclass.nicemethod badclass.nicemethod badclass2.nicemethod verybadclass.nicemethod goodclass.nicemethod badclass.nicemethod badclass2.nicemethod goodclass.nicemethod how can lines 'nicemethod' not follow 'goodclass' you can use negative lookbehind : string regex = "(?<!goodclass\\.)\\bnicemethod\\b";

linux - How to install rgdal and rgeos package in R on university high performance computing system? -

i have been installing r packages tar.gz type files on edinburgh university's compute , data facility high performance computing cluster accessed via ssh. once logged in, can install files example below: install.packages("/exports/work/eng_antonyhydrodata/pkges/deoptim_2.2-3.tar.gz",rpeo=null,target="source") there approximately 40 packages , 38 of them install no problem, 2 fail: rgeos (rgeos_0.3-14.tar.gz) , rgdal (rgdal_1.0-7.tar.gz). the reason failure given below: installing package '/exports/work/eng_antonyhydrodata/library' (as 'lib' unspecified) inferring 'repos = null' 'pkgs' * installing *source* package 'rgdal' ... ** package 'rgdal' unpacked , md5 sums checked configure: cc: gcc -std=gnu99 configure: cxx: g++ configure: rgdal: 1.0-5 checking /usr/bin/svnversion... yes configure: svn revision: 559 checking gdal-config... no no configure: error: gdal-config not found or not executable. error:

java - Loss of precision when converting big double to long -

i'm trying convert bigdouble long (as written in title). class ideone { public static void main (string[] args) throws java.lang.exception { double test = math.pow(math.sqrt(5)+1,100); system.out.println("double value : " + test); system.out.println("long value : " + (long)test); system.out.println("biginteger value : " + bigdecimal.valueof(test).tobiginteger()); } } the double value : 1.0040690755570702e51 the long value : 9223372036854775807 and biginteger value : 1004069075557070200000000000000000000000000000000000 isn't there way can cast double value long without loosing precision? (i know decimals truncated, don't care decimal's precision). you can perform math purely bigdecimal . note square root of 5 irrational , can approximated math.sqrt . bigdecimal bd = new bigdecimal(math.sqrt(5)); bd = bd.add(bigdecimal.one); bd = bd.pow(100); system.out.println(bd);

ios - fatal error: unexpectedly found nil while unwrapping an Optional value (lldb) -

i using avfoundation in swift2 scan barcodes, code below. now, every randomly error : fatal error: unexpectedly found nil while unwrapping optional value. code: // // placingorder.swift // sfc version2 // // created studiolaptop1 on 28/09/2015. // copyright (c) 2015 librex. rights reserved. // import uikit import avfoundation //making view controller implement delegate: avcapturemetadataoutputdelegate. class placingorder: uiviewcontroller, avcapturemetadataoutputobjectsdelegate { @iboutlet weak var thenav: uinavigationbar! @iboutlet weak var stopbutton: uibutton! //defining needed variables , constants let mysession : avcapturesession = avcapturesession() var thepreview : avcapturevideopreviewlayer! var hlview : uiview = uiview() //store string value of barcode var detectionstring : string! @ibaction func stoptapped(sender: uibutton) { self.mysession.stoprunning(); self

file - How does PHP scandir work? -

i need scan directory /home/user/www/site/public_html/application (full path root). scandir perform 'application' part of full path argument , that's going ok, got list of files , directories result. interesting how scandir work path 'application' ? ain't argument should full path root ? did not found explanation behavior on official php.net, unfortunately. idea, how works? thanks. p.s. document_root set /home/user/www/site/public_html for relative paths bases them on script's current working directory, can find getcwd .

javascript - CCID slot status byte -

reading ccid specifications, wondering intrinsic structure of slot status ( bstatus byte), set in header of response ( inbound bulk transfer ) message. only first 2 , last 2 bits used bmiccstatus , bmcommandstatus , i'm not sure how. given (javascript) binary notation 0bxx0000yy , true bmcommandstatus represented xx ? given (javascript) binary notation 0bxx0000yy : xx .. bmcommandstatus (mask 0xc0 ) yy .. bmiccstatus (mask 0x03 ) reference here (i did check ccid rev 1.1, unable find bit order here -- i.e. msb first or lsb first). you might find using wireshark extremely useful supports usb sniffing ccid support .

flash - Google analytics - trafic from adobe.com -

we have flash application https://designer.genomecompiler.com/app getting lot of traffic adobe.com/apollo . not make sense, seems huge percentage of our users coming url. our guess has fact application runs flash player don't have clue on why. ideas on why getting traffic there? thanks adobe apollo old name adobe air. referrer issue not uncommon , appears quite old (references on google since 2009). e.g https://forums.adobe.com/thread/429383?tstart=0 probably worth making sure air application uses latest sdk ensure been resolved.

while statment is stuck on an infinite loop in python -

task = "" while task != "e" or task != "d": task = raw_input("would encrypt or decrypt\r\n:- ").lower() keyword = raw_input("enter keyword:-").lower() keyphrase = raw_input("enter key phrase:-").lower() does know why when code runs, while statment looped on , on when correct input has been entered. think parameters in while statment im not sure. i have tried while statment 1 condition , works, don't see why not working multiple your or statement evaluates true . if task == 'e' , task != 'd' , , while loop evaluates true , making loop continue indefinitely. change like: task = " " while task not in "ed": # stuff

scala - Using Custom Hadoop input format for processing binary file in Spark -

i have developed hadoop based solution process binary file. uses classic hadoop mr technique. binary file 10gb , divided 73 hdfs blocks, , business logic written map process operates on each of these 73 blocks. have developed custominputformat , customrecordreader in hadoop returns key (intwritable) , value (byteswritable) map function. value nothing contents of hdfs block(bianry data). business logic knows how read data. now, port code in spark. starter in spark , run simple examples (wordcount, pi example) in spark. however, not straightforward example process binaryfiles in spark. see there 2 solutions use case. in first, avoid using custom input format , record reader. find method (approach) in spark creates rdd hdfs blocks, use map method feeds hdfs block content business logic. if not possible, re-use custom input format , custom reader using methods such hadoopapi, hadooprdd etc. problem:- not know whether first approach possible or not. if possible, can please provide po

cqrs - Domain logic in command handler or event handler? -

i using cqrs , ddd build application. i have account entity, transaction entity , transactionline entity. transaction contains multiple transactionlines. each transactionline has amount , points account. if user adds transactionline in transaction has transactionline points same account 1 new transactionline, want add new transactionline amount existing one, preventing transaction having 2 transactionlines point same account. ex : before command : transaction transactionline1(amount=100, account=2) transactionline2(amount=50, account=1) command : addnewtransaction(amount=25, account=1) desired result : transaction transactionline1(amount=100, account=2) transactionline2(amount=75, account=1) // add amount (50+25) instead of 2 different transactionlines instead of transaction transactionline1(amount=100, account=2) transactionline2(amount=50, account=1) transactionline3(amount=25, account=1) // error, 2 different tr

sql server - Dynamically select a version of WHERE clause in SQL SELECT statement? -

basically, want select 1 of 2 versions of clause in sql select statement, without having duplicate 2 versions of whole select statement. for example, specify variable @topclients, , execute following clause when @topclients = 'true': where cast(event_dtm date) between @start , @end , client in ('client1','client2', 'client3') or execute following clause when @topclients = 'false': where cast(event_dtm date) between @start , @end how can this? just use: where cast(event_dtm date) between @start , @end , ( client in ('client1','client2', 'client3') or @topclients = 'false' )

playframework - Play scala integration spec - Injecting dependencies through Guice -

i use scala, play 2.4, , slick 3 in project. have following dao code , works fine end end. @singleton() class companiesdao @inject() (protected val dbconfigprovider: databaseconfigprovider) extends companiescomponent hasdatabaseconfigprovider[jdbcprofile] { import driver.api._ } however, can't working expected in integration test because of dbconfig stuff. integration test below: class companiesdaointegrationspec extends funspec oneserverpersuite { def companiesdao(implicit app: application) = { val app2companiesdao = application.instancecache[companiesdao] app2companiesdao(app) } describe("create") { it("should create ") { companiesdao.create... } } } if don't put db properties in application.conf got following error: [info] java.lang.runtimeexception: com.google.inject.provisionexception: unable provision, see following errors: [info] [info] 1) no implementation play.api.db.slick.

xcode - Swift ios set a new root view controller -

Image
i wonder if possible set new root vc? my app gets init uinavigation controller has table view root vc. then table view running segue login window (present modally) if login end in red vc/account page. want set red vc new root vc of app, , remove underlying vc's. can show menu button/icon instead of "back" button i have found dont understand how use it: let storyboard: uistoryboard = uistoryboard(name: "main", bundle: nsbundle.mainbundle()) let yourviewcontroller: viewcontroller = storyboard.instantiateviewcontrollerwithidentifier("respectiveidentifier") as! viewcontroller let navigationcontroller = self.window?.rootviewcontroller as! uinavigationcontroller navigationcontroller.setviewcontrollers([yourviewcontroller], animated: true) but cannot work. possible make red vc in picture act new root vc. may should try this let mainstoryboard = uistoryboard(name: "main", bundle: nil) let redview

java - JavaFX 8 screen rendering freezes when running with hw acceleration enabled -

one of our javafx 8 freezes quite when running on microsoft surface 3, every , when running on different tablet running windows 8 , once in blue moon when running on normal desktop. if run prism.order=sw , doesn't freeze performance on tablets little bit slow usable. when screen freezes, 1 can still click on screen , events , javafx thread appear working usual seems prism / quantum rendering or whatever converts scenegraph pixels crashed. i've reported bug in old jira , new jbs , apparently need produce reproducible test case don't have time prepare. any ideas why can happening? has had happening well? hints how root of problem?

<a href> not working, after adding some jquery javascript based image sliders -

my web-design working perfectly, added trendy image slider within other template, , links have stopped responding. think because of order of calling jquery scripts etc, im not sure how should order them fix issue. i tried many solutions available on internet, , worked out. reason links stopped working because of positioning of jquery scripts overlapped whole page. so used z-index:100 in page, , enabled them. working fine. body a{ z-index:100; }

asp.net mvc - Foreach not updating HTML list elements -

using knockout 2.2.0 i'm trying use same dialog add , edit. have code working, when replace observable new edited one, doesn't cause update in foreach (or @ least continues display old values) update actual model, can see in dev tools. tried force update .valuehasmutated(), no luck. self.editreference = function () { self.isedit(true); self.open(); self.dialogreferences(this); }; self.saveeditreference = function () { self.references.replace(this, self.dialogreferences); self.references.valuehasmutated(); self.dialogreferences(newreferences()); self.close(); }; and here of partial view references section of html code: <ul class="sortable references-summary" data-bind="foreach: references"> <li class="ui-state-default"><b>name: </b><!-- ko text:name --><!-- /ko--><br /><b>company: </b><!-- ko text:company --

syntax - Swift Not Equals, Forced Unwrap, and Whitespace -

i've been enjoying swift while now, found 1 syntax incredibly problematic. start assumption that: let foo : string = "" this simple check: if foo!="value" { but alas, won't compile. compiler complains trying unwrap value not optional. change line to: if foo != "value { the compiler happy , code behaves expected. case of significant whitespace, , i'm not content it. suspect there situations may compile , behave contrary intention. there alternative syntax should using avoid type of error? the alternate syntax put spaces around infix operators. required. without spaces, treated prefix or postfix operator. spaces infix operator. swift consistent this. know realize what's happening; don't believe there's way around it, , cure worse disease (i can't come examples lead real-world bugs). swift forgiving if there no conflict, , allow 1+1 instance, shouldn't this, either. believe swift style put spaces in. ye

python - circular motion and angle -

i'm trying make program(ai) determine circular action of vehicle. have data of current vehicle's speed , heading. after user provide desire angle , radius, vehicle start tile turn , circular drive. in step how can calculate radius of formed circle? wnat compare given , created radius. it's bit hard give answer unless show code (such how user data inputed, how vehicle moves, , data formatting of current speed , heading). here suggestion, if have heading and position, can find radius computing distance between 2 points whos' heading opposite of each other. next, take distance , cut in half (thus giving radius). assuming have position coordinate work with. if don't have position value (or can't one), problem becomes harder solve , require calculus. if case, question better suited mathematics stack exchange ; @ least until provide code with.

c# - Display Value for related_records field -

in dmn_demand [demand management] table, display value realted_records field. for example, for assigned_to field, display value name . similarly, want display value realted_records field. the display value determined table field references (assuming it's reference field). so example, if go field assigned_to field references (probably sys_user) , @ table dictionary (right click -> configure -> table), you'll see list of fields, , on 1 of them, "display=true" should true. here's more information . note can have 1 "display" field on given table.

how to query not null values in google app engine admin console -

how query not null values in google app engine admin console using gql syntax? consider having table property firstname. need values first name not null. how do that? whats query? you don't need special query : from docs : datastore queries refer property never return entities don't have value property. so if use firstname in gql, return entities have firstname.

c# - Why does the supposedly-saved file not really get saved? -

the following code taken this tutorial create , save excel file c#: using excel = microsoft.office.interop.excel; namespace windowsformsappexceltest { public partial class form1 : form { public form1() { initializecomponent(); } private void buttoncreateexcelfile_click(object sender, eventargs e) { excel.application xlapp; excel.workbook xlworkbook; excel.worksheet xlworksheet; object misvalue = system.reflection.missing.value; xlapp = new excel.application(); xlworkbook = xlapp.workbooks.add(misvalue); xlworksheet = (excel.worksheet)xlworkbook.worksheets.get_item(1); xlworksheet.cells[1, 1] = "http://csharp.net-informations.com"; xlworkbook.saveas("csharp-excel.xls", excel.xlfileformat.xlworkbooknormal, misvalue, misvalue, misvalue, misvalue, excel.xlsaveasacc

json - log a stock/share price variable to database useing php -

i have api retrieves stock price data through php script. have tried several different ways add price database no luck. please driving me crazy, have tried logging float different syntax still doesn't display, please kind enough give me example using code below new php/mysqli , programing in general. thanks. please note use import.io create api , have removed api key. this how api works: <?php $url = 'http://my api url.com'; $json =file_get_contents($url); $retval =json_decode($json, true); $output = "<ul>"; foreach($retval['results'] $results) { $output .="<p>".$results['price/_source']."</p>"; } $output .="</url>"; echo $output; // show price so: 1.139791 ?> ' //this json file. { "offset": 0, "results": [ { "price": "1.140 293" } `]`, "cookies": [ ], "connectorversi

javascript - Uneven Responsive Image/Text Grid with Overlay -

Image
i've been trying create below layout no avail. kind enough me out in either creating minimal working example or linking somewhere able me out this? what need grid row heights same. each row containing 2 images , 1 text column (the text column being placed in different locations in each row). text column needs same height images , i'd text vertically centered width of needs smaller (half size). images, i'd have white overlay on hover or touch(mobile) header , couple lines links , 1 link have video popup (a la fancybox). i'd responsive , adapt screen sizes. on mobile i'm fine each box being 100% width it's tablet sizes think i'm having issues laying thing out properly. hover state need become touch state on these platforms. i'd supply code if need think i'd start scratch since feel i've created huge mess. i feel should simple yet i'm having way many problems , can't seem find websites showcase examples of i'm trying create..

c++ - Is it good practice to hide Initialization code "before main"? -

i building c++ library , need initialize opengl context program ( , other default resource objects ). practice ( considering modern c++ semantics ) "hide init. code" in code chunk being called before main ? cannot use static variables because need initialize things in specific order ! (i cannot init texture before openglm or sdl !) here code : #include <stdio.h> #ifdef _msc_ver // msvc / msvc++ 2015 #define ccall __cdecl #pragma section(".crt$xcu",read) #define initializer(f) \ static void __cdecl f(void); \ __declspec(allocate(".crt$xcu")) void (__cdecl*f##_)(void) = f; \ static void __cdecl f(void) #elif defined(__gnuc__) gcc / g++ #define ccall #define initializer(f) \ static void f(void) __attribute__((constructor)); \ static void f(void) #endif static void ccall finalize(void) { /* king of delete / dispose here : sdl_quit, ... */ } initializer(initialize) { /* here startup code ... */ } the standa

javascript - jQuery: change the value of input range continuously with mousedown event -

i trying change value of input range continuously until mousedown on button code tried html <input type="range" id="points" value="50" min="10" max="100" step="1" /> <input type="button" id="plus" value="+" /> <input type="button" id="minus" value="-" /> jquery $('#plus').on('mousedown', function() { oldvalue = parseint($('#points').val()); $('#points').val(oldvalue + 5).change(); console.log($('#points').val()); }); $('#minus').on('mousedown', function() { oldvalue = parseint($('#points').val()); $('#points').val(oldvalue - 5).change(); console.log($('#points').val()); }); jsfiddle code value of input range changed once, requirement keep changing value untill mousedown thanks in advance help your problem event triggered once.

c++ - operator new doesn't return 0 when running out of memory -

i found interesting exercise in bruce eckel's thinking in c++, 2nd ed., vol.1 in chapter 13: /*13. modify nomemory.cpp contains array of int , allocates memory instead of throwing bad_alloc. in main( ), set while loop 1 in newhandler.cpp run out of memory , see happens if operator new not test see if memory allocated. add check operator new , throw bad_alloc*/ #include <iostream> #include <cstdlib> #include <new> // bad_alloc definition using namespace std; int count = 0; class nomemory { int array[100000]; public: void* operator new(size_t sz) throw(bad_alloc) { void* p = ::new char[sz]; if(!p) { throw bad_alloc(); // "out of memory" } return p; } }; int main() { try { while(1) { count++; new nomemory(); } } catch(bad_alloc) { cout << "memory exhausted after " << count << " allocations!" << endl; cout << "out of memo