Posts

Showing posts from 2011

c - How to get mysql to throw an error on update for no rows matched? -

i want know when update query reports 0 rows matches. i'm using libmysql . here's code i'm using: char query[300] = {0}; snprintf(query, 300, "update `my_table` set name='%s' id=%d", name, id); if (mysql_query(db, query)) { printf("error!\n"); } essentially need know whether or not there match id . know can check doing select, there way? check mysql_affected_rows . return number of modified rows last query. however, may return rows modified. if want return matched row, have specify client_found_rows in mysql_real_connect . check same page details.

Android how to add activities to backstack like fragments -

i have multiple activities. want add them backstack, when open activities 1 one fragments. possible activities add them in backstack fragments. useful. thanks! just launch new activities on top of activity , not finish current activity. android maintain activity stack of own. return previous activity once finish current activity

django - How to use Telegram API to authenticate users? -

i'd use telegram api authenticate users django website, tchannels.me does. i've read docs authorization not figure out how implement api. appreciate if can provide useful hints, or better, concrete example. there project in github tlsharp can figure out how it's work good luck !!!

validation - Allowing only digits in aui:form, with Liferay portlet-model-hints.xml -

my portlet-model-hints.xml below stipulates quantity required, works fine. want stipulate quantity must made of digits: <model-hints> <model name="com.example.model.myentity"> [...] <field name="order" type="long"> <validator name="required" /> <validator name="digits" /> <----- not work </field> [...] </model> </model-hints> problem : adding <validator name="digits" /> makes text field disappear. is there problem in syntax? should validation in jsp instead? way here jsp form add/edit entity: <aui:form action="<%= editmyentityurl %>" method="post" name="fm"> <aui:fieldset> [...] <aui:input name="quantity" /> [...] </aui:fieldset> [....] </aui:form> [workaround, still...

List of libraries needed for http, REST API development in Android -

i newbie in developing web services android. needed know list of libraries needed http, rest api support in android client along use case. helpful. volley networking library best provides concurrent request initiation , cancellation features. has documentation on https://developer.android.com/training/volley . further information on library best. please go through following links https://www.quora.com/what-is-the-best-library-to-make-http-calls-from-java-android http://instructure.github.io/blog/2013/12/09/volley-vs-retrofit/ comparison of android networking libraries: okhttp, retrofit, , volley hope helps.

How to manually deploy 3rd party utility jar for Apache Spark cluster? -

i have apache spark cluster (multi-nodes) , manually deploy utility jars each spark node. should put these jars to? example: spark-streaming-twitter_2.10-1.6.0.jar i know can use maven build fat jar including these jars, deploy these utilities manually. in way, programmers not have deploy these utilities jars. any suggestion? 1, copy 3rd party jars reserved hdfs directory; example hdfs://xxx-ns/user/xxx/3rd-jars/ 2, in spark-submit, specify these jars using hdfs path; hdfs: - executors pull down files , jars hdfs directory --jars hdfs://xxx-ns/user/xxx/3rd-jars/xxx.jar 3, spark-submit not repleatly upload these jars client: source , destination file systems same. not copying hdfs://xxx-ns/user/xxx/3rd-jars/xxx.jar

.net - How do I look at the IL for my code? -

i have c# .net code , out of curiousity i'd @ il generated it. how can achieve this? you use ildasm.exe utility that's built .net framework. example in visual studio command prompt type following: ildasm /output:foo.il foo.dll and enjoy beauty of il contained in assembly.

asp.net - Not valid json in c# even though it should be -

i want parse json string: string downloadedstring = "[ { \"type\" : 2, \"value\" : \"las terrenas\", \"label\" : \"las terrenas, (dom. republik halbinsel samana, karibik)\", \"regioncode\" : \"kb\", \"zielcode\" : \"azs\", \"ortcode\" : \"67\", \"giatacode\" : null, \"chaincode\" : null}, { \"type\" : 2, \"value\" : \"las caletillas\", \"label\" : \"las caletillas, (teneriffa, kanaren)\", \"regioncode\" : \"ka\", \"zielcode\" : \"ten\", \"ortcode\" : \"830\", \"giatacode\" : null, \"chaincode\" : null}, { \"type\" : 2, \"value\" : \"las tricias\", \"label\" : \"las tricias, (la palma, kanaren)\", \"regioncode\" : \"ka\", \"zi...

c++ - Cannot move virtual function outside header -

i have c++ class header defines many functions inline. want move these functions outside header , seperate .cpp file speeden compile. although can move normal functions seperate file , keep function deceleration in header, when try move virtual functions .cpp following error: error 2 - error c2723: 'virtual' storage-class specifier illegal on function definition how do that? function follows: virtual void soundmixersub::setfilters(const mixerfilter& f) { .... } as says, can't have virtual on function definition outside class, per §7.1.2: the virtual specifier shall used in initial declaration of non-static class member function keep virtual on declaration , remove definition. in header file: class soundmixersub : ... { // ... virtual void setfilters(const mixerfilter&); // ... }; then in implementation file: void soundmixersub::setfilters(const mixerfilter& f) { // ... }

java - @BatchSize a smart or stupid use? -

first i'll explain how understood , use @batchsize : @batchsize made in order load relations of objects in batch, making less sql request database. specially usefull on lazy @onetomany relations. however it's useful on lazy @onetoone relation , @manytoone : if load list of entities database , ask load lazyed @*toone entity, load entities batch if use test load relation of 1st entity of list. note if want tests : show if entities not loaded : instance if have list of user manager , list users, when access manager, no request triggered since it's loaded. the drawback see on method if load list of item database use part of it. post-filtering operation. so let's main point. let's assume make never post-filtering-like operations if it's makes me native sql queries or use dto objects multiselect criteria query , on. am right consider can @batchsize every lazyed relations after having think using eager loading / join , choose lazy relation ? ...

javascript - How to register setInterval without the delay without using any function as I need it to run 1st time -

var interval = setinterval(function(){alert("i alive.")},delay) i want register setinterval explicitly want run interval after every delay time if page in have written destroyed. works fine if delay 5 minutes , wait till setinterval registered first time if change page alerts. if change page before delay time dont alert never registered @ all. there way can directly register setinterval load page. have tried putting document ready? when page loads itll run straight away; var interval; $(document).ready(function) { interval = setinterval(function(){alert("i alive.")},delay); });

