Posts

Showing posts from January, 2014

Using Poly/ML to build projects with nested directory structures -

until now, have been using poly/ml several small projects source code files in same directory. build these projects, had run following command in repl: > polyml.make "main"; but have project scale makes impractical put source code files in same directory. build these projects in repl, need run following commands: > polyml.make "foo/foo"; > polyml.make "bar/bar"; > polyml.make "qux/qux"; > polyml.make "main"; which not terribly practical number of subsystems grows. is there way automate process of building projects nested directory structures in poly/ml? p.d.: have had @ both sml/nj's compilation manager , mlton's ml basis system. while unquestionably powerful, these complicated needs. put file called ml_bind.ml in each of sub-directories , have files build component directory. polyml.make expects name of source file match name of component (structure, signature or functor). if looking

php - How can I determine when the form data has been successfully entered in the database? -

first here code: <?php //establish connection database require("database.php"); try{ // prepare , bind $stmt = $conn->prepare("insert clients (phonenumber, firstname) values (:phonenumber, :firstname)"); $stmt->bindparam(':phonenumber', $phonenumber, pdo::param_str); $stmt->bindparam(':firstname', $firstname, pdo::param_str); // set parameters , execute if(isset($_post['phonenumber'])){ $phonenumber = $_post['phonenumber']; } if(isset($_post['firstname'])){ $firstname = $_post['firstname']; } $stmt->execute(); }catch (exception $e) { echo "could not insert data database $e"; exit; } //my attempt on checking if data has been entered in database $inserted = true; ?> <h2>the form</h2> <hr /> <br /> <form action="" method="post"> number: <input type="text" name="phonenumber" valu

Destructor in C++ doesn't work -

can tell me what's wrong me destructor ? if remove working well. #include "stdafx.h" #include <stdio.h> #include <string.h> #include <conio.h> class dynstring { private : char *string; int size; public : dynstring(const char *tab) { string = new char[strlen(tab)]; size = strlen(tab); if (string != null) { strcpy(this->string, tab); } } dynstring(const dynstring& s) { string = new char[s.size]; if (string != null) { strcpy(string, s.string); size = s.size; } else size = 0; } int size() const { return size; } const char* cstr() { return string; } dynstring& operator +=(const char* tab) { char *bufor = new char[size + s

php - Codeigniter and jquery Ajax method with Sever side validation -

