Posts

Showing posts from April, 2010

Xtext: Create an EMF Resource on the fly -

Xtext: Create an EMF Resource on the fly - for reasons, need create non-persistent emf resource within scoping. hold of resourceset language uses. need not in ui project main project. i tried in scopeprovider class with @inject resourceset @inject provider<resourceset> @inject iresourcefactory however, none of these ever injected (stay null) although in defaultruntimemodule, there indeed bindings @ to the lowest degree resourceset , iresourcefactory. utilize xtext 2.5.1. i take other ways create emf resource on fly regards, clericc you can try @inject provider<xtextresourceset> resourcesetprovider; also don't forget execute <yourlanguage>standalonesetup.dosetup() in non-ui app initialize emf registries , create classes injected properly. xtext emf

c++ - math functions in thread returning wrong values, with android ndk -

c++ - math functions in thread returning wrong values, with android ndk - i having issue while trying port code android ndk, doing fine on ios. code renders 3d models , uses opengl es 1.1 that, performs many calculations using standard c math library (including math.h). here snippet of code used test anomaly: double e; e = sqrt(25); assert(e == 5); e = sqrt(16); assert(e == 4); e = sqrt(9); assert(e == 3); e = sqrt(4); assert(e == 2); e = sqrt(1); assert(e == 1); e = sqrt(0); assert(e == 0); these asserts work fust fine anywhere, while this: int vec[10] = {0, 1, 4, 9, 16, 25, 36, 49, 64, 81}; int res[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; double d; (int i=0; i<10; i++) { d = sqrt(vec[i]); assert(d == res[i]); } crashes on thread other main one. example, returns me 0.37500000008731149 sqrt(0), why first assert on loop fails. it seems problem lies on calculations using content of variables, not calculations on hardcoded values. may problem memory mapping on

javascript - HTML5 drag and drop element over div with Hammer.js drag events -

javascript - HTML5 drag and drop element over div with Hammer.js drag events - tl;dr i want utilize html5 drag , drop of element container drag hammer.js events. however, there conflicts. detailed description: as presented in attached figure, have 2 containers: left: container draggable elements right: container hammer.js events, namely drag, dragstart , dragend. i want drag , drop elements left container right one. however, while dragging, when entering on right container, hammer.js dragstart event activated. after dropping element, apply drag event on right container. however, hammer.js drag event activated , considers deltax , deltay previous dragstart event. hammer.js beingness used preventdefault: true: hammer(this.container, {preventdefault: true}).on('dragstart', function (event) { ... } i have used event.preventdefault() , event.stoppropagation() on dragstart of draggable element, without success. i have partially solved problem. in dragsta

xcode - UiTableCell UIImageView - last cell not displaying image -

xcode - UiTableCell UIImageView - last cell not displaying image - i have using storyboards , have view uitableview custom uitable cell. the cell has uiswitch, uilabel , uiimageview. there 3 rows in table , displays should apart the uiimageview in lastly row. the info there uiswitch , uilabel set correctly. image exists , valid same image used in first row displays correctly. code cellforrowatindexpath below - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { nslog(@"in settingsviewcontroller cellforrowatindexpath\n"); shared_prefs = [sharedprefs sharedinstance]; message *mymessage = [shared_prefs.messages objectatindex:indexpath.row]; static nsstring *cellidentifier = @"mytablecellid"; mytablecell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; // configure cell... if (cell == nil) { cell = [[mytablecell alloc] initwithstyle:uitable

angularjs - Patterns for handling missed push events? E.g. chat messages sent while offline or in sleep mode -

angularjs - Patterns for handling missed push events? E.g. chat messages sent while offline or in sleep mode - i'm writing app uses websockets via pusher. ruby on rails + angularjs app should apply stack, really. i realized app doesn't handle missed force events, , i'm interested hear established patterns are. my app isn't chat, let's pretend is. when page loads, gets lastly 100 chat messages db , shows them. whenever new chat message comes in, server pushes new message clients via pusher/websockets. but! if client offline or in sleep mode when force comes in, can miss messages. what's pattern handling that? i have vague ideas around detecting client "waking up" , either forcing total page reload or requesting events since timestamp or since event, i'm not sure way of determining "waking up" without adding polling mix. maybe using pusher's client presence or connection states features, detecting when user (re-)c

scala - Inner map function in Spark -

scala - Inner map function in Spark - i have 2 rdds : rdd1[string, double] sample info : ("a" , 1.0) ("b" , 2.0) ("c" , 3.0) ("d" , 4.0) this corresponds key value pair. rdd2[string , (string , string) sample info : ("a" , ("b" , "c")) ("b" , ("a" , "b")) ("c" , ("a" , "d")) ("d" , ("a" , "b")) rdd1 contains values required rdd2 so want able access values rdd2 in rdd1 such : ("a" , ("b" , "c")) map ("a" , (2.0 , 3.0)) 2.0 & 3.0 corresponding values in rdd1 how can accomplish scala spark ? possible solutions convert rdd1 hashmap , "get" values within map operation of rdd2 : rdd2.map(m => rdd1hashmap.get(m._2._1)) is there alternative method accomplish ? if rdd1 little should have in hash map utilize broadcast va

asp.net mvc 4 - MVC 4 ASP .NET Oracle 10g EntityFramework -

asp.net mvc 4 - MVC 4 ASP .NET Oracle 10g EntityFramework - i have oracle 10g database on production, , need deploy new mvc 4 web application. want utilize entityframework database first approach, can't figure out how it. i have read lot, , people can create oracle 10g work entity framework 5, can't it. in dataproviders oracle database not listed, in connections explorer. i appreciate help. thanks! i solved it, , i'll write solution downwards here future reference. i'm using visual studio ultimate 2013 . clean odac previous installations , installed latest 1 odac 12c release 2 , oracle developer tools visual studio (12.1.0.1.2) . , working entity framework 5 . i hope helps someone. asp.net-mvc-4 oracle10g entity-framework-5 ef-database-first

make - /usr/bin/ld: cannot find -lstdc++ -

make - /usr/bin/ld: cannot find -lstdc++ - hi i'm trying compile create code in debian wheezy armhf isn't working gives me error i found lstdc++.so looks direct acces , not original file /usr/bin/ld: cannot find -lstdc++ collect2: error: ld returned 1 exit status #include <gst/gst.h> #include <gst/rtsp-server/rtsp-server.h> int main (int argc, char *argv[]) { gmainloop *loop; gstrtspserver *server; gstrtspmediamapping *mapping; gstrtspmediafactory *factory; gst_init (&argc, &argv); loop = g_main_loop_new (null, false); server = gst_rtsp_server_new (); mapping = gst_rtsp_server_get_media_mapping (server); mill = gst_rtsp_media_factory_new (); gst_rtsp_media_factory_set_launch (factory, "( mfw_v4lsrc capture-mode=0 is-live=1 ! vpuenc codec=0 ! rtpmp4vpay send-config=true name=pay0 pt=96 )"); gst_rtsp_media_factory_set_shared (factory, true); gst_rtsp_media_mapping_add_factory (mapping, "/test&qu

c# - xUnit and Watin cleanup -

c# - xUnit and Watin cleanup - i have test cases using xunit , watin. create facts in class share same instance of ie, had created singleton class first test launch new ie instance, , next tests utilize same instance. after facts finish, ie instance still running. wonder how close ie after tests in class finish. for purpose class tests need implement iuserfixture interface. i'll provide illustration solves needs , demonstrates xunit life-cycle model: public class mytestclass : iusefixture<watinfixture>, idisposable { private watinfixture _data; public void setfixture(watinfixture data) { _data = data; console.writeline("setting info test"); } public mytestclass() { console.writeline("in constructor of mytestclass"); } [fact] public void fact1() { console.writeline("in fact1. ie '{0}'", _data.referencetoie); // utilize _data.referen

r - Unable to deploy shiny app on shiny server -

r - Unable to deploy shiny app on shiny server - i running shiny illustration in https://github.com/rstudio/shinyapps/blob/master/guide/guide.md . it works fine on computer, when seek deploy on shiny server using rstudio, r console says: application deployed http://epidemiologia-asppalermo.shinyapps.io/shinyprova" on browser get: "error: object 'dataset' not found". in working directory there next objects: diamonds (dataframe) dataset (dataframe, same diamonds) server.r ui.r . i utilize r 3.1.0, rstudio 0.98.932 , windows 7, 32 bit, r packages updated. anyone can tell me wrong? i cant see original deployment perhaps you've declared diamonds server.r ui.r beingness asked work diamonds, instead of beingness fed server.r? r shiny shiny-server

writing data from sqlite database android -

writing data from sqlite database android - i want read info sqlite database in android app app forcibly shuts down. public void getdata(string[] results) { string[] columns = new string[]{ key_sno,key_item,key_price,key_time }; cursor c = canteendb.query(database_ctable,columns,null,null,null,null,null); int isno = c.getcolumnindex(key_sno); int iitem = c.getcolumnindex(key_item); int iprice = c.getcolumnindex(key_price); int itime = c.getcolumnindex(key_time); for(c.movetofirst(); !c.isafterlast(); c.movetonext()) { results[0]=c.getstring(isno); results[1]=c.getstring(iitem); results[2]=c.getstring(iprice); results[3]=c.getstring(itime); } } here's logcat: 06-21 18:55:17.028: e/androidruntime(9160): fatal exception: main 06-21 18:55:17.028: e/androidruntime(9160): java.lang.runtimeexception: unable start activity componentinfo{com

css - Border around HTML Page Not Working -

css - Border around HTML Page Not Working - i have looked around few different solutions on google , tried them out, still cannot seem page border work. i tried creating div container contain on page, had div 4 div circles on inside, did not work when added border. so, took outer div away , left 1 div 4 div circles inside. finally (what below), tried adding border body, still not set border around entire page. i have feeling problem might have height , width values, have played , not desires results. thanks advice here code: <!doctype html> <html> <head> <style> body { background: white; border: 1px solid #ff0000; width: 100%; height: 100%; } .circle { width: 100px; height: 100px; -webkit-border-radius: 50px; -moz-border-radius: 50px; border-radius: 50px;

c# - share data status on different instances of WCF -

c# - share data status on different instances of WCF - i have 2 servers(and more later) wcf service, both behind load balancer. client application, in multiple servers(also loadbalanced), phone call wcf action, lets save. same data, lets client information, opened several users @ same time. save action can be, then, executed several users @ same time, , phone call go different wcf servers. i want when user phone call save ui, , there save in progress ui on same client data, sec user alerted it. that, wcf instances should know actions been executed in other instances. how can synchronize info status between wcf server instances ? dont want share data, status of data(opened, save in progress, that) please advice, thanks, i'm working c#/.net4 added: wcf hosted within windows service. the problem having 1 of resource management. you trying resolve way how can service clients somehow know open handles each other have on internal state within service, , fo

java - How to configure Orika classMap for class hierarchies? -

java - How to configure Orika classMap for class hierarchies? - i'm trying understand how configure orika class mapping correctly in case have inheriting classes. i've set simple illustration ba able understand working , not working, not it. public class source { private final string alpha; public source(final string alpha) { this.alpha = alpha; } public string getalpha() { homecoming alpha; } } public final class sourceextended extends source { private final string beta; public sourceextended(final string alpha, final string beta) { super(alpha); this.beta = beta; } public string getbeta() { homecoming beta; } } public final class target { private final string alpha; private final string beta; public target (final string alpha) { this(alpha, null); } public target(final string alpha, final string beta) { this.alpha = alpha; this.bet

ssl - Nginx redirect http to https not working -

ssl - Nginx redirect http to https not working - i'm setting nginx server ssl. the domain ssl dev.cooknconnect.com want redirect requests from: http://domain.com https://domain.com have next server blocks setup currently: server { hear 1.2.3.4:80 default; server_name domain.com; server_tokens off; rewrite ^ https://$server_name$request_uri? permanent; } server { hear 443 ssl; server_name domain.com www.domain.com; keepalive_timeout 70; server_tokens off; ssl on; ssl_certificate /etc/ssl/certs/certificate.crt; ssl_certificate_key /etc/ssl/private/certificate.key; ssl_session_timeout 5m; ssl_protocols sslv3 tlsv1; ssl_ciphers all:!adh:!export56:rc4+rsa:+high:+medium:+low:+sslv3:+exp; ssl_prefer_server_ciphers on; location / { proxy_pass http://do

syntax error in json using ajax and php -

syntax error in json using ajax and php - here total code. error seems in jsontesting.php page variables literature, history , comedy.it's giving me these variables not defined.these variables supposed post ajax. please help asap.here php page (jsontesting.php): <?php $library= '{"closets":[ {"id":"001","theme":"literature","shelves": { "books": [{"id":"b1","genre":"english literature"}, {"id":"b2","genre":"arabic literature"}, {"id":"b3","genre":"french literature"}

javascript - Offline persisting storage in Sencha mobile app -

javascript - Offline persisting storage in Sencha mobile app - i new mobile app development. creating cross-platform app using sencha + phonegap. goal store user-written text in mobile (offline storage) , other text info related it, persist if mobile restarts, uploaded server, 1 time mobile has connection. according http://docs.sencha.com/touch/2.3.2/#!/api/ext.data.proxy.proxy sencha provides 2 client side storages. localstorageproxy - saves info localstorage if browser supports memoryproxy - holds info in memory only, info lost when page refreshed memoryproxy out of question. , localstorage uses html5 storage , dont believe that lasts after reboot. so need kind of database, accessible sencha, on both android , ios, in offline mode. there such thing? your assumption wrong, localstorage persistent between applications restarts , application reboots. maybe confusing sessionstorage ? far know, info wiped out if user actively clears application info (fo

CKAN: custom authentication but with default session handling -

CKAN: custom authentication but with default session handling - what direct approach implement hook ckan login mechanism, allows 1 define user log in based on apache environment headers instead of validating username/password. when writing plugin implements ckan.plugins.iauthenticator class requires both login() , identify() method. 1 has define way of keeping track of user. however, want check whether trusted info (shibboleth environment variables) available , log in corresponding user, in effect bypassing login form, leaving session handling ckan internals. can write iauthenticator plugin identify() method looks these environment variables, , if don't need login() method leave blank? def login(self): pass i think should work. ckan calls identify() 1 time each request decide user loggged in. calls login() 1 time each time login form submitted. apart identify() check on each request, rest of ckan's session handling go on work normal plug

css3 - Combining max-width and min-device-pixel-ratio -

css3 - Combining max-width and min-device-pixel-ratio - i've been asked create different responsive layouts tablets, depending on if high pixel density displays or not. this code, target iphone 5s in landscape, doesn't seem work. possible? @media screen ( min-width: 568px) , (-webkit-min-device-pixel-ratio: 1.25), screen ( min-width: 568px) , ( min--moz-device-pixel-ratio: 1.25), screen ( min-width: 568px) , ( -o-min-device-pixel-ratio: 1.25/1), screen ( min-width: 568px) , ( min-device-pixel-ratio: 1.25), screen ( min-width: 568px) , ( min-resolution: 200dpi), screen ( min-width: 568px) , ( min-resolution: 1.25dppx) { body { background-color: maroon; } } by nesting min-width within queries dpi seems working (i haven't tested on big arsenal of devices). i've never heard of beingness done, safe do? @media screen , (-webkit-min-device-pixel-ratio: 1.25), screen , ( min--moz-device-pixel-ratio: 1.25), scre

Upgrade Azure virtual machine to A8 -

Upgrade Azure virtual machine to A8 - we have running azure virtual machine on a7 bundle wish upgrade a8 can provide steps finish this you need go azure portal, configuration -> settings -> virtual machine size ( pick a8 ). click save @ bottom , instance reboot. azure

python - Pyjamas-desktop (pyjd) compiles, runs and quits -

python - Pyjamas-desktop (pyjd) compiles, runs and quits - i'm running pyjamas on windows 8.1 python 2.7 (64-bit). i've struggled bit getting installed, believe struggle has been fruitful -- i've run bootstrap, file "run_bootstrap_first_then_pyjd_setup.py", , have moved on experimenting pyjamas desktop. i'm trying view hello.py illustration (in examples/helloworld directory) running both run.bat file in command line & double-clicking in gui windows explorer. code of .bat file below: @echo off python hello.py the programme compile, run, open white window quit. makes me think it's not quite running (or pyjamas doesn't interface windows 8.1). if run hello.py file straight typing python hello.py into command line, same thing happens. i'm guessing windows software versioning problem (8.1 isn't capable of running current version of pyjamas or .....any ideas? haven't run particular error, help debug going on, can

php - Google app-engine - Uploaded files not public on google cloud storage -

php - Google app-engine - Uploaded files not public on google cloud storage - i have app lets users upload image, , want other users able see image. i using cloudstoragetools::createuploadurl method allows users upload via post. taking uploaded file , using move_uploaded_file store on google cloud storage. then, using cloudstoragetools::getpublicurl url file. returns right url, file not publicly accessible xml error response "accessdenied". i know because file isn't shared publicly, i'm not sure how create public after gets upload. i tried passing in "acl=public-read" alternative createuploadurl, returned error of unknown option. i see illustration of how todo on page: https://developers.google.com/appengine/docs/php/googlestorage/public_access however, workflow requires me allow normal post uploads using createuploadurl method shown here: https://developers.google.com/appengine/docs/php/googlestorage/user_upload how create user uploade

Parse xml in stored procedure oracle -

Parse xml in stored procedure oracle - i have list has list type property (address) within it. sending whole info xml in database update/insert details in oracle table. here xml format declare x xmltype := xmltype( ' <person> <row> <name>tom</name> <address> <localaddress> <state>california</state> <city>los angeles</city> </localaddress> <localaddress> <state>california1</state> <city>los angeles1</city> </localaddress> </address> </row> <row> <name>jim</name> <address> <localaddress> <state>california</state> <city>los angeles</city> </localaddress> </

properties - Maintainability of library in C++ -

properties - Maintainability of library in C++ - i creating library in c++ intent of utilizing in future applications (games). decided on using entity-property design base of operations entity can extended attaching various properties it. properties derivatives of base of operations gameproperty class allows them stored in single vector of polymorphic pointers, fellow member of gameentity class. have entitymanager class creates specialized entities attaching right set of properties them, in accordance entitytemplate can loaded file. here problem: want easy create , add together new properties suit needs of given project. each new property cannot extend gameproperty, needs seemlessly possible integratable entitymanager. entitymanager expects strings "graphicsproperty", "inputproperty", etc , selects property attach newly created entities based on that. how can construction property , entitymanager classes in such way typespecific code not need added enti

php - Use function in another JavaScript file? -

php - Use function in another JavaScript file? - i have php file next @ bottom: <script src="js/functions.js"></script> <script type="text/javascript"> alert(testfunction()); </script> i have js file called functions.js next function: function testfunction() { homecoming 'hello world!'; } why console show referenceerror: testfunction not defined when i've imported right js file , called function? works fine here: (i know not needed simple) http://jsfiddle.net/6flny/1/ the thing is... create sure script file correctly linked page. here brief description of file paths when inserting path in src tag: ./ means current directory ../ means parent of current directory, not root directory / root directory myfile.text in current directory, ./myfile.text ../myfile.text 1 level above , /myfile.text lives in root directory. so you: <script src="js/functions.js">

Trying to add attachment to PHP email from html form -

Trying to add attachment to PHP email from html form - i struggling , have tried many different methods form attach file email sent through php. this html form: <form id="form1" enctype="multipart/form-data" action="submit/applicationscript.php" method="post" name="form1"> <input checked type="radio" name="school" value="english martyres"/> <input type="radio" name="stop" value="stop1" /> <input type="radio" name="stop" value="stop2" /> <input type="radio" name="stop" value="stop3" /> <input type="radio" name="stop" value="stop4" /> <input type="checkbox" name="mon" value="monday" /> <input type="checkbox" name="tue" value="

android - How and why to send a MultiPartEntity (best chunked) with OKHttp? -

android - How and why to send a MultiPartEntity (best chunked) with OKHttp? - i know it's improve utilize okhttp based on httpurlconnection, dont know why. why improve utilize okhttp instead of implemented httpurlconnection? and.. how possible send mixed data. post vars , files. best if there multithreaded possible. here's illustration of client using httpurlconnection. how in okhttp? dataclass , datapackage modals holding files , info sending. the client if self called factorymanager (lazyloading) using public static defaulthttppostclient getenterprisehttpmanager() { if (defaulthttppostclient == null) { defaulthttppostclient = new defaulthttppostclient(); } homecoming defaulthttppostclient; } the constructor of httpclient request it's settings everytime when called. public static httpconnectionsettings getdefaulthttpconnectionsettings() throws malformedurlexception { httpconnectionsettings httpconnectionsettings = n

c# - How to use a SqlDataReader result as a MySqlParameter value -

c# - How to use a SqlDataReader result as a MySqlParameter value - i'm moving tables sql server db mysql db programmatically. i've got sqldatareader populated table's fields values, , insert them corresponding mysql table. there aren't primary key , auto increment problems on destination table. what i'm missing howo convert sqldatareader field value mysqlparameter value. snippet of code: cmd.commandtext = "select a,b,c,d,e sqltable"; cmd.prepare(); dr = cmd.executereader(); while (dr.read()) { mysqlconnection mysqlconn = new mysqlconnection(mysqlconnstring); mysqlconn.open(); mysqlcmd.connection = mysqlconn; mysqlcmd.commandtext = "insert mysqltable values (?, ?, ?, ?, ?) "; (int k = 0; k < dr.fieldcount; k++) { mysqlcmd.parameters.add(new mysqlparameter(dr[k].tostring(), dr[k])); } ... a fatal error occurs on line, without detail. mysqlcmd.parameters.add(new mysqlparameter(dr[k].tostring(

android - Filter newGraphPathRequest "me/friends by name -

android - Filter newGraphPathRequest "me/friends by name - is there way filter graph result facebook ( me/friends ) name? i add together simple search function in android app user can search though friends , show result. think no way fetch finish list of friends , filter later. this short snipped how utilize @ moment private request createrequest(session session) { request request = request.newgraphpathrequest(session, "me/friends", null); set<string> fields = new hashset<string>(); string[] requiredfields = new string[] { "id", "username","name", "picture" }; fields.addall(arrays.aslist(requiredfields)); bundle parameters = request.getparameters(); parameters.putstring("fields", textutils.join(",", fields)); if(!searchactive) { parameters.putstring("limit", limit); parameters.putstring("of

JavaScript: Get the value of a dinamicly generated object -

JavaScript: Get the value of a dinamicly generated object - i know can access value of user defined variable composing name like window["myvariable"+1234] what don't know how access value of inner properties. want next code, works: //suppose there object user-generated property names mycars.ford.focus.mileage , need function reports value of property when content not empty string. create function function squealproperty(maker,model,udprop){ if(window["mycars."+maker+"."+model+"."+udprop+".length"] > 0){ alert("user defined property inspector ("+udprop+")="+window["mycars."+maker+"."+model+"."+udprop]); }; }; in moments this, find answers prayers in "the book"[1] no luck time. inquire here. [1] "the book" mean "javascript: definitive guide", 5th edition. david flanagan you can not access propertys single string

c# - Is there any way to set the height of winform more than 1044? -

c# - Is there any way to set the height of winform more than 1044? - i tried set form height 2000 homecoming height size 1044 in c# winform. way create height size more 1044 in winform c#? the reply no, though is size of form in visual studio designer limited screen resolution? has workaround situations. as explained in q&a, intentional , design: from msdn property form.size: maximum value of property limited resolution of screen on form runs. value cannot greater 12 pixels on each screen dimension (horizontal + 12 , vertical + 12). c# winforms

jquery - having an issue when edited a row again it is inserting a new row in php codeigniter -

jquery - having an issue when edited a row again it is inserting a new row in php codeigniter - i have issue edit , update row having file upload field. problem when inserting row if there file uploaded inserting row, when edited not showing file , 1 time again asking file upload. here controller: public function addclient() { $logo = 'logo'; $status = ""; $msg = ""; $file_extension = ""; $this->load->library('form_validation'); $this->form_validation->set_rules('name','name','trim|required'); $this->form_validation->set_rules('location', 'location', 'trim|required'); $this->form_validation->set_rules('address', 'address', 'trim|required'); $this->form_validation->set_rules('mobile', 'mobile', 'trim|requ

Define date type in Magento widget -

Define date type in Magento widget - i want write widget allow input 2 date. know type of date in magento. illustration text type in etc/widget.xml: <parameters> <limit_count> <label>limit count</label> <description>the numbers of product show</description> <visible>1</visible> <required>1</required> <type>**text**</type> </limit_count> </parameters> i want alter text type datetime type. there way resovle problem. thanks magento

linux - Mono stream issue -

linux - Mono stream issue - i want upload file on server using nancyfx. this: var filestream = file.create(path_to_file); file.value.seek(0, seekorigin.begin); file.value.copyto(filestream); filestream.close(); also tried: byte[] buffer; using (var memorystream = new memorystream()) { file.value.seek(0, seekorigin.begin); file.value.copyto(memorystream); buffer = memorystream.toarray(); } memorystream ms = new memorystream(buffer, 0, buffer.length); ms.position = 0; image img = image.fromstream(ms, true); img.save(path); and this: file.writeallbytes(coverpath, buffer); on windows pc works great. on linux server, image saving, image content doesn't match original image. so, here images: original image, uploading: http://i.stack.imgur.com/mtse2.jpg saved image: http://i.stack.imgur.com/orkn1.jpg if image size < 900kb, image saving good, times there appears lines. please, help. as understand have filestream , wanna save image here peace of

vb.net - getting data from datagridview and adding itto another table -

vb.net - getting data from datagridview and adding itto another table - im doing software handle library, book stock, readers getting books , whatnot... in form im suppose register book loan, maintain getting error saying system.invalidcastexception unhandled hresult=-2147467262 message=o operador '&' não está definido para cadeia "insert levantamento values(" e tipo 'datarowview'.(the operator & not defined string..... , says type info row view this code gets info datagrid view textbox dim s string = datagridview1.rows(datagridview1.currentrow.index).cells(0).value 'command bring info itemid matches selected cell row itemid dim cmd new sqlcommand("select livro.id_livro, livro.titulo, autor.autor, [tipo de livro].tipodelivro, livro.[data de ediçao], livro.quantidade livro inner bring together autor on livro.id_autor = autor.id_autor inner bring together [tipo de livro] on livro.id_tipodelivro = [tipo de livro].i

php - How to generate an XML with comments with CakePHP? -

php - How to generate an XML with comments with CakePHP? - cakephp provides functionality generate xml documents/strings array (s. cakephp docu -> core libraries -> utilities -> xml -> transforming array string of xml). simple example: $xmlarray = array( 'project' => array( '@id' => 1, 'name' => 'name of project, tag', '@' => 'value of project' ) ); $xmlobject = xml::fromarray($xmlarray); $xmlstring = $xmlobject->asxml(); result: <?xml version="1.0"?> <project id="1">value of project<name>name of project, tag</name></project> now i'd generate xml 1 or more comments, this: <?xml version="1.0"?> <!-- here comment --> <project id="1">value of project<name>name of project, tag</name></project> is possible? how that? comment: this question marked

c# - Class design: Access two keys as properties using a constant? -

c# - Class design: Access two keys as properties using a constant? - now: 2 classes each same constant name, e.g. err123 class1 got public const int err123 = 123; class2 got public const string err123 = "error 123, went wrong."; so phone call int code = class1.err123; string message = class2.err123; i don't approach because need re-create constant names , touch 2 files when add/change something. i'd access that: int code = errors.subcategory1.err123.code; string message = errors.subcategory1.err123.message; and declaration shouldn't inconvenient. possible? maybe using reflection-magic? to descript message codes descriptions can utilize enum descrition attribute. get enum description attribute c# reflection .net-3.5 class-design

html - Working with span in ggplot2 / geom_smooth -

html - Working with span in ggplot2 / geom_smooth - i using ggplot2 create plot several info sets. not datasets have same amount of datapoints (or have breaks), adjust span. but not sure effects adjustment of span have, neither documented in stat_smooth nor in geom_smooth , thought can find how span taking info dataset? how span calculate number of datapoints have taken calculating smoother? code looks this: t<-ggplot(data=xx1)+ scale_x_date(as.posixct(xx1$date1), breaks = "1 month", labels=date_format("%b %y"))+ geom_vline(xintercept=as.numeric(xx2$day.of.action, colour="lightgray"))+ geom_point(aes(x=day, y=perc_dp10m, colour=as.factor(station_subunit) ))+ geom_smooth(data=1_f1, aes(x=day, y=perc_dp10m, colour=as.factor(station_subunit)),method=loess, span=0.3, se=false, lwd=1)+ geom_smooth(data=xx1, aes(x=day, y=perc_dp10m, colour=as.factor(station_subunit)),method=loess, span=0.3, se=false, lwd=1)+ geom_smooth(data=1_f3, aes(x

optimization - Python speed up: checking if value in list -

optimization - Python speed up: checking if value in list - i have programme processes csv file. contents of csv follows lines = [ [id_a, val1, val2, ..., valn], [id_a, val1, val2, ..., valn], [id_b, val1, val2, ..., valn], [id_b, val1, val2, ..., valn], [id_b, val1, val2, ..., valn], [id_b, val1, val2, ..., valn], [id_c, val1, val2, ..., valn], [id_c, val1, val2, ..., valn], ] i building dictionary looks my_dict = { 'id_a': ['many', 'values'], 'id_b': ['many', ''more', 'values'] 'id_c': ['some', 'other', 'values']} my current implementation looks like for line in lines: log_id = line[0] if log_id not in my_dict.keys(): datablock = lines[1:] my_dict[log_id] = datablock else: my_dict[log_id].append(lines[1:]) with close 1000000 lines in csv, programme starts slow downwards 1 time there couple one thous

ruby on rails - Whenever X is true do X, otherwise Y -

ruby on rails - Whenever X is true do X, otherwise Y - think i'm brain dead. need concise way of writing when x exists (the value specified key in hash), print value (i.e., x), otherwise, print 0. reason needs concise because i'm using in options form_tag , , i'd avoid writing method. can't think through... here's i've tried: this won't work because homecoming "0": <%= number_field_tag "transaction[][#{thing}]", :quantity, min: 0, placeholder: 0 || @transactionparams["#{thing}"] %> this won't work because whenever @transactionparams doesn't exist, instead of getting 0, error undefined method []' nil:nilclass <%= number_field_tag "transaction[][#{thing}]", :quantity, min: 0, placeholder: @transactionparams["#{thing}"] %>` how ternary operator? @transactionparams = {:thing => "foo"} puts @transactionparams ? @transactionparams[:thing] : 0 @transacti

c# - UI freezes when using async await -

c# - UI freezes when using async await - i have troubles create ui work using async method. here part of code private async void btndooutput_click(object sender, routedeventargs e) { /* initiliaze */ groupboxconfiguration.isenabled = false; var progressindicator = new progress<int>(); progressindicator.progresschanged += (s,value) => { progressexport.value = (double)value; labelpercentage.content = "export in progress : " + value + " %"; }; /* work */ switch (something) { case 1: await method(input, output, options, progressindicator); break; default: break; } /* finalization */ groupboxconfiguration.isenabled = true; } the method public async static task<string> method(string input, string output, string options, iprogress<int> progress) { while(something) { //operations on input , output if (prog

c++ - diff btwn Function returning nonrefrence variable andrefrence variable by reference -

c++ - diff btwn Function returning nonrefrence variable andrefrence variable by reference - consider below code int& func1() { int x = 2; homecoming x; } int& func2(int &x) { homecoming x; } int main() { int x = func1(); cout<<"\n : "<<x; int y = 3; x = func2(y); cout<<"\n : "<<x<<"\n"; } output: : 2 : 3 the code working absolutely fine , have few doubts have listed below: in func1() have returned non_reference variable "x" homecoming type reference int, how conversion happening , part of "x" function returning. in func1() "x" returned reference beingness stack variable how reference of x can returned , mean have no significance after completion ( relating point logic " functions should not homecoming pointers memory allocated in statically"). in func1() returning non refrence variable "x" refrence i

sql - Error : Login failed for user 'domain\username' using SqlCredential object -

sql - Error : Login failed for user 'domain\username' using SqlCredential object - i using below mentioned code when tried connect sql server. geeting login failed user 'domain\username'. have checked user having sysadmin permission in sql server & using sql server express edition. connection string used "initial catalog=employee;server=servername" public static bool connectsqlclient(string connecton) { bool isconnect = false; seek { string username = @"domain\username"; string initstring = "abcpassowrd"; // instantiate secure string. securestring teststring = new securestring(); // utilize appendchar method add together each char value secure string. foreach (char ch in initstring) teststring.appendchar(ch); teststring.makereadonly(); sqlcredential cred = new sqlcrede