parsing - PHP Parse/Syntax Errors; and How to solve them? -

Image
everyone runs syntax errors. experienced programmers make typos. newcomers it's part of learning process. however, it's easy interpret error messages such as: php parse error: syntax error, unexpected '{' in index.php on line 20 the unexpected symbol isn't real culprit. line number gives rough idea start looking. always @ code context . syntax mistake hides in mentioned or in previous code lines . compare code against syntax examples manual. while not every case matches other. yet there general steps solve syntax mistakes . references summarized common pitfalls: unexpected t_string unexpected t_variable unexpected '$varname' (t_variable) unexpected t_constant_encapsed_string unexpected t_encapsed_and_whitespace unexpected $end unexpected t_function … unexpected { unexpected } unexpected ( unexpected ) unexpected [ unexpected ] unexpected t_if unexpected t_foreach unexpected t_for unexpected t_while unexpected t_do ...

ANSI C work with 2dim array throught pointers -

long long time ago i've played c lot forgot everything. trying solve easy tasks , failed. i'd write function takes 2dim array or char* , print it. code buggy , not understand why. understand products pointer 2dim array, increasing i * sizeof(char**) pointer sub-array, , increasing sub-array pointer pointer char block. seems code looking different memory block. about products array - know has n rows , 2 columns. #include <stdio.h> #include <string.h> void print(char*** products, size_t rows, size_t cols) { size_t i; for(i = 0; < rows; i++) { printf("col1: '%s. col2: %s'\n", (products + * sizeof(char**)), (products + * sizeof(char**) + sizeof(char*)) ); } } int main(void) { const char* a[][3] = {{"abc", "1"}, {"def", "2"}, {"ghi", "3"}}; print((char***)a, 3, 2); return 0; } you've mixed regard ...