i using codeigniter jquery ajax call, want is: show error message codeigniter own form_validation errors. i using jquery $.ajax method , getting form values clicking on sumbit button, handled in formhander.js file. i given if($this->form_validation->run() == false) in condition, when submit form jquery ajax method. my controller file: ajaxcontroller.php follow: class ajaxcontroller extends ci_controller { public function __construct() { parent::__construct(); $this->load->library('form_validation'); $this->load->helper('url'); } public function index() { $this->form_validation->set_rules('fname', 'first name', 'required|min_length[1]|max_length[50]'); $response = array('code' => 500, 'message' => null); if ($this->form_validation->run() == false) { $this->load->view('ajax_form');

css3 - Questions regarding CSS <div> tags vs. HTML table -

many have cautioned not use html tables construct html page layout, i'm struggling design work right css , tags. here's example in tables want , how simple was: editor's note: code example required jsfiddle.net/y2rlm0t6/1/ and now: editor's note: code example required: jsfiddle.net/hyp8re6h/ i have 3 questions: should create new div inside other div "lay-main" properties such max-width px , make centerd inside "lay-main"? resolve problems i'm having image being stretched across screen? my header i'm calling lay-top. should same thing here, menu start bottom-left 800px that's centered , not centerd entire page now. how go making height of "lay-main" take remaining space after lay-top/lay-bottom have taken space. attempts tried height 100% resulted in adding *px bottom , making page scroll no reason. read strange fixes such setting -*px margins bottom layer etc. also, im asking myself why continue using css l

batch file - Migrate Printers using the command line -

im looking copy printers users old workstation new workstation i have tried built in printbrm.exe need work reliably , simply. are there command line solutions can or sol;ution that can run batch file? thanks reading confuseis

java - Can't update the version code in a PhoneGap Android application -

i have tried upload new apk application google play keeps telling me version code still "1" when have stated in both config.xml , androidmanifest.xml (main) version code should "9". this new android project since lost source old 1 in hard drive crash. config.xml: <widget xmlns = "http://www.w3.org/ns/widgets" id = "com.phonegap.helloworld" version = "1.3.0" android-versioncode = "9" > androidmanifest.xml: <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" android:versioncode="9" android:versionname="1.3.0" > i have been on hunt answer on multiple forums both on @ google, phonegap, cordova , here no solution far. suggestions? this depends on buildtool. if android-gradle, value build.gradle override corre

c++ - Errors while linking in Qt5 with poppler -

/usr/lib/libpoppler.so.50: undefined reference std::__throw_out_of_range_fmt(char const*, ...)@glibcxx_3.4.20' makefile:156: recipe target 'docviewer' failed /usr/lib/libsystemd.so.0: undefined reference to lzma_stream_decoder@xz_5.0' /usr/lib/libqt5core.so: undefined reference __cxa_throw_bad_array_new_length@cxxabi_1.3.8' /usr/lib/libsystemd.so.0: undefined reference to lzma_end@xz_5.0' /usr/lib/libsystemd.so.0: undefined reference `lzma_code@xz_5.0' collect2: error: ld returned 1 exit status make: *** [docviewer] error 1 20:53:35: process "/usr/bin/make" exited code 2. i errors mentioned above while compiling program using poppler in qt5 . below project file, should in change something? qt += core gui greaterthan(qt_major_version, 4): qt += widgets target = docviewer template = app includepath += /usr/include/poppler/qt5 libs += -l/usr/lib -lpoppler-qt5 sources += main.cpp\ mainwindow.cpp

Gregorian Calendar -

one part of assignment requires me use gregorian calendar in student class. every student has unique studentnumber (int), name (string), ** dateregistered (gregoriancalendar) ** , id (string) , courseenrolled (courseoffering). import java.util.calendar; import java.util.gregoriancalendar; public abstract class student { private int studentnumber; private string name; private string id; private courseoffering courseenrolled; private gregoriancalendar startdate = new gregoriancalendar(); public student( int studentnumber, string name, string id, courseoffering courseenrolled){ this.studentnumber = studentnumber; this.name = name; this.id = id; this.courseenrolled = courseenrolled; } public int getstudentnumber(){ return studentnumber; } public string tostring(){ return string.format("%08d", studentnumber) + " " + name + " " + id; } } i

The difference between these two scheduled method calls - iOS -

i have seen around few times can't seem find difference between 2 ... [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(loginviewfetcheduserinfo:) name:fbsdkprofiledidchangenotification object:nil]; - (void)loginviewfetcheduserinfo:(nsnotification *)notification and [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(loginviewfetcheduserinfo) name:fbsdkprofiledidchangenotification object:nil]; - (void)loginviewfetcheduserinfo i know (void)methodname:(type *)newname can pass in value method don't know difference in 2 above , why first 1 (which used in facebook sdk example) on second one. the first method passes nsnotification object method. way allows acce

Fail to pass user input to wget in python -

i pass user input wget download content of web page. user_input = raw_input "type url here.. " os.system("wget -o /directory/, user_input") the code above did not work because wget not take user input, wget "user_input" instead. there way round problem? thank you you not passing variable, use subprocess module: from subprocess import check_call user_input = raw_input("type url here.. ") check_call(["wget", "-o", "directory/foo.html", user_input]) in code need pass variable: os.system("wget -o /directory {}".format(user_input)) if command returns non-zero exit status calledprocesserror using check_call . the easiest way save file let user pick name , add extension. parse url passed there many possible variations consistently: user_input = raw_input("type url here.. ") save_as = raw_input("enter name save file as...") check_call(["wget",

python - modify ip and port where modoboa is listening -

how can modify ip , port modoboa listening. default listening on localhost , port 8000 http://localhost:8000/ i make listening on ip, http://0.0.0.0:8000/ i can't find no place in docu describing this. in advance b.t.w. : not able create new tag "modoboa", maybe 1500 points can me the web-facing part of modoboa seems ordinary django application. can specify address you're binding this: python manage.py runserver 0.0.0.0:8000 please note documentation advises against using embedded webserver in production. recommends use external webserver apache or nginx instead .

html - PHP - Display mysql single record php via id from database -

my html lists rows database table (venues), want view records separately. user should able click row, , redirected single page , see details. here 1st page. <?php // include connection file. include("func.inc.php"); //////displaying data///////////// $venue_id = mysql_real_escape_string($_get['venue_id']); $venue_id=$_get['venue_id']; $city=$_get['city']; $reason=$_get['reason']; $budget=$_get['budget']; // select rows in markers table $query = sprintf( "select city, reason, budget, venue_name, description, venue_id venues city = '%s' , reason = '%s' , budget = '%s' ", mysql_real_escape_string($city), mysql_real_escape_string($reason), mysql_real_escape_string($budget) ); $result = mysql_query($query); if($result == false) { die(mysql_error() . "<br />\n$query"); } if(mysql_num_rows($result) == 0) { user_error("no rows returned by:<br />\n

ios - Floating star effect with an animation and UIImageView -

i need make floating star effect uiimageview when view load , put below code method , call viewwillappear doesn't work expected. little star must became large (4 x height , width) , centered animation work reverse. star starts 4 x height , width , start became smaller. [uiview animatewithduration:3 delay:0.1 options: uiviewanimationoptioncurveeasein animations:^{ self.daystar.frame = cgrectmake(0, 0, self.view.frame.size.width * 4, self.view.frame.size.height * 4); self.daystar.center = self.view.center; } what need change on code , should put it. thanks. seems overrides lines. it's code change daystar? scale use: [self.daystar settransform:cgaffinetransformmakescale(scale, scale)]

bash - Find a port in a configuration file with regex -

in configuration file (nginx default.conf) got strings this: server { listen 80; server_name sudomain1.somewhere.com ; location / { proxy_set_header host sudomain1.somewhere.com; proxy_pass http://127.0.0.1:8999/; } } in bash script, catch port number " 8999 " in variable use after in script. if possible using entire string above. because in file have several times sequence, , variable mark " subdomain1 " does know how this? you can single line: ( ln=$(grep -a 1 sudomain1 nginxconf.txt | tail -n1); port=${ln##*:}; port=${port%/*}; echo "port: $port" ) or script: #!/bin/bash ln=$(grep -a 1 sudomain1 nginxconf.txt | tail -n1) port=${ln##*:} port=${port%/*} echo "port: $port" you first locate sudomain1 , line follows using grep -a 1 use tail -n keep last line. simple parameter matching/substring extraction isolate 8999 . output

count - How many times each value from a list appears in a column in another table. MYSQL -

i have table of id values , need count how many times each of ids appears in column in table. i have figured out how values appear @ least once: select one.id, count(*) table1 one, table2 2 one.id = two.id group one.id; but can't figure out how include ids appear in first don't appear in second table @ all. example: table1: table2: +-----+ +-----+ | id | | id | +-----+ +-----+ | 11 | | 11 | | 12 | | 12 | | 13 | | 14 | | 14 | | 11 | +-----+ | 11 | | 12 | +-----+ the result be: +-----+----------+ | id | count(*) | +-----+----------+ | 11 | 3 | | 12 | 2 | | 14 | 1 | +-----+----------+ i'm trying make include line | 13 | 0 | you doing implicit inner join discouraged. instead need left join, like: select one.id, count(two.id) table1 1 left join table2 2 on one.id = two.id group one.id;

c++ - Arrays vs. Doubly Linked Lists for Queue simulation -

i working on assignment school simulating line students , multiple windows open @ registrar's office. i got queue students down suggested use array windows implementing our queue class made on our own. don't understand why array work when there other variables want know each window besides student time decrementing. i'm looking direction or more in depth explanation on how that's possible use array store time each student @ window opposed doubly linked list? the way see you've got variable number of students , fixed number of windows (buildings don't change often). if make representation of in code use dynamically sized container (a list, vector, queue, etc.) contain students , fixed-size array registers. embody intent of real situation in code, making less else using code makes mistakes related size of registrar's office. choosing container type intended use! thus can design class hold registers using fixed-size array (or nicer: templat

java - How to implement edit functionality in ThymeLeaf in Spring MVC -

i using this tutorial see delete functionality each row: 7.6 dynamic fields thanks advanced form-field binding capabilities in spring mvc, can use complex spring el expressions bind dynamic form fields our form-backing bean. allow create new row objects in our seedstarter bean, , add rows’ fields our form @ user request. in order this, need couple of new mapped methods in our controller, add or remove row our seedstarter depending on existence of specific request parameters: @requestmapping(value="/seedstartermng", params={"addrow"}) public string addrow(final seedstarter seedstarter, final bindingresult bindingresult) { seedstarter.getrows().add(new row()); return "seedstartermng"; } @requestmapping(value="/seedstartermng", params={"removerow"}) public string removerow( final seedstarter seedstarter, final bindingresult bindingresult, final httpservletrequest req) { fina

html - erb without rails helpers -

i'm switching python app ruby , need implement erb html , clueless how implement of basic things. seems recommends using rails helpers aren't available me. i'm trying below line work. figured in loop interpolated, links aren't working. appreciated. <% employee in @employees %> <div class="col-sm-6 col-md-3 employee"> <a style="text-align:center;" href="/employee/#{employee.id}" class="thumbnail"> <% if !employee.filename? %> <img src='#{settings.employee_image_url}'> <% else %> <img src='#{settings.no_image_url}'> <% end %> the follow should fix issue. <img src="<%= settings.no_image_url %>"> string interpolation executed ruby, "#{settings.no_image_url}" not ruby string in context you're using it.

oop - Perl - create objects but how to get at the individual object? -

i create objects don't know how use them once created (do set/get , run methods). code below works cannot @ object use how do this? # array of coffeecup names @coffeecupnames = ("espresso", "sumatran", "java"); # create array hold objects once created @objects = (); # create new coffee cup object name of coffee cup foreach (@coffeecupnames) { push @objects, new virtualcoffeeobject("$_"); } # how @ espresso coffee cup object? i agree hints other answers give don't see why nobody posted obvious solution keep track of created objects. of course can store objects in dedicated scalar variables: my $espresso = virtualcoffee->new("espresso"); $sumatran = virtualcoffee->new("sumatran"); ... as draw coffee types array you'll not want use fixed variable names coffees. tool of choice hash in perl. my @coffee_cup_names = ("espresso", "sumatran", "java"); # crea

Can't Remove Activity Title in My Android Project With minSdkVersion=9, targetSdkVersion=21 -

i new android. trying hide title bar of activity failed every time. my style.xml <resources> <!-- base application theme. --> <style name="apptheme" parent="theme.appcompat.light.darkactionbar"> <!-- customize theme here. --> </style> </resources> failed attempt 1 requestwindowfeature(window.feature_no_title); failed attempt 2 final actionbar actionbar = getactionbar(); actionbar.setdisplayshowtitleenabled(false); failed attempt 3 <activity android:name=".mainactivity" android:label="@string/app_name" android:theme="@android:style/theme.black.notitlebar.fullscreen"> my activity public class jobdetailsview extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { this.requestwindowfeature(window.feature_no_title); this.getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,

javascript - getting connection reset after sending a jquery ajax $.post -

i making game lobby php, jquery, ajax. have php echo string jquery loop sends ajax $.post's page check , see if 1 joined players game, if new users online , current games join. if there fill div's on page new data. here loop <script> $(function() { getpage = function() { // gets current games users trying start $.post("lobbyclasses.php", { lobbyrequest: "getgames", }, function(data, status){ if(status == "success"){ $("#joingamecontainer").html(data); // gets online users , puts themin div onlineusers $.post("lobbyclasses.php", { lobbyrequest: "getonlineusers", }, function(data, status){ if(status == "success"){

java - Custom object deserializes fine in Jax-RS but if it is used in another object it doesn't work -

deserializing works fine if pass custom object through @post public response savecustomobject(customobject data) { // prints correct value system.out.println(data); } however, if property on object, gets default value of custom object @post public response savecustomobjectwrapper(customobjectwrapper data) { // prints incorrect value system.out.println(data.getcustomobject()); } my provider registered , looks this: public customobject readfrom(class<customobject> type, type type1, annotation[] antns, mediatype mt, multivaluedmap<string, string> mm, inputstream in) throws ioexception, webapplicationexception { try { return new customobject(ioutils.tostring(in)); } catch (exception ex) { throw new processingexception("error deserializing customobject.", ex); } } the problem reader other objects doesn't lookup/delegation while unmarshalling. mean that, can seen in this answer , 1 reader looks reade

c# - Managing keyboard focus with custom TextBox control template -

currently i'm working on wpf project has defined custom style textbox . among other things, override default control template textbox . control template looks (i've removed lot of templatebinding stuff since it's not relevant). <border> <grid> <grid.columndefinitions> <columndefinition width="*"/> <columndefinition width="auto"/> </grid.columndefinitions> <scrollviewer x:name="part_contenthost" istabstop="false" background="{x:null}" verticalalignment="center" borderthickness="0"/> <contentpresenter grid.column="1" margin="5,0,0,0" focusable="false" content="{templatebinding local:unitconversion.info}" contenttempla

php - Jquery: remove the particular node from xml and get remaining xml -

below xml, want remove complete data including <onward-solutions> below xml. var xml=' <search-result> <onward-solutions> <solution index="1"> </solution> <solution index="2"> </solution> <solution index="3"> </solution> </onward-solutions> <return-solutions> <solution index="1"> </solution> <solution index="2"> </solution> <solution index="3"> </solution> </return-solutions> </search-result> '; below estimated output xml: <search-result> <return-solutions> <solution index="1"> </solution> <solution index="2"> </solution> <solution index="3"> </solution> </return-solutions> </search-result> can 1 me how expected result? if wan

php - How to make an input identifies an table id, then get the corespondent row and change another value of that row? -

i have tables stored in database (mysql), created table show fields want this: http://prntscr.com/6mkyii here's .php , javascript code (obviously, won't work because im not connecting local database, it's better understanding ^^): https://jsfiddle.net/4zuq8qfy/ $consulta = mysqli_query($link, "select * jogadores"); //consulta banco de dados $tabela = $consulta->fetch_all(mysqli_assoc); //ordena os dados $colunas = mysqli_num_fields($consulta); //pega o numero de colunas $rows = $consulta->num_rows; //pega o numero de linhas my wish link these left buttons (green plus), alter values in db. set names 1, 2, 3.. 40, js because needed differentiate 1 another, , these values set thinking on id_jogador ("id_player"). i'm trying many ways interact php , javascript, or jquery, i'm not getting anywhere. last try make buttons submit input, alter table, direct php. can't differentiate buttons php, , cant compare button'

javafx - JAVA FX - Hide stage lost service task response -

in this post answer why ui blocking after service.start() call, , resolved. have "little" problem... after start() service hide/close stage run application on trayicon. i've noticed hide()/close() stage, service blocked , never go in succeeded status. i've tried remove call , works. how can hide()/close() stage without block service thread , receive answer minimize on tray? @fxml private void handleregisterbutton() { user newuser = new user(); newuser.setusername(usernametextfield.gettext()); newuser.setgroup(groupchoichebox.getselectionmodel().getselecteditem()); newuser.setmachinename(machinenametextfield.gettext()); this.mainapp.registernewuser(newuser); // primarystage main registeruserinvocation service = new registeruserinvocation(newuser); service.stateproperty().addlistener(new invalidationlistener() { @override public void invalidated(observable observable) {

security - Possible malfunction - Python -

is possible potential user make statement true? secret = 25134231 z = ast.literal_eval(user_input) if z == secret: access.granted() edited more answer question... think you're getting @ making function calls user input (among other things) through literal_eval() , , answer no, cannot done. literal_eval() designed protect against type of input. for contrast see below. user type access_granted() , function run same if user typed 24134231 . import ast def access_granted(): print 'yay' while true: secret = 25134231 user_input = raw_input('in: ') z = eval(user_input) if z == secret: access_granted() example: in: access_granted() yay in: 'foo' in: 25134231 yay

electronics - Power supply to custom led backlight -

i programmer not electronic technician therefore: i using power supply: thermaltake tr2 w0070 430w atx12v v2.3 power supply to power 13 leds in parallel. on supply, there 3.3v, 22a connector in want bypass , power leds. these white leds following necessary specs: forward current: 20 ma max peak forward current: 30 ma max suggested using current: 16-18 ma forward voltage: 3.2 min 3.4 max i understand voltage somewhat. however, might calculating wrong or something. either way might stupid question, wouldn't need large resistor withhold remaining current not being used leds? size/value resistor if do? calculations under single ohm resistor, doing wrong? the current value on power supply max. current can drawn power supply. power supply provide needed current only. important thing don't exceed current. (and don't provide more voltage needed loads). so, no need resistor way mentioned it.

android - Barometric pressure - not getting values -

i've read environment sensors documentation i'm trying pressure , unsuccessfully. this have: public class pressure extends activity implements sensoreventlistener{ textview textview; private sensormanager sensormanager; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.my_pressure); textview = (textview) findviewbyid(r.id.txt_pressure); sensormanager = (sensormanager) getsystemservice(service.sensor_service); } @override protected void onresume() { super.onresume(); sensormanager.registerlistener(this, sensormanager.getdefaultsensor(sensor.type_pressure), sensormanager.sensor_delay_normal); } @override public void onsensorchanged(sensorevent event) { if (event.sensor.gettype() == sensor.type_pressure) { float[] values = event.values; textview.settext("" + values[0]); } } @override public void onaccuracychang

Maven Build Failure for chat-jc sample of spring security 4.0 -

there maven build failure when tried compile chat-jc sample of spring security 4.0 first, downloaded sample code command. git clone https://github.com/spring-projects/spring-security.git after, changed directory /samples/chat-jc , 'mvn compile'. , got result [info] scanning projects... [warning] [warning] problems encountered while building effective model org.springframework.security:spring-security-samples-chat-jc:war:4.0.0.ci-snapshot [warning] 'build.plugins.plugin.version' org.apache.maven.plugins:maven-compiler-plugin missing. @ line 246, column 15 [warning] [warning] highly recommended fix these problems because threaten stability of build. [warning] [warning] reason, future maven versions might no longer support building such malformed projects. [warning] [info] [info] ------------------------------------------------------------------------ [info] building spring-security-sa

javascript - Creating page objects in a loop in PhantomJS -

i'm using phantomjs retrieve html of many distinct urls. this, i'm iterating on array of urls , trying create phantomjs page objects (documentation here ). for reason, console.log inside page.open block isn't firing. have idea why? can't find similar problem on google or stack overflow or phantomjs documentation. code: for(var = 0; < urllist.length; i++) { urltorequest = urllist[i]; var page = require('webpage').create(); page.open(urltorequest, function (status) { console.log("status code: ", status); phantom.exit() }); } by default console.log output page suppressed. print out define onconsolemessage handler page object done below , print. page.onconsolemessage = function (msg, linenum, sourceid) { console.log(msg); };

spring - Thymeleaf: How to work with a AbstractIterationElementProcessor class -

anyone work abstractiterationelementprocessor derived class in spring project uses thymeleaf? trying use implement kind of tag: <form:form ...> ... </form:form> the element iterated based on list should generated inside processor class, based on array list of field of class model class passed view (named command ). in each iteration, 1 element of list processed switch-like structure inside tag , inner element chosen ( form:input , form:select , etc). right now, have code: public class formprocessor extends abstractiterationelementprocessor { public formprocessor() { super("form"); } @override public void processclonedhostiterationelement(arguments arguments, element iteratedchild) { // } @override public string getiteratedelementname(arguments arguments, element element) { return "form"; } @override public boolean removehostiterationelement(arguments arguments, element element) { return false; }

css3 - Use css ::before to place blurred circle behind image -

how black circles (shadows) behind images? jsfiddle demo i using background image sprites position round button images on span tags. wish put shadow behind each image visual effect, cannot position black dots behind button images. although works if reverse things , put black dot on span tag , button pic on image tag, there many of these buttons , black dots appear @ once, , after several seconds button images appear @ once on top of dots. works, looks crap. so, need solution keeps button images on span tags, , somehow positions blurry black circle (shadow) behind span tag background image. here have tried (note disabled attempt use ::before pseudo-class. html: <div class="container"></div> <div class="tabmenu"> <span id="sml_1"><img class="smalliconsprite" src="blank.png" width="40" height="40" /></span> <span id="sml_2"><img class=&q

c++ - Convert byte array to picture -

hello try convert byte array image each time null image, me please ? qimage image("p.jpg"); qdebug()<<image; qimage image2; qbytearray paquet2; qdatastream out2(&paquet2, qiodevice::writeonly); out2 << image; qdebug()<<image2.fromdata(paquet2,"jpg"); qdebug 1 result: qimage(qsize(500,500)) qdebug 2 result: qimage(qsize(0,0)) fromdata() static method. try image2.loadfromdata(paquet2) or qimage::fromdata(paquet2) instead. i noticed strange, code works expected: qimage img("..."); qbytearray data; qbuffer buff(&data); qdatastream out(&buff); out << img; qdebug() << qimage::fromdata(data); but gives warning iodevice not being open. if manually buff.open() , fromdata() produces null image again. without explicitly opening, openmode() automatically set unbuffered | writeonly , works, if open() explicitly unbuffered | writeonly doesn't work. go figure...

How do I create a Java EE container deployable JAR? -

i have main project used standalone batch want move container using ejb timer (using wildfly 8.2). thought building war file timer class , dependencies withing web-inf/lib, doesn't sound elegant solution because isn't web app, doesn't need bound context. it's jar, ejb inside , dependencies (i'm using fat jar) container throws error when deploy it. should use ear? or guys think war file fine? ps: i'm using maven, possible suggestions can take in account. you don't need in war file if it's not web application, although doesn't harms. put in jar file, don't add doesn't have meaning...it can confusing others. @bruno césar pointed out, need package first ejb(s). have @ this ; you'll see ways package them jar, war, ear.

Android Facebook SDK 4.0 - Display username -

i've been having little trouble migrating fb sdk's new version. according documentation, how fetch default user data: graphrequest request = graphrequest.newmerequest( accesstoken, new graphrequest.graphjsonobjectcallback() { @override public void oncompleted( jsonobject object, graphresponse response) { // application code } }); bundle parameters = new bundle(); parameters.putstring("fields", "id,name,link"); request.setparameters(parameters); request.executeasync(); and believe data contained withing jsonobject. however, not know how can access , use user data. any extremelly appreciated! thanks! now facebook sdk 4.0 doesnt return graphuser returns pure json object while working around android app found someof tags. check this {"id":"10000700xxxxxxx","birthday":"xx\/xx\/xxxx","email":"xxxxxx@gmail.com

How to simulate the browser to login in https website using c++ based on Linux? -

everybody,my goal logging in https website , downloading webpage using c++ background service program based on linux. detail needs follow: (1)connect " https://www.space-track.org/auth/login " (2)enter username , password in order login in successful (3)post formdata website (4)downloading webpage. now,my method using mfc::cinternetsession(code follow. in ms-windows),but it's not successful. there must exist problems in codes. hope can me solve problem. maybe can come better solutions using c++ simulate browser based on linux. thank much! url = "https://www.space-track.org/auth/login/"; nport = internet_default_http_port; cstring strheaders = _t("content-type: application/x-www-form-urlencoded"); if (afxparseurl(url,dwsevicetype,strservername,strtarget,nport) == 0) return false; cinternetsession sess; sess.setoption(internet_option_connect_timeout,1000*20); sess.enablestatuscallback(true); chttpconnection* phttpconnect = sess

Capturing image of HTML table using Python -

i know 1 can generate html csv, how turn html image using python? you can use python-webkit2png project convert html code image using webkit engine (same chrome uses)

c# - Variables are not recognized on Master partial class -

its old project, .net 3.5, i'm trying update 4.5. i'm trying use master pages: nzhos3colnew.master <%@ master language="c#" autoeventwireup="true" codefile="nzhos3colnew.master.cs" inherits="nzjobfinder.nztemplatemasterpage" %> nzhos3colnew.master.cs namespace nzjobfinder { public partial class nztemplatemasterpage: system.web.ui.masterpage { protected void page_load(object sender, eventargs e) litloginstyle.text = "style='height:10px;padding-top:5px;width:70px;left:890px;top:10px;'"; but, when building, get: error 24 name 'litloginstyle' not exist in current context c:\nzjobfinder\app_master\nzhos3colnew.master.cs 25 21 nzjobfinder any helps here? missing? thanks.

swift - Sprite follows touch -

i trying sprite follow finger around when touch screen. have searched around , found works seems little process; beginner i'm not sure if best. let player = skspritenode(imagenamed: "player") var location = cgpoint(x: 0, y: 0) var touched: cgpoint? = nil override func didmovetoview(view: skview) { backgroundcolor = skcolor.whitecolor() player.position = cgpoint(x: size.width * 0.5, y: size.height * 0.25) addchild(player) runaction(skaction.repeatactionforever( skaction.sequence([ skaction.runblock(addenemy), skaction.waitforduration(0.25) ]) )) } override func touchesbegan(touches: nsset, withevent event: uievent) { touched = true touch: anyobject in touches { location = touch.locationinnode(self) } } override func touchesmoved(touches: nsset, withevent event: uievent) { touch: anyobject in touches { location = touch.locationinnode(self) } } override func touchesended(touches: nsse

Can not create text file with php -

i'm new php. i'm trying write small script writes small text file , reads same file , show contents on screen. script dies, , error message "error: can not create file!" i'm running code in home centos sandbox. <?php ////////////////////////////////////////////////////////////// // http://inpics.net/tutorials/php/files3.html // php date function: // http://www.w3schools.com/php/func_date_date.asp // date("d/m/y h:i:s") ////////////////////////////////////////////////////////////// // define filename $myfilename = (date("dmy").".txt"); print "<p>filename: '<b>$myfilename</b>'</p>"; // define text $mytext = 'some text... blah, blah, blah...'; print "<p>this text should on file:'<b>$mytext</b>'</p>"; ////////////////////////////////////////////////////////////// // open file write: // $handle = fopen($myfilename, 'w') or die(

unity3d - How I can instantiate various prefabs in a given time for each? -

i developing video game guitar hero type. finished everything. need configure notes. i have script instantiates me prefab (a note) , generates time time. there not 1 note. there 23 , wonder if possible instantiate each different timers , within same script. for example, first note should generated 1 second , second 3 seconds. this script have: #pragma strict var yellownote: gameobject; var time = 1; function start () { while (true) { yield waitforseconds (time); instantiate (yellownote, transform.position, quaternion.identity); } } you define array of times you'd between each instantiation. then, iterate through array loop , waitforseconds inside loop.

r - Is there anyway to document S4 class and its constructor separately using Roxygen2 -

i trying design s4 class own initialization method , separately document them roxygen2. assuming class defined as: #' classa #' @name classa-class #' @rdname classa-class ######## @aliases null #' @exportclass classa classa <- setclass(class = "classa", slots = list(member = "any")) with initialization method: #' constructor #' @name classa #' @rdname classa #' @export classa setmethod("initialize", "classa", function(.object, x) { .object@member = x return(.object) }) after compiling package roxygen2. got 2 .rd files 3 page: classa-class: classa classa: classa classa: constructor both class?classa , ?classa show classa-class page. want hope class?classa lead classa-class: classa while ?classa lead classa: constructor . so, question how separate class documentation , constructor documentation roxygen2? thank help. ( i understand roxygen2 put alias

python - Passing persistent values into a class -

using python 2.7 , tkinter in linux mint 'mate' 17 environment i'm new oop , don't understand how pass persistent values class instance; in code "global not defined" error generated when use pin_id @ lines 20 , 22: 1 #!/usr/bin/env python 2 import tkinter tk 3 4 root = tk.tk() 5 6 class cbclass: 7 def __init__(self, pin_id): 8 self.cb_txt=tk.stringvar() 9 self.cb_txt.set("pin " + pin_id + " off") 10 self.cb_var = tk.intvar() 11 cb = tk.checkbutton( 12 root, 13 textvariable=self.cb_txt, 14 variable=self.cb_var, 15 command=self.cbtest) 16 cb.pack() 17 18 def cbtest(self): 19 if self.cb_var.get(): 20 self.cb_txt.set("pin " + pin_id + " on") 21 else: 22 self.cb_txt.set("pin " + pin_id + " off") 23 24 c1 = cbclass("8") 25 c2 = cbclass("e") 26 root.mainloop() you want save

How to manually give control of my Twitter account to my application? -

i'm dealing 2 separate twitter accounts. i want give access of 1 account other account holds twitter application/api key. this tutorial same account owner of api: https://dev.twitter.com/oauth/overview/application-owner-access-tokens currently gives access token , access token secret of 1 account. how can info account can tweet both accounts via api?

Multiple clickable items in ListView inside android widget -

i'm trying make listview in widget there multiple clickable items in each row. example, if each row has data containing link, 1 button in row open link , share link. sample code: widget layout <linearlayout...> <textview../> <listview id="list_view" /> </linearlayout> each list row in listview has: <linearlayout id="listrowparent"> <textview../> <button id="openbtn"/> <button id="sharebtn"/> </linearlayout> i'm able set onclick of each row using remoteviews.setpendingintenttemplate(r.id.list_view, *<pendingintent>*); //in onupdate and remoteview.setonclickfillinintent(r.id.openbtn, *fillintent*); // in adapter which works fine, can't have setpendingintenttemplate list row button doing remoteviews.setpendingintenttemplate(r.id.sharebtn, ); since nothing happens on clicking button if this. question: i'

Android: Cannot resolve method 'findFirstVisibleItemPosition()'? -

i'm trying write code endless scroll on recycler view. snippet gives me compiler error: @override public void onscrolled(recyclerview recyclerview, int dx, int dy) { visibleitemcount = mlayoutmanager.getchildcount(); totalitemcount = mlayoutmanager.getitemcount(); pastvisiblesitems = mlayoutmanager.findfirstvisibleitemposition(); if ( (visibleitemcount+pastvisiblesitems) >= totalitemcount) { log.v("...", "last item wow !"); } and declaration i've written before is: mlayoutmanager = new linearlayoutmanager(this); and mlayoutmanager object of class recyclerview.layoutmanager mlayoutmanager object of class recyclerview.layoutmanager wrong, should use android.support.v7.widget.linearlayoutmanager mlayoutmanager , so: mlayoutmanager = new linearlayoutmanager(this); //above 'linearlayoutmanager' //'android.suppo

Displaying content in tabs on Onsen UI page -

i building single page app on onsen ui various pages defined. 1 of pages shows schedule 2 day event , it's logical have tabs dates , respective daily content. how in onsen ui considering tutorials i've seen on tabs assume main website navigation use tabs not case. here's code i'd been tinkering with <ons-template id="schedule.html"> <ons-page> <ons-toolbar> <div class="left" style="line-height: 44px"> <ons-back-button>back</ons-back-button> </div> <div class="center">schedule</div> </ons-toolbar> <div style="text-align: center"> <ons-tabbar position="top"> <ons-tab page="dayone.html"> <p>day one</p> </ons-tab> <ons-tab page="daytwo.html"> <p>day two</p> <

Complicated sorting based on date Yii2 -

i creating search in yii2. $q = $_get['q']; $dataprovider = new activedataprovider([ 'query' => company::find() ->where('name :name', [':name' => "$q%"]) ]); return $this->render('index', ['dataprovider' => $dataprovider,]); i have 2 date properties (valid payment , to): from_date , to_date i need display result starting 1 has valid payment first. how should qyery if want display companies valid payment first? should sort on name asc.. i have function value in model, not query: public function getvalidpayment() { $today = date("y-m-d"); return (($this->from_date <= $today) && ($today <= $this->to_date)); } this yii2 thanks! edit: clarify need: query companies based on name (name :name') priority 1 has valid , date (from_date , to_date) display rest not have valid , date (both groups in query should sort on name asc). maybe shoul

c# - Show selected value in listpicker wp8 -

i want show selected value in listpicker. location": [ { "id": "208", "name": "canberra" }, { "id": "209", "name": "regional act" }, { "id": "67", "name": "nsw" }, { "id": "134", "name": "cbd, inner west & eastern suburbs" } ], i'm convert data list.now want show selected location listpicker foreach (var seletedloc in _lst) { lstlocations.selecteditem = seletedloc ; } but error .selecteditem must set valid value sample xaml <grid loaded="contentpanel_onloaded" x:name="contentpa