Posts

Showing posts from June, 2013

jenkins - Python: How do you use lxml to parse xml tags with periods? -

i attempting parse jenkin's job xml files using lxml module python. looks this: <triggers> <hudson.triggers.timertrigger> <spec>h h(6-21)/3 * * *</spec> </hudson.triggers.timertrigger> i using lxml's handy objectify module, gets confused when try this: root.triggers.hudson.triggers.timertrigger.spec = 'something' i attributeerror: no such child: hudson . of course there's no attribute named hudson! how 1 work goofy piece of xml this? for additional context, here code: from lxml import objectify import jenkins j = jenkins.jenkins('http://local.jenkins.instance') xml = j.get_job_config('job_name') root = objectify.fromstring(xml) root.triggers.hudson.triggers.timertrigger.spec = 'something' it make sense triggers.hudson.triggers.timertrigger interpreted trying access <timertrigger> element in following structure, hence complained hudson child element not found when gi

java - Creating an overlay activity -

i trying create overlay activity sitting in corner of screen taking small portion of screen, while rest of screen interactive tap on displaying on rest of screen. far unsuccessful in obtaining goal. have added these properties window don't seem work. hello.xml: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="50dp" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/tepp" > </relativelayout> what can solve problem? from can remember, 1 activity can active @ given time. while small activity in corner running, other activitys paused , wont able interact them. should try using fragment instead. can have multiple fragments visible @ same time. although believe 1 fragment can active @ given time activity , when click on different fragments, 1 click on becomes active , can interact it. might achieve looking for.

encryption - What SHA2 hash function does Realm dot net use -

on realm xamarin page says realm supports encrypting database file on disk aes-256+sha2 supplying 64-byte encryption key when creating realm. which sha2 hashing function use. sha256? yes, realm uses sha256 validate data integrity. curious difference makes? or curious?

javascript - VueJS: Loop through JSON-object -

i use json , loop through each items using vuejs' v-for . i'm using array store translations of dataset. translations located in data.translations . but happens: http://d.pr.it/1k1yb this source code of template: <!--suppress --> <template> <div class = "uk-form-row"> <span class = "uk-form-label">{{ data.type | trans }}</span> <div class = "uk-form-controls uk-form-controls-text"> <a href = "#{{ data.type }}" data-uk-modal class = "uk-placeholder uk-text-center uk-display-block uk-margin-remove"> <p class = "uk-text-muted uk-margin-small-top">text...</p></a> </div> </div> <div id = "{{ data.type }}" class = "uk-modal"> <div class = "uk-modal-dialog uk-modal-dialog-large"> <ul class = "uk-tab" v-el:t

java - How to get class reference for a generic class -

i new java (coming actionscript 3.0 background) , trying port actionscript code java (as3signals jsignal) i trying class name of generic class in order pass super call. in actionscript 3.0 super(vector.<tilevo>,boolean); the above piece of code pass class references constructor vector of tilevo , boolean. in java doesn't seem work , know doing wrong: super(asvector.class<tilevo>,boolean.class); to write short, how class reference asvector class composed of tilevo objects? thank you! later edit: i realised code not displayed (treated html) posting source code: public signal(class<?>... params) { this.params = params; } i need pass signal class references via constructor. new signal(int.class) example works i need know how can pass signal's constructor class of object of form: asvector<tilevo> i tried asvector.class<tilevo> , doesn't seem work! at compile time, generic type paramete

node.js - How do I make this curl call with nodejs request module -