php - Product and Sizes symfony2 doctrine example -

i'm new symfony2 , i'm building first online store it. have products , want add product sizes, 1 product can have many sizes , 1 size can have many products. example: 2 products cat have 'm' size. class product { ... /** * @orm\manytomany(targetentity="size", inversedby="products", cascade={"persist", "merge"}) * @orm\jointable(name="sizes") */ private $sizes; } //in file class size { /** * @orm\manytomany(targetentity="product", mappedby="sizes") */ protected $products; } productcontroller.php ... ->add('sizes', collectiontype::class, [ 'entry_type' => sizetype::class, 'label' => 'sizes', 'allow_add' => true, ]) ... sizetype.php public function buildform(formbuilderinterface $builder, array $options) { $repo = $...

oracle11g - How to create a scheduler job in oracle 11g with time window -

how create scheduler job stored procedure run every seconds monday till friday , 10 20 clock? instead of relaunching job every second make more sense have permanent background task polls relevant table once per second. use dbms_lock.sleep(1) achieve necessary wait. (access dbms_lock not granted default need dba grant execute privileges user.)

Running python commands in solaris os -

i have 1 python file (abc.py) include several commands make directory, copy commands. want execute such that,whenever hit command example abc --makedir on console, should make directory. makedir function written in abc.py. rename abc.py abc . make executable: chmod +x abc then add @ first line of script: #!/usr/bin/python from command line (if abc in python path): #abc to create directory said , should parse arguments passed python script. for example: import sys if len(sys.argv)>1: if sys.argv[1] == '--makedir': makedir() for more informations @ link what's best way grab/parse command line arguments passed python script?

scala - documet microservice built using akka-http with swagger -

i trying build microservices design first approach , using akka-http(scala) 2.4.1. design-first, imho, swagger used. couldn't find boilerplate implementation how swagger works akka-http. kindly suggest, how proceed? i found thread https://github.com/akka/akka/issues/16591 talks extent, couldn't find conclusion / approach take. also, there seems 1 not maintained version of library https://github.com/tecsisa/akka-http-swagger in swagger community, found thread indicating use swagger-inflector ensuring implementation adhering swagger spec developed, seems blend java , not scala.

osx mavericks - Load Error when requiring taglib-ruby -

i'm trying use ruby wrapper gem taglib play around id3 tags in practice program. i'm getting load errors regarding requiring of taglib ruby gem. i've installed gem project via rubygems , requiring gem stated in number of posts: require 'taglib' these software versions i'm working with: ruby 2.0.0p481 taglib-ruby (0.7.1) taglib-1.9.1 i'm on mac mavericks 10.9.5, using rubymine ide. i'm not sure if installation correct taglib (the original, not ruby wrapper). used homebrew download .tar.gz file , unzipped this. taglib 1.10 folder sitting in local downloads folder - should placed somewhere else? as mentioned, i'm requiring 'taglib' @ top of .rb file. error i'm getting when trying run file is: 'require': cannot load such file -- taglib (loaderror) i'm pretty new ruby , so else need clarify, please ask. appreciated, lot. when require file, file must either in $load_path variable ruby, or explicitl...

qt - QtTextEdit: text content not rendered to QPainter -

Image
i have difficulties rendering context of qtextedit painter (which prints pdf). other widgets correctly printed, text of qtextwidget not. the widgets fine in gui: but text of qtextwidget not printed pdf: the code quite simple. perhaps need add additional flags? text rendered same looks in gui, seperate rendering of text (using textfield->document()->drawcontents(&painter) , not best solution) qtextedit* textfield= ... // textedit correctly visible qprinter printer(qprinter::highresolution); ... qpainter painter( &printer ); textfield->render(&painter, qpoint(), qregion(), qwidget::drawchildren); there nothing wrong code snippet. tried: void mainwindow::on_pushbutton_clicked() { qprinter printer(qprinter::highresolution); printer.setoutputformat(qprinter::pdfformat); printer.setoutputfilename("output.pdf"); qpainter painter( &printer ); ui->textedit->render(&painter, qpoint(), qregion(), qwidget::drawchildren); } ...