i able send request browsermob using curl so: curl -x put -d "pageref=car" localhost:9000/proxy/8081/har/pageref . however, inside nodejs using request module. equivalent command using request module? assume request.put(url, data, callback) when try request.put('localhost:9000/proxy/8081/har/pageref', {form: { pageref: encodeuri(browser.platform) + encodeuri(browser.browsername) + encodeuri(browser.version) }}) , get error: invalid protocol @ request.self._buildrequest (/users/dragonite/pixel/node_modules/request/request.js:336:53) @ request.init (/users/dragonite/pixel/node_modules/request/request.js:503:10) @ new request (/users/dragonite/pixel/node_modules/request/request.js:97:8) @ request (/users/dragonite/pixel/node_modules/request/index.js:50:11) @ function.request.put (/users/dragonite/pixel/node_modules/request/index.js:121:27) @ repl:1:10 @ replserver.self.eval (repl.js:110:21) @ interface.<anonymous> (repl.js:239

What is the best practice for a jenkins hearbeat script? -

i have multiple jenkins instances running not have slave/master relationship. best way have them monitor each other , warn admin if 1 instance goes down. current approach using have job on instance triggers job on instance b, in turn checks resources of instance b healthy. instance b performs same trigger process on instance a. setup? best way trigger job , output status? is setup? if works use case, setup; is, don't find tweaking scripts frequently, or being falsely alarmed. there may cases using job queue problematic - e.g. there many jobs execute before one, or long-running ones block heartbeat processed. then, perhaps possible keep 1 job executor free perform jobs heartbeat; 1 (job restrictions) seems fit. additionally, coupling heartbeats sequentially means after first failure, there no more information other nodes in sequence; when instance down, don't know state of instance b. i'd check server monitoring software: nagios , cacti etc. you

cmd - how to move files from sub-folder to folder -

i've got: c:/pics/asf/photos/files (.jpg) c:/pics/dfs/photos/files (.jpg) c:/pics/hgd/photos/files (.jpg) c:/pics/ftg/photos/files (.jpg) .....etc in every "photos" directory more 1 .jpg file i want: c:/pics/asf/files (.jpg) c:/pics/dfs/files (.jpg) c:/pics/hgd/files (.jpg) c:/pics/ftg/files (.jpg) .....etc can me .cmd doing job? best regards @echo off cd c:/pics /d %%i in (.) ( cd "%%i" move photos/*.jpeg . cd.. )

Segmentation Fault (Core Dumped) C++ - Pointers -

i'm pretty new pointers , i'm assigned array doubling task whenever run code segmentation fault(core dumped) error. can @ code , tell me error coming , can fix it? i'm stuck , appreciated. code: int size = length; string *new_array = null; string *tmp_array = new string[50]; for(int k=0; k<50; k++)//initial array copying. tmp_array[k] = wordarray[k]; for(int i=0; i<=1; i++)//array range 0 n-1 { new_array = new string[size*2]; for(int j=0; j<size; j++)//array range 0 n-1 { new_array[j]=tmp_array[j]; new_array[j+size]="empty"; } delete[] tmp_array; //deleting old array size=size*2; } delete[] tmp_

c# - How to check if a state object is of type ICollection -

i use nhibernate interceptor compare values of old state , current state of entity properties of properties of type icollection guide me how check if object of type icollection this code public void onpostupdate(nhibernate.event.postupdateevent @event) { var entitytoaudit = @event.entity iauditable; string path = path.combine(appdomain.currentdomain.basedirectory, "auditlog.txt"); using (streamwriter sw = file.appendtext(path)) { (int = 0; < @event.oldstate.length; i++) { string propertyname = @event.persister.propertynames[i]; if (@event.oldstate[i] != null) { if (!@event.oldstate[i].equals(@event.state[i])) { sw.writeline("the value of "+ propertyname + " has been changed " + @event.oldstate[i] + " " + @event.state[i]); } }

shell - BASH - After 'wait', why does 'jobs -p' sometimes show 'Done' for a background process? -

the short version: bash script has function. this function launches several instances (a maximum of 10) of function in background (with & ). i keep count of how many still active jobs -p | wc -w in loop. when i'm done loop, break . i use wait ensure processes terminate before continuing. however, when check count (with jobs -p ) sometimes find this: [10] 9311 done my_background_function_name $param how can wait proceed when launched child-processes have terminated , jobs list empty? why jobs shown "done" , not? clearly, knowledge of how jobs works deficient. :) thanks.

java - Sql2o with postgres, No results were returned by the query -

the other questions i've found title deal non-select queries. i'm using java 8, sql2o 1.5.4, , postgresql 9.5.3. my userservice looks like: public class userservice { private final pgservice pgservice; public userservice(pgservice _pgs) { this.pgservice = _pgs; } public user getuserbyid(int id) { string sql = "select id, firstname, lastname, email, team_id teamid users id = :id;--"; user user; try (connection c = pgservice.getconnection()) { user = c.createquery(sql) .addparameter("id", id) .executeandfetchfirst(user.class); } return user; } } my user looks like: public class user { private int id; private string firstname; private string lastname; private string email; private string passhash; private int teamid; /*getters , setters*/ } my test looks like: public class userservicetest { pr

java - cast custom content to the chromecast -

(apologies abstract question) i trying develop simple android application chromecast library. android application streams custom content. custom content can list or list. i looked few examples online , 1 followed : https://www.binpress.com/tutorial/building-an-android-google-cast-sender-app/161 noticed here content want cast created via: mediainfo.builder , takes string parameter url of video . ( although documentation says content id actually). i not finding correct direction needs looked able cast list screen. edit: possible cast application chromecast thanks you might want take @ remote display apis in cast sdk; allows render view, application, in chromecast; content of view you. mediainfo tailored toward playback of media (video/audio) content.

c++ - SHGetFolderPath Deprecated: What is alternative to retrieve path for Windows folders? -

the shgetfolderpath() function deprecated beginning windows vista: http://msdn.microsoft.com/en-us/library/bb762181%28v=vs.85%29.aspx what alternative way retrieve path application folder in windows? shgetfolderpath(null, csidl_common_appdata, null, 0, szpath) aside that, why errors when using function: error 1 error c2065: 'csidl_common_appdata' : undeclared identifier error 2 error c3861: 'shgetfolderpath': identifier not found the alternative described in documentation link. namely shgetknownfolderpath . however, shgetknownfolderpath available on vista or later. if use load time linking, , run program calls shgetknownfolderpath on xp, program fail start. problem if wish support xp. now, switch run time linking of shgetknownfolderpath . carry out version check before call it, , if function not available, fall shgetfolderpath . personally, not let deprecation worry excessively. microsoft renowned maintaining backwards compatibili

mysql - PHP session doesn't update when user logs ou -

i have website in php uses mysql create accounts , allow users log in , log out. working fine. when users logs in, changes enum value, "loggedin" 1 meaning logged in. when log out, doesnt change 0. have logout hyperlinking logout php , code of logout php. <?php // create connection include_once 'credentials.php'; $conn = new mysqli($db_hostname, $db_username, $db_password, $db_database); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); }else{ session_start(); session_destroy(); $sql = ("update users set loggedin = '0' id = '$userid'"); mysqli_query($conn, $sql); header("location: ../index.php"); exit; } ?> but doesnt seem working. also, on logged in one, when user logs in first time, loggedin status changed in mysql website not show unless user logs out, in again. you have check update query in mysql application (eg: phpmyadmin)

svn - How to exclude .cs files during checkout in Jenkins? -

is there way exclude .cs files while checkout svn in jenkins? need fetch files needed release not files used in development. workspace should contains design files , dll. several options come mind: specify subversion repository url in such way check out, specific release directory, such http://svn.repo.org/repos/project/release/ . use workspace cleanup plugin remove unnecessary files. try out proposed feature subversion plugin supposedly implements checkout using sparse checkout ( be aware not official release , can contain bugs/regressions ).

PostgreSQL function round and JPA/Hibernate -

i have query executed java application this: query query = getentitymanager().createquery(hql); the query looks this: string hql = "select * table round(column1, 3) = round(parameter, 3)"; here column1 of type double . value holds 143.02856666 . need retain value is, business logic need round , compare. the initial database configured h2 , worked fine. database has been changed postgres , query errors out. error: function round(double precision, integer) not exist hint: no function matches given name , argument types. might need add explicit type casts. the round() function in postgres takes numeric datatype , needs cast. the below query works fine if executed directly in postgres console. select * table round(cast(column1 numeric), 3) = round(cast(parameter numeric), 3); the same java application errors out. java.lang.illegalargumentexception: org.hibernate.queryexception: not resolve requested type cast : numeric also tried query qu

android - Retrieve Firebase Data saved with push() -

i have firebase database.when im saving data used push() generate auto increment key. now db this recipe{ categories{ -kjxzi0jbe1sy5ccfgqf{ name: "sri lankan" } } } when im retrieving data got error w/classmapper: no setter/field -kjxz53rlic4rzpvjk48 found on class com.kosala.uyamu2.data_category this data_category bean public class data_category { string name; public data_category() {} public data_category(string name) { this.name = name;} public string getname() { return name;} public void setname(string name) { this.name = name;}} this retrieving data mdatabase.child("recipe").child("categories").addlistenerforsinglevalueevent(new valueeventlistener() { @override public void ondatachange(datasnapshot datasnapshot) { data_category data = datasnapshot.getvalue(data_category.class);

How to check the existence of a server side file on my website server without actually editing it with javascript only. -

this question has answer here: synchronous xmlhttprequest on main thread deprecated error 2 answers i have found many questions on topic including stackoverflow. none of them working me. have compiled following existing answers: function doesfileexist(urltofile) { var xhr = new xmlhttprequest(); xhr.open('head', urltofile, false); // => error message on line xhr.send(); if (xhr.status == "404") { return false; }else { return true; } } then use function call web server follows: var thesource = "myurl"; var result = doesfileexist(thesource); if (result == true) { // yes, file exists! console.log('file exists:', thesource); } else { // file not exist! console.log('file not exist:', thesource); } the error message this: synchronous xmlhttprequest on main thread deprecate

redirect stdout/stderr to function in C -

i want redirect stdout , stderr function , write simple code. fprintf ok when use printf without \r, stream passed terminal! #include <stdio.h> static ssize_t file_write(void *c, const char *buf, size_t size) { file * pfile; pfile = fopen ("output.txt","w"); fprintf(pfile, "%s", buf); fclose (pfile); return size; } void redirect() { file *stream; stream=fopencookie(null, "w", (cookie_io_functions_t) {(ssize_t) 0, file_write, 0, 0}); setbuf(stdout, null); stdout = stream; setbuf(stderr, null); stderr = stream; } int main() { redirect(); fprintf(stderr,"1-stderr test\n"); fprintf(stdout, "2-stdout test\n"); printf("3-printf r test\n\r"); printf("4-printf without r test\n"); return 0; } file "output.txt": 1-stderr test 2-stdout test 3-printf r test terminal output: $ ./sample 4-printf without r test you can't "r

Android : Unfortunately, MyApp has stopped -

Image
when run application on avd, gives error: unfortunately, myapp has stopped. when see log cat, looks this: log cat first section log cat second section here mainactivity file: package com.ghani.myapp; import android.app.activity; import android.os.bundle; import android.view.menu; import android.view.menuitem; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); if (id ==

delphi - How can I remove the additional icon on the task bar when I use both VCL and FMX? -

this question has answer here: how hide firemonkey application button taskbar (xe4)? 4 answers if create delphi vcl application default have 1 vcl form , if run application there 1 icon on task bar. after if add fmx form it, can have both forms , use them both. in task bar when application running there 2 icon. there anyway remove 1 title project name , keep other main form? i using delphi xe8. i found answer. funny. 2 days searching , no success found answer after posted question. answer myself maybe useful person. i found code on page https://github.com/vintagedave/firemonkey-container/blob/master/parnassus.fmxcontainer.pas function enumwindowcallback(hwnd: hwnd; lparam: lparam): bool; stdcall; const fmxclassname = 'tfmappclass'; var processid : dword; classname : string; classnamelength : nativeint; begin // xe4 (possibly others) s

Sqoop not loading CLOB type data into hive table properly -

i trying use sqoop job importing data oracle , 1 of column in oracle table of data type clob contains newline characters. in case, option --hive-drop-import-delims not working. hive table doesn’t read /n characters properly. please suggest how can import clob data target directory parsing characters properly.

user interface - Easy way to create GUI in python -

this question has answer here: is there gui design app tkinter / grid geometry? 3 answers i have tried using tkinter not easy create attractive gui application.is there application or online website can use drag , drop approach create gui interface in python.or other easy way reply intutive references or tutorial if possible. pyqt seems option here. it's cross platform gui framework comes qt designer, applicatiom let's build guis dragging , dropping widgets on canvas. here's basic tutorial can follow. there's series of videos included imformation on how download , install pyqt

symfony 1.4 - .htaccess load from sub folder but keep on showing main domain -

i have install has web folder has website stored in this. how can make domain load folder within public_html folder. the domain like: sub.domain.co.nz don't put entire symfony project under public_html folder - cause of project files accessible on web, including .yml files include sensitive information database passwords! put symfony project files in folder not web accessible. configure web server documentroot points path of web folder of symfony project, , modify paths of aliases.

jquery - how to enlarge an element and show text on clicking -

Image
i had image background, , add elements on (circular points) in positions how make points on clicking, enlarge , show text !? if not possible css wonder if jquery might help. here jsfiddle css #container { height: 400px; width: 400px; position: relative; } #image { position: absolute; left: 0; top: 0; } #point { cursor: pointer; outline: none; z-index: 0; position: absolute; width: 20px; height: 20px; border-radius: 20px; background: rgba(26, 26, 26, 0.85); border: 5px solid #7fcff7; } html <div id="container"> <img id="image" src="http://s24.postimg.org/jnd9wc0n9/m7a_uku_s.png"/> <p id="point" style="top:15%;left:35%"></p> </div> do need ? <html> <head> <style> #container { height: 400px; width: 400px; position: relative; } #image { position: absolute; left: 0; top: 0; } #point {

canvas - Javascript : generate random number function and push into array -

i'm trying push random number of bunnies canvas 1~10 in javascript. however, math.random() method doesn't seem working. gives me 1 bunny. doing wrong? var field = []; var randomnum = math.floor(math.random() * 10); field.push(randomnum * new bunny()); function bunny() { ... } it won't give bunnies @ all. randomnum * new bunny() nan 1 , because you're trying multiply object number. if want multiple bunnies, have create them, in loop: var field = []; var randomnum = math.floor(math.random() * 10); (var n = 0; n < randomnum; ++n) { // loop field.push(new bunny()); // creating , pushing } // multiple bunnies function bunny() { // ... } 1 or number, if you've overridden valueof on bunny.prototype , seems unlikely.

javascript - reduce / thottle requestAnimationFrame for Canvas animation -

im creating html5 canvas animations , wish reduce / throttle frame rate. i'm using requestanimationframe method. throttle frame rate, use settimeout. is there better / more efficient way this? // game - animation loop var fps = 5; function step() { settimeout(function() { update(); draw(); window.requestanimationframe(step); }, 1000 / fps); } thanks const fps = 5; const delay = math.ceil(1000 / fps); let last = date.now(); let now; function step () { = date.now(); if(now - last < delay) { return requestanimationframe(step); } last = now; update(); draw(); requestanimationframe(step); } step();

apache - Force https to http redirect except for Wordpress /wp-admin directory -

our https site indexed on google. need redirected http . we're using following code: <ifmodule mod_rewrite.c> options +followsymlinks rewriteengine on rewritebase / rewritecond %{server_port} ^443$ [or] rewritecond %{https} =on rewriterule ^(.*)$ http://www.example.com/$1 [r=301,l] </ifmodule> to redirect https http , , works fine. however, want exclude of wordpress admin https http redirect, i'd keep wordpress admin working on https , added: rewritecond %{request_uri} !^wp-admin taking .htaccess code to: <ifmodule mod_rewrite.c> options +followsymlinks rewriteengine on rewritebase / rewritecond %{server_port} ^443$ [or] rewritecond %{https} =on rewritecond %{request_uri} !^wp-admin rewriterule ^(.*)$ http://www.example.com/$1 [r=301,l] </ifmodule> unfortunately not work, , trying load /wp-admin on https results in many redirects , wordpress dashboard not load. www.example.com redirected many times. would appreciate

c - filePointer automatically progressing in while loop? -

i getting myself fileusage in c. found code explaining reading strings file. curious how mechanically works. while (!feof(fpointer)){ fgets(singleline, 150, fpointer); puts(singleline); } how filepointer know @ end of loop go further line? shouldnt filepointer increased @ end of while loop? cheers a file object stores information open file, including "current positition". each read/write operation increments current position how many bytes read/written. that's why can keep calling fgets (or other input function) in loop , contents, chunk chunk. similarly, can call printf (or other output function) multiple times produce output, , won't overwrite each other. you can , set current file position using ftell , fseek (subject restrictions, e.g. standard c doesn't require ftell return actual byte offset on text files, "magic number" can passed fseek (but i've never seen in real implementation)). (your fpointer points 1 fil

javascript - Syntax Error: Token '21' is an unexpected token at column 12 of the expression [2013-08-28 21:10:14] starting at [21:10:14] -

i'm building simple directive date countdown. i'm stuck on error syntax error: token '21' unexpected token @ column 12 of expression [2013-08-28 21:10:14] starting @ [21:10:14] really don't have clue ho make work here example on jsfiddle http://jsfiddle.net/5eftb/1/ here coffee script since in javascript it's code :( .directive "timer", ["$compile", ($compile) -> restrict: "e" replace: false scope: endtimeattr: "=endtime" controller: ($scope, $element) -> _second = 1000 _minute = _second * 60 _hour = _minute * 60 _day = _hour * 24 timer = undefined showremaining = -> = new date() distance = end - if distance < 0 clearinterval timer setexpired "expired!" return $scope.days = math.floor(distance / _day) $scope.hours = math.floor((distance % _day) / _hour) $scope.minutes = math.floor((distance % _hour) / _min

node.js - find records in sequelize seeds -

i've been trying write seeds project, i've ran bit of snag. i've got many-to-many relation users , roles table. so, when i'm seeding database need add record correct ids join table. in order need find user email , role name , ids , that's problem. can't find documentation on sequelize site . i'm using sequelize-cli seeding , migrating things. parameter queryinterface , can't find example or mention thing can do. simple examples got me through migrating (somehow) , able find on google. i've resolved using "dirty trick" i'd say... // user_seeds.js up: function (queryinterface, sequelize) { return queryinterface.bulkinsert(table, [{ id: 1, name: 'john doe', email: 'john@doe.com', created_at, updated_at }], {}); // roles_seeds.js up: function (queryinterface, sequelize) { return queryinterface.bulkinsert(table, [{ id: 1, name: 'admin', created_at, updated_at

ios - Segue performing on separate button click -

Image
i'm following course online, app i'm building cut down version of instagram can see on left hand side have view signing in, on right hand side have view signing up. pretty straight forward right, have created seque signin page button register when pressed takes registration view (one on right), works expected if i'm on signin page , click sign in , errors whatever reason display error message straight after performs seque registration screen though never pressed register this storyboard: this code behind sign in button located on left view @ibaction func btnsignin(sender: anyobject) { if txtusername.text == "" || txtpassword.text == "" { displayalert("error", message: "username , password required!") } } i have no other code inside controller cause seque initialise. if can shed light how can stop seque happening on sign in click , happen when press register i'd appreciate it. update

CakePHP 3 : Define global contant variable -

i working on cakephp 3 project little big. i want keep application clean possible separating media files core application , that's why have store media files on separate subdomain media.myproject.com , project accessible www.myproject.com . also in media.myproject.com there many directories as /root |- users |- avatar |- cover |- services |- logo |- banner |- slides |- clients |- logo |- avatar |- etc |- etc |- etc |- etc now, able access files in application view want set global variables can use in view like <img src="<?= $media.$mediauser.$useravatar.$user->avatar ?>" /> how ? you can make this: config/bootstrap.php configure::write('media', array( 'users' => array( 'avatar' => 'media.myproject.com/users/avatar/', 'cover' => 'media.myproject.com/users/cover/' ), 'services' =>

asp.net - Is the Singleton Design Pattern good or bad practice for banking application in c#? -

is singleton design pattern or bad practice banking application in c# ? problem performance , security? singleton design patterns used when don't want create more 1 object of class. so depends on want do, , functionality trying implement. for database connection can use singleton design pattern. transactions may want create thread safe singleton design pattern. but whole, cannot said if singleton or bad practice banking service.

mysql - Using JDBC to access localhost database from any computer -

first up, apologise if duplicate in way, have been trying many different things site several hours no luck. , record, running os x 10.11.5. i have made simple application using jdbc connect database created stored on localhost (i using phpmyadmin, if help): @override public void actionperformed(actionevent e) { // id search int search = integer.parseint(textfield.gettext()); // setting connection database. string url = "jdbc:mysql://my_ip_address:3306/javadatabase"; string user = "root"; // root user string password = ""; // no password connection con = null; preparedstatement searchid; // used prepared statement include user input resultset result = null; // results after sql execution try { con = drivermanager.getconnection(url, user, password); // connect mysql // creating prepared statement searchid = con.preparestatement("select * names id = ?"); // setting parameter user

Recursion java - Testing is the sum of the two Integers are equal Boolean function -

i have write recursive function accepts 2 integers. function returns true if first number digit amount equal second number, otherwise function returns false. the function return true. what doing wrong? the code: public static boolean amountequal(int num1, int num2) { int sum1 = 0, sum2 = 0; if (num1 == 0 && num2 == 0 && sum1 == sum2) return true; else if (num1 == 0 && num2 == 0 && sum1 != sum2) return false; sum1 += num1 % 10; sum2 += num2 % 10; return amountequal(num1 / 10, num2 / 10); } thank's what doing wrong? you using sum zero. need figure out way pass sum1 , sum2 along, final invocation make decision based on prior invocations. one way of doing making recursive function 4 parameters, , adding two-parameter overload start recursive chain: public static boolean amountequal(int num1, int num2) { return amountequal(num1, num2, 0, 0); } private static boolean amounte

Need help editing Wordpress CSS code - my sub menu disappears on hover -

hope can - im extremely new , not clued on code/editing css hoping can spell out me. have problem whereby can't keep sub menu visible. when hover on parent item 'destinations' appears, , when move down select 1 of sub menu items disappears. can please check me? www.thespindrifters.com - under destinations tab thanks in advance add/edit css in code: remove padding .site-bar 13px 0 , set 0; add padding .site-tools padding: 13px 0; - fix social icons in navbar add this: .navigation > li > { padding: 13px 0 } .navigation > li > ul { display: none; } .navigation > li:hover > ul { display: block; } reason remove padding .site-bar , adding child elements prevent disappearing of menu when moving parent link submenu

c# - Windows forms editor keeps recreating an event method -

i have c# application custom control. custom control class looks this: public partial class detnumericupdown : updownbase { public event eventhandler valuechanged; /* public methods */ public detnumericupdown() { /* ... */ } } then have several instances of detnumericupdown in form file main.cs, placed designer. each of these instances have own valuechanged event defined, instead of placing them in main.cs have moved them clarity file otherfile.cs. problem each time try use windows forms designer on main.cs recreates these methods in main.cs , complains methods defined twice. happens detnumericupdown instances, have moved event methods other controls otherfile.cs , works fine. doing wrong?

Android global variable vs cannot resolve method getApplication() -

i'm trying create global variable shown in mutliple other stack answers, when follow instructions, "cannot resolve method getapplication()" when trying or set variable in other activity. doing wrong , how get/set variable? here's mainactivity code: public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); } private int globalvariable_move; public int getglobalvariable_move() { return globalvariable_move; } public void setglobalvariable_move(int value) { globalvariable_move = value; } and here's activity code: public class playactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(s

java - Sending data from activity to class -

i need guys. i'm making quiz i'm stuck. first of got activity can choose between categories: package com.laurenswuytsjordipapen.cultural.pursuit; import android.app.activity; import android.content.intent; import android.content.sharedpreferences; import android.os.bundle; import android.preference.preferencemanager; import android.view.view; import android.widget.button; import com.laurenswuytsjordipapen.cultural.pursuit.library.userfunctions; public class dashboardactivity extends activity { userfunctions userfunctions; button btnlogout; button btneuropa; button btnamerika; button btnafrika; button btnazie; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); /** * dashboard screen application * */ // check login status in database userfunctions = new userfunctions(); if(userfunctions.isuserloggedin(getapplicationcontext())){

Retrieving data from a postgresql request using angularJs -

Image
i'm trying use http service, want retrieve data postgresql request, used angular.fromjson it's not working. there request response: for example want retrieve 'lat':

java - could not read column value from result set in Hibernate Native Query -

select concat(creg.firstname, ' ', creg.lastname) name, case when cr.campaigntype = 'nps' npsscore else csatscore end score, ifnull(cast(cc.text char(255)), '') comments, creg.id clientid, cr.id campaignresponseid, ci.id issueid customer_issues ci inner join (select distinct issueid issue_department_mapping customeruserid = 91 , issue_status = 'new') idm on cast(ci.feedback_date date) between '2016-06-05' , '2016-06-11' , idm.issueid = ci.id inner join campaign_response cr on cr.id = ci.campaign_response_id inner join client_registration creg on creg.id = cr.responsecustomerid left outer join campaign_comments cc on cc.campaign_response_id = cr.id; the above query running in mysql-console ,but when

php - OpenSSL won't create private keys? -

okay, well, first time working encryption on project. using hosting provider ssl, want encrypt portions of database sensitive. this, told use openssl. testing on localhost (wamp), , have installed openssl , turned on php , apache ssl mods. okay, i've been following tutorials and, using several suggested methods, have been able generate public key , store file. reason, can't seem generate private key. post 2 versions of code i've tried: // generate private key $privatekey = openssl_pkey_new(array( 'private_key_bits' => 1024, 'private_key_type' => openssl_keytype_rsa, )); // write private key file openssl_pkey_export_to_file($privatekey, 'private.key'); // generate public key private key $publickey = openssl_pkey_get_details($privatekey); // write public key file file_put_contents('public.key', $publickey['key']); // clear key echo $privatekey; ?> this generates public.key file, provides me warnings "opens

javascript - Web Service method name is not valid c# json ajax -

i making email contact form ajax post on umbraco site, halway thru , testing ajax part , "web service method name not valid" error when runs. i have booking.cs in app_code, booking.asmx in webservice folder, [webservice(namespace = "http://localhost/")] [webservicebinding(conformsto = wsiprofiles.basicprofile1_1)] [system.web.script.services.scriptservice] public class booking : system.web.services.webservice { public string email { get; set; } [webmethod] [system.web.script.services.scriptmethod(responseformat = system.web.script.services.responseformat.json)] public string saveit(string email) { try { return "success"; } catch (exception er) { return "error"; } } } javascript: $("#email_popup_submit").click(function (e) { $.ajax({ url: '/webservice/booking.asmx/saveit', type: 'post'

visual studio - How to store data from resource pointer to a static memory buffer in C++? -

i have loaded a.dat file in resource in vc++ project in visual studio told in documentation . now in main code, want load data static memory buffer resource pointer: hrsrc myresource = ::findresource(null, makeintresource(idr_rcdata1), rt_rcdata); unsigned int myresourcesize = ::sizeofresource(null, myresource); hglobal myresourcedata = ::loadresource(null, myresource); void* pmybinarydata = ::lockresource(myresourcedata); now i'm stucked on how create static memory buffer , store data pmybinarydata pointer. can solved please! in advance. you have information need: size of data ( myresourcesize ), , contents of resource ( pmybinarydata ), can create buffer , copy contents it: void *buffer = malloc(myresourcesize); memcpy(buffer, pmybinarydata, myresourcesize); buffer holds copy of bytes making resource, , can keep long need - can call ::unlockresource(myresourcedata); without affecting buffer . don't forget @ stage free(buffer); though - unless nee