mysql - Query with union repeating same subquery into each row -

in db have 5 tables details and, extract details each table, need join witn 3 more tables. need (into result query table) data (always same data each idlite ) , add them each row. wrote query work very slow can't use it. used concat 2 times: first time details each detail table; second time data others tables (these data same). data before concat same (for each idlite ). how can improve query? thinking using variables wasn't able it. ( select t.office, li.year, li.rifnum, 1 idtable, li.idlite, idliteuser, d1.idevent, concat_ws('_', ifnull(d1.typet,''), ifnull(d1.in_date,''), ifnull(d1.out_date,'') ) dett, concat_ws('_', ifnull(li.section,''), ifnull(li.indate,''), ifnull(li.type,''), ifnull(li.subject,''), ifnull(li.dcu_instance,''), ifnull(li.dc_instance,'...

sql - Find minimum value of a table -

i'm looking statement find user minimum value of special field. mean this select id, username, joindate, min(score) table1 actually i'm looking way find user lowest score. to find user lowest score, can simpy sort table , take first record: select top 1 id, username, joindate, score table1 order score

openerp - ODOO 9 the "read more" link is not working in the message? -

when message long odoo displays read more link have click on show full text of message. this link working on local installation on computer (localhost:8069) on remote adress not working (192.168.1.1:8069). in chrome consol of developer tools see msg : " can't find "td.oe-actions" when extending template one2many.listview " in file : web.assets_common.js:2482 i'm using odoo 9, thank help. the problem resolved udating last version of odoo 9 here: https://nightly.odoo.com/9.0/nightly/exe/

java - What am I doing wrong with my while loop? -

i working on program takes in user input (temperatures) , puts in array. confused on last method have create. need go through array , print them least greatest. need use while loop this. the thing is need index stay temperature values. index represents day temperature taken. have method finds lowest value in array , prints along index. can use method have , use in new method? if have no idea how call method while doing while loop. going try , find lowest value , print both value , index , change value "uninitialized" variable can find next lowest value , on. the last method in code "leasttogreatest" attempt @ doing not work. have been working on trying figure out hours on own. have no idea need or how need organize work. here have: public class weather { static int lowesttemp; static int lowestday; private static final int uninitialized = -999; public static void main(string[] args) { // todo auto-generated method stub int[] high = new int[...

python - unittest is not able to discover / run tests -

there some related questions, none apply. this directory tree: » tree abc_backend abc_backend/ ├── backend_main.py ├── funddatabase.db ├── healthcheck.py ├── __init__.py ├── init.py ├── portfolio.py ├── private.py ├── __pycache__ ├── questionnaire.py ├── recurring.py ├── registration.py ├── tests │   ├── config.py │   ├── __init__.py │   ├── __pycache__ │   ├── test_backend.py │   ├── test_healthcheck.py │   └── test_private.py ├── trading.py ├── users.db ├── version └── visualisation.py unittest not able find anything: top » python -m unittest abc_backend ---------------------------------------------------------------------- ran 0 tests in 0.000s ok not within abc_backend : abc_backend » python -m unittest tests ---------------------------------------------------------------------- ran 0 tests in 0.000s ok what have verified: my test methods named ( test_whatever ) my testcases extend unittest.testcase the abc_backend , abc_backend/tests directories hav...

php - Extract Text from HTTP referer -

i using following code show referer link page on website. how can modify code shows part of link. i.e if website url www.example.com/?s=printing want extract printing. , should happen if format www.example.com/?s=aaa , not if format else www.example.com/printing. code: <?php session_start(); if ( !isset( $_session["origurl"] ) ) $_session["origurl"] = $_server["http_referer"]; echo $_session["origurl"] ?> i figured out , following code works: <?php session_start(); if ( !isset( $_session["origurl"] ) ) $_session["origurl"] = $_server["http_referer"]; $mysearchterm = $_server["http_referer"]; $whatiwant = substr($mysearchterm, strpos($mysearchterm, "=") +1); echo $whatiwant; ?>

ubuntu - "fatal error: TProcessor.h: No such file or directory" when trying to install Rhbase package -

everyone, i'm trying install rhbase package, first missing thrift package, solved, shows me error. added tprocessor.h ../lib/cpp/src/thrift/processor/ didn't , shows me same error: in file included hbase.cpp:7:0: hbase.h:10:24: fatal error: tprocessor.h: no such file or directory #include <tprocessor.h> ^ compilation terminated. make: *** [hbase.o] error 1 error: compilation failed package ‘rhbase’ i using rstudio lot you should edit thrift.pc . i used locate thrift.pc , found in /usr/local/lib/pkgconfig/ . edited includedir variable looked like includedir=${prefix}/include/thrift it worked me.

Audio Start Delay For The First Time - ios Swift -

i creating application 5 buttons. when click on each button each audio play. working. problem when click first button audio play 1 second delay(app stuck 1 second) , play. next time clicks button audio play without delay. issue here? i using following code play audio var currentaudio = try? avaudioplayer(contentsofurl: nsurl(fileurlwithpath: nsbundle.mainbundle().pathforresource("sample_audio", oftype: "mp3")!)); currentaudio!.stop() currentaudio!.currenttime = 0 currentaudio!.play(); please me finds issue. you use avaudioplayer's .preparetoplay() method preload player's buffers , increase avaudioplayer's performance (faster start). the idea prepare player time before playing it: currentaudio?.preparetoplay() then later, in play function, start immediately: currentaudio?.play()

Disabling interrupts on TX pin on Arduino Mega 2560 -

i'll start telling reference on function serialevent not documented arduino. https://www.arduino.cc/en/reference/serialevent due lack of information i've misunderstood how function works. have arduino mega 2560 comes 4 serial inputs/outputs, , have own serialeventx function (where x = {'',1,2,3}). i've communicated esp8266 module, sends , receives information once client connected it. using serialevent1 (1 because it's connected rx1 , tx1) want serialevent1 called when data incoming, called whenever use serial1.write(msg), means when message being sent. #define debug_esp8622 1 #include <esp8622.h> #include <string.h> #include "common.h" #include <stdlib.h> wifi esp = wifi(); //here serial1.begin(115200) happens void setup() { serial.begin(9600); //first of serial debugging serial.println("starting"); while(!esp.sreachable()); //works serial.println("esp found"); while(!esp.ssetmode(1)); ...

python - ginput Not implemented Error -

in project, need extract several points in pixel coordinate in order transform points world points. every time, i'm using ginput function in spyder (python 2.7), got following error. example of code given below: import matplotlib.pyplot plt import numpy np import os os.chdir(r'my path') rgb = io.imread('myphoto.jpg') plt.figure(1) pylab.imshow(rgb) pylab.show() [x,y] = plt.ginput(5) the error in below: file "c:\python27\lib\site-packages\matplotlib\pyplot.py", line 592, in ginput return gcf().ginput(*args, **kwargs) file "c:\python27\lib\site-packages\matplotlib\figure.py", line 1576, in ginput show_clicks=show_clicks) file "c:\python27\lib\site-packages\matplotlib\blocking_input.py", line 291, in call blockinginput. call (self, n=n, timeout=timeout) file "c:\python27\lib\site-packages\matplotlib\blocking_input.py", line 114, in call self.fig.canvas.start_event_...

php - DomPDF render of large HTML file results in 500 error -

i'm using recent version of dompdf (0.6.0 beta 3). php version 5.2.17. unfortunately, i'm on shared hosting account , upgrading php , similar actions unavailable. don't have access apache error logs, don't think helpful anyways. i've set memory_limit of php 2048m , max_execution_time 999 . although don't know if they've taken effect. think don't matter because feel dompdf isn't timing out or running out of memory. 500 error seems occur 10 seconds after requesting page, when attempt generate pdf fewer pages script takes longer (12-15 seconds) ends successfully. i have html file that's 72.3kb large, 1 small html table. (in fact, removing page table nothing problem.) pdf should result in 35 pages. after lots , lots of digging found error occurs on 30th - 31st page, on following line of code in page_frame_reflower.cls.php inside reflow function: // render page $this->_frame->get_renderer()->render($child); when ech...

javascript - Assign value returned by Http subscribe method in Angular2 -

i have issue when call webservice in angular2. variable this.arc empty because function get() asynchronous , return directly variable before webservice's response. i don't know how handle this. saw informations defer think not best way. thanks ! getarcs (lat,lng) { var url = "http://localhost:8081/api/v1/arcs?lat="+lat+"&lng="+lng; this.arcs = []; /*var options = new requestoptions({ headers: new headers({ 'content-type': 'application/json;charset=utf-8' }) });*/ this.http.get(url) .subscribe( (data: any) => { json.parse(data._body).foreach(arc => { //console.log(new arc(arc)); this.arcs.push(new arc(arc)); //add arcs }); console.log("send"); }, error => { console.log("error during http request"); ...

excel - Delete set number of characters following the first character -

i have dummy emails long. want shorten them don't want delete first parenthesis. "est@scelerisque.ca" "fermentum@fringillacursus.edu" "adipiscing@arcuvivamussit.com" "vitae.aliquet@sed.edu" "magna.tellus@nullamnisl.com" "placerat.eget@purusnullam.org" is possible me delete example first 3 letters after (") , next 3 letters after @ , stop @ dot? as ask this, sounds complicated. may use same email users since it's dummy data :/ if have 1 email in each cell, can create excel formula convert email values you. delete 3 letters after ": =char(34) & mid(a1, 5, len(a1)) (using result of previous formula in b1): skip 3 letters after @: =mid(b1, 1, find("@", b1)) & (mid(b1, find("@", b1)+4, len(b1))) (using result of previous formula in c1): stop @ dot (also keep " @ end): =mid(c1, 1, find(".",c1)-1 ) & char(34)

javascript - Variable in place for x does't work in transit.js -

i using transit.js , have following lines of code: var axis = math.floor(math.random() * 2); axis = genxy(axis); if($(this).hasclass(btn_classname)) { $(this).transition({ axis : '100px' } , function(){ $(this).addclass('active'); $(this).transition({ axis : 0 , duration : 2000 }); }) } the genxy function below: var xy = ['x' , 'y']; function genxy(no) { return xy[no]; } now ran below simple test on single element(in devtools): var axis = x; $('.gridbox .large').eq(2).transition({ x : "100px" }); the above line of code works perfect , i.e. transitions element 100px , if replace x axis , variable indeed x , code looks below: var axis = x; $('.gridbox .large').eq(2).transition({ axis : "100px" }); the above line does't work . why work ? afterall axis x , can explain ? actually, putting key object can't done that: var axis = x; $('.gr...

javascript - initialize owl carousel on click function of tab -

i using tab structure owl slider , title user wanted unique url of each tab clicked, changed click function. here, unable process slider.it won't work. html: <ul id="mytab" class="nav nav-tabs"> <li class="active" id="chhimi-gurung"> <a href="#tab-0" data-toggle="tab" rel="chhimi-gurung">chhimi gurung</a> </li> <li class="" id="subha-shrestha"> <a href="#tab-1" data-toggle="tab" rel="subha-shrestha">subha shrestha </a> </li> </ul> <div id="mytabcontent" class="tab-content" > <div class="tab-pane fade active in" id="tab-0"> <h3>chhimi gurung</h3> <div class="owl-carousel team-image-slider" id="team-image-slider-0"> <img src="up...