Posts

Showing posts from May, 2015

android - Want to get users input during call -

i want achieve following in android. when usera make call userb. when userb press key during call on number pad usera can notification users selected button. is possible? by using gsm call feature want doesn't have api support. can try of following case 1: when number key pressed during call dtmf tone send. try if can somehow decode dtmf tone. there no recording option in android during call can try setting speakerphone on.. ( haven't tried this, not sure fully) can see project case 2 create channel on network. create server client mechanism register each number in server. whenever 2 calls of 2 registered users made send data on network. can see similar apps thruto

c# - Why won't datatables plug-in not work for my ASP.NET MVC 4? -

i want enable infinite scrolling. have installed datatables plug-in using nuget on visual studio 2012 project. standard model, view, , controller project. ran "install-package jquery.datatables" in package manager console added < thead > , < tbody > view added script view took @ similar issues on stackoverflow, no success problem coding demo teach myself infinite scrolling, in preparations serious project. have 30 names. should want show first 10 names , can infinite scroll show everyone. project compiles no errors. however, when table. see no change being rendered @ datatables plugin. displays 30 names, before. model-view public class ismodel { //[scaffoldcolumn(false)] public int id { get; set; } public string name { get; set; } public int age { get; set; } // array list of bools displaying achievement images? if true, display image on list, else don't display (alt text 1.g) //public bool

excel vba - What VBA coding in a Userform can I use to find a cell based upon row & column content, and then update that cell? -

Image
i complete beginner vba, truely. i trying create user form update number of tasks person completes on given date listed on spreadsheet. envision userform having 2 bottons (which hidden , appear conditions of subroutine). working on mac, way, , know have vba coding implications use on pc och vice versa. the example sheet this: the example userform (a) this: for argument's sake, let want update or input number of tasks greg completed on 7th of may (2013/05/07). i userform proceed this: entering person , date: then, retrieving number of tasks greg on 7th after button click: now, want input know greg completed 6 tasks on 7th , click second button (now visible , first button hidden): and result in spreadsheet: i ought input code here, skills , completeness of code wanting. put in have: option explicit 'subroutine when clicking first ("find") button private sub btnfind_click() lbltasks.vissible = true txttasks.visible = true

sanitizer - When modifying SimpleHtmlSanitizer.java, how to deal with <a href=> (Gwt)? -

you know simplehtmlsanitizer.java accepts following markup ("b", "em", "i", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ul", "ol", "li"). want "u", "sub", "a href=" & don't want "hr", "ul", "ol", "li". need modify class. now @ simplehtmlsanitizer.java ( https://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/safehtml/shared/simplehtmlsanitizer.java?r=8653 ) & @ line in class: arrays.aslist("b", "em", "i", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ul", "ol", "li")); you can guess can put our wished list line of code right. modify to: arrays.aslist("b","i", "u", "h1",

HTML - 'Persistance Navbar'? -

i wondering if possible following in html. index.html: <title>awesome website</title> <link href="navbar.html" rel="i-dunno-what-to-put-here" type="text/html"/> <p>content</p> navbar.html: <div id="navbar"> <li><a href="1.html">1</a></li> <li><a href="2.html">2</a></li> <li><a href="3.html">3</a></li> <li><a href="4.html">4</a></li> </div> so pretty - pages link navbar.html , if there 1 change in navbar, all pages change. does know if possible / how it? appreciated. i used php include jees mentioned.

ruby on rails - Using turbolinks with dynamic layouts -

i rendering different layouts each controller so: # layouts/student.html.erb: <% content_for :stylesheets %> #menu_container {background-color: #3085bd;} <% end %> <% content_for :side_menu %> <h4 style="text-align: center;"> students</h4> <% end %> <%= render :template => 'layouts/application' %> using turbolinks, i've found layout not changing when navigate between different parts of site. page refresh fixes everything. is there way tell turbolinks grab layout along page content? i got work placing following lines within body tag of application.html.erb: <%= content_for?(:side_menu) ? yield(:side_menu) : yield %> <style type="text/css"> <%= content_for?(:stylesheets) ? yield(:stylesheets) : yield %> </style>

javascript - How to load the data without clicking on the link? -

i developing mvc app. trying develop comment box. i have written code , in code , have written process like, when user click on show comment link comments appeared. now, want change functionality, without clicking on show comments button , comments should load. i trying not working. show comments link code <div class="span12" style="margin-left:0px; margin-top:50px;"> <span style="font-size:16px;"> @ajax.actionlink("show comments", null, null, null, new { id = model.id, @class = "addremark" }) <div class="remarkbox"></div> <span class="commentadd"></span> </div> i want load comments when page load, expecting commments show load while loading page, still want click on show comment link. $(document).ready(function () { $('a.addremark').click(addremarkclick); // call on load addremarkclick();

javascript - use tags <script> with if and else -

i have script tag this: <script src="cordova-2.5.0.js"></script> <script src="js/jquery-1.7.2.min.js"></script> <script src="js/jquery.mobile-1.1.1.min.js"></script> <script src="js/jquery.xdomainajax.js"></script> <script src="js/xml2json.js"></script> <script src="js/zipplugin.js"></script> <script src="js/jquery-ui.min.js"></script> <script src="js/jquery.ui.touch-punch.min.js"></script> <script src="js/prefixfree.min.js"></script> app wrote using phonegap android want use code in web. , dont use web page. have way using if else in html: if(anything) { <script src="cordova-2.5.0.js"></script> <script src="js/jquery-1.7.2.min.js"></script> <script src="js/jquery.mobile-1.1.1.min.js"></script> &l

c# - How can I have multiple handlers in same ProcessRequest method? -

i calling rest service ajax, have following example call myipaddress/restwebservice/employee?id=1", the c# service code shown below. handler above "employee", wish add more handlers , wondering can same processrequest method, parse out handler , direct request paramaters required, so have call like myipaddress/restwebservice/company?id=1", many thanks void ihttphandler.processrequest(httpcontext context) { try { string url = convert.tostring(context.request.url); connstring = @""; dal = new dal.dal(connstring); errhandler = new errorhandler.errorhandler(); //handling crud switch (context.request.httpmethod) { case "get": //perform read operation read(context); break; case "post": //perform create operation create(context

php - htaccess-rewriting, but excluding sub-directory -

this question has answer here: .htaccess exclude directory rewrited 1 answer i have general rewrite-rule in sites root looks this: rewriteengine on rewritecond %{request_filename} !-f rewriterule ^([\w]+)/?([\w]+)? index.php?action=$1 which works fine rewriting urls "www.example.com/myaction" "www.example.com/index.php?action=myaction" this must stay this, need exclude subdirectory ("/login") rewriting. so tried: rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_uri} !^/login/ rewriterule ^([\w]+)/?([\w]+)? index.php?action=$1 but still no luck. i've read several answers here on can't find flaw. ideas? thank you! you've slash. .htaccess doesn't use preceding slash unlike virtual host . /login/ directory. you're matching not real file, potentially real directory. if insta

Integration of Shenzhen Concox Information Technology Tracker GT06 -

i using opengts time organization. using tk103 family tracker company changed tracker , brought gt06 made shenzhen concox information technology co. ltd. tracker protocol entirely different , unable create server. can me tracker integration or let me know integrated tracker somehow similar one. give me tip , manage rest. copying protocol reference. 5.1.3. examples examples of login message packet sent terminal server , response packet sent server terminal follows: (in examples terminal id 123456789012345. example of data packet sent terminal 78 780 0d 01 01 23 45 67 89 01 23 45 00 01 8c dd 0d 0a example of response packet returned server 78 78 05 01 00 01 d9 dc 0d 0a shenzhen concox information technology co.,ltd www.cothinking.net/ copyright reserved. 5.2. location data packet (combined information package of gps , lbs) 5.2.1. terminal sending location data packet server format length(byte) example start bit 2 0x78 0x78 packet length 1 0x1f protocol number 1 0x12 date time

regex - Lookarounds in python -

i have problem regarding lookarounds in python: >>> spacereplace = re.compile(b'(?<!\band)(?<!\bor)\s(?!or\b)(?!and\b)', re.i) >>> q = "a b (c or d)" >>> q = spacereplace.sub(" , ", q) >>> q # meant happen: 'a , b , (c or d)' # instead happens 'a , b , (c , or , d)' the regex supposed match space not next words "and" or "or", doesn't seem working. can me this? edit: in response commentor, broken down regex multiple lines. (?<!\band) # looks behind \s, matching if there isn't word break, followed "and", there. (?<!\bor) # looks behind \s, matching if there isn't word break, followed "or", there. \s # matches single whitespace character. (?!or\b) # looks after \s, matching if there isn't word "or", followed word break there. (?!and\b) # looks after \s, matching if there isn't word "and",

ember.js - How to set up bindings in Ember -

i saw in ember documentation set binding using similar snippet: householdincomebinding: 'app.wife.householdincome' however set bindings supplying objects instead of strings (path global scope). need achieve similar this: ember.bind(obj1, "obj1attributename", obj2, "obj2attributename"); suggestions welcome. thanks! bindings can connected directly 1 object. from , to paths evaluated relative object they're connected. these paths can global. check out docs , implementation ember.bind helper: /** global helper method create new binding. pass root object along `to` , `from` path create , connect binding. @method bind @for ember @param {object} obj root object of transform. @param {string} path 'to' side of binding. must relative obj. @param {string} path 'from' side of binding. must relative obj or global path. @return {ember.binding} binding instance */ ember.bind = function(obj, to, from)

How to read list of numbers with readLine method in java? -

this question exact duplicate of: how make list of numbers calculate arithmetic mean of remainder? 2 answers i want ask question readline() method. project reading numbers in list separated spaces , calculate arithmetic mean remainder discarding lowest , biggest numbers. try way read number of them incorrect. how can read numbers readline() method in java ? p.s : program should working acm libary(console program) int [] inputarray ; ---> helpful me ? thanks help. import java.text.decimalformat; import java.util.scanner; import acm.program.consoleprogram; public class ccc extends consoleprogram { public static void main(string[] args) { /* * data input. */ scanner kb = new scanner(system.in); /* * declare array store judge's scores. */ double[] scores = new double[8]; /* * declare variables lowest

Structuring a three site Cassandra cluster -

i have 3 nodes cluster in 1 location (let's call main), , want add 2 new locations (let's remote1 , remote2). the use case i'm trying address sort of logging, want remote1 , remote2 able log data fast , reliably. opted 3 new nodes in each remote location, on persist using local_quorum , data replicated main location read app. my problem if both remote location write in same column family, replication factor { 'remote1': 3, 'remote2': 3, 'main': 1 } data remote1 replicated remote2 , vice-versa, don't want. one solution have 2 different column families each replication factor of { 'remotex': 3, 'main': 1 } end data split , less easy read. is there way acheive this? no, there not way have data centers in cassandra "hub , spoke" persistence strategy 1 keyspace. if don't want data persisted data centers have use multiple keyspaces. 1 remote1 , main, , remote2 , main.

ruby on rails - No route matches [POST] "/author/test_author/24/steps_author/13" -

i have form work , not , can't work out changing between times, other restarting rails app. isn't working. i have these entries in routes file: constraints :subdomain => 'my' namespace 'my', path: nil namespace 'author' resources :test_author resources :steps_author [...] end end end end the particular routes i'm interested in here produce rake routes my_author_test_author_steps_author /author/test_author/:test_author_id/steps_author/:id(.:format) my/author/steps_author#show {:subdomain=>"my"} put /author/test_author/:test_author_id/steps_author/:id(.:format) my/author/steps_author#update {:subdomain=>"my"} delete /author/test_author/:test_author_id/steps_author/:id(.:format) my/author/steps_author#destroy {:subdomain=>"my"} my form opening looks (using simple for

mysql - Update Query Using strcmp result -

i unsure how change select query update. the select query is: select if (strcmp( `player1`, `player2` ) >0, concat(player2, " - ", player1), pair) goodpair scores the problem trying solve pairs field contains pair names not in same order. example "bill - dennis" , "dennis - bill" same pair appear in different records , want pair names "lesser" name first can count times particular duo found. if more info needed, let me know. thanks in advance. bili you can use least , greatest functions: select concat_ws(' - ', least(payer1,player2), greatest(player1,player2)) goodpair scores i prefer use concat_ws concatenate strings separator instead of concat in particular case same. to create update query, use this: update scores set goodpair = concat_ws(' - ', least(payer1,player2), greatest(player1,player2)) if need swith player1 player2 in case player1 greater player2, use update query: upda

java - Cant get JLabels allign properly -

Image
i have list of categories , each category has image, need display images 1 after other (4 @ row) spaces between them. have problem displaying last label, seems setbounds method doesn't affect it. created jpanel , add labels containing images panel. source code, added link screenshot thanks! jframe frame = new jframe("test"); jpanel panel = new jpanel(); panel.setbackground(color.white); java.util.iterator<entry<integer, y2category>> = configfile.categories.entryset().iterator(); int positionx = 50; int positiony = 50; int linecounter = 0; while( it.hasnext() ) { map.entry<integer, y2category> pairs = (entry<integer, y2category>) it.next(); y2category cat = (y2category) pairs.getvalue(); jlabel label = new jlabel( new imageicon( "img\\main\\black.png" ), jlabel.center ); label.setbounds(positionx,positiony,115,179); label.setfont(new font("arial

html - Center multiple inline blocks with CSS and align the last row to the left -

i want horizontally center few inline blocks, @ same time have them align left on last row (see below). the problem achieved ( http://jsfiddle.net/5jsag/ ): | _____ _____ | | | | | | | | | 1 | | 2 | | | |_____| |_____| | | _____ | | | | | | | 3 | | | |_____| | while want this: | _____ _____ | | | | | | | | | 1 | | 2 | | | |_____| |_____| | | _____ | | | | | | | 3 | | | |_____| | you can see sample html @ http://jsfiddle.net/5jsag/ . i have tried using column-count , column-width doesn't work want to, because order of blocks changes: | _____ _____ | | | | | | | | | 1 | | 3 | | | |_____| |_____| | |

html5 - Navigation List a:hover -

i'm creating website, , far has navigation bar under "construction." want when hover on it, whole nav ul li background change color, not background behind text. have this: <html> <head> <link href='http://fonts.googleapis.com/css?family=noto+sans' rel='stylesheet' type='text/css'> <title>landstown high school , technology academy - home</title> <link rel="stylesheet" type="text/css" href="main.css"> </head> <body> <header> <nav> <ul> <li class="active"><a href="#">home</a></li> <li><a href="#">contact us</a></li> <li><a href="#">sharepoint</a></li> <li><a href="#">employees</a></li> </ul>

javascript - Knockout js - && in if condition and containerless binding -

i displaying list of items , if items not available have display default message. now, have check whether object has been created , check object has list in it. so now, doing below , works creates unnecessary dom elements. but, when same containerless binding doesn't seem work , there && syntax if in ko <span data-bind="if: object"> <span data-bind="if: !object().property"> <p> list not available </p> </span> </span> // works <!-- ko if: object --> <!-- ko if: !object().property --> <p> list not available </p> <!-- /ko --> <!-- /ko --> // doesn't work thanks as mentioned codethug, using solutions provided display message until ko.applybindings have finished. more verbose solution, avoid problem without relying on css, use dynamic templates shown in following jsfiddle: http://jsfiddle.net/sakb4/1/ this create valid

javascript - get css value on media query change via enquire.js -

enquire .register('screen , (min-width: 1200px)', { match: function() { active_li_margin_left = $('li.active').css('margin-left') active_li_width = $('li.active').width() console.log(active_li_margin_left, active_li_width) zwarovsky(); } }) .register('screen , (min-width: 980px) , (max-width: 1199px)', { match: function() { active_li_margin_left = $('li.active').css('margin-left') active_li_width = $('li.active').width() console.log(active_li_margin_left, active_li_width) zwarovsky(); } }) li.active width change 770px 620px, margin-left -30px -20px, bootstrap span8 items. the problem: seems enquire fire functions before css media query, pickup previous values when resize window. when switch 1200 980 resizing browser window console log show 30px 770 instead 20px 660, , when switch 980 1200 console log show 20px 620.

java - 3-tier architecture - Notify gui from lower layers -

i creating 3 tier application in java consists of gui, business logic layer , database layer. layers client-sided. from definition of multi tier architecture allowed make calls same or lower layers , return same or higher layers. in case i'm doing lot of database queries after user clicked on button. have status field in gui queried table shown. because layers in same application, call method database layer while looping through tables update status field. doing break rule make calls lower or same layer. so "legit" way update or notify gui lower layers in 3 tier architecture? i suggest use observer pattern. using java.util.observable class (as subject) , java.util.observer interface still keep conventions. you create concrete observer subclassing java.util.observer (gui- layer) you create concreate subject subclassing java.util.observable (dao- layer) you can attach concrete observer concreate subject. (referencing lower layers doesn't viol

java - How do I measure the SOAP processing time of a JAX-WS WebMethod? -

interface: import javax.jws.webservice; import javax.jws.webmethod; @webservice(name="webservice") public interface iwebservice{ @webmethod public collection<somevalue> dosthg(); } i measure time, how long takes javaws serialize returned collection<somevalue> in soap. have tried jamon, becauee soap somehow generated in background can't find way instrumentate code. use soapui. can accurate timings of send , receive: http://www.soapui.org/ soapui invaluable testing , debugging. imho...

java - Scaling Spring on Heroku -

i wondering if point me tutorial or blog post on writing spring application can run in single process integration testing locally when deployed deploy different subsystems different processes/dynos on heroku. for example, have services user management, job processing, etc. in web application. want run web application locally. when deploy heroku want deploy stateless web front end 2 dynos , have worker dynos can select different services run on. may decide group 2 of these services 1 process or decide each should run in own process. when services run in own process need transparently add kind of transport rest or rabbitmq or akka or such. any pointers on start looking learn how this? or thinking incorrectly , you'd suggest different approach? need figure out how setup application , how construct maven , intellij achieve this. thanks. i can't point prefabricated article or post, can share direction started down solve similar problem. essentially, proposed appro

winforms - Can't access global variables -

in globaldata.h defining typedef struct globaldata. in main cpp program, i'm including globaldata.h, declaring globaldata globaldata; after declaration, include createnetdialog.h , gui.h. why can reference globaldata in gui.h not createnetdialog.h? both include files should pasted .cpp file during precompile, globaldata should visible in both right? i have globaldata structure defined here: globaldata.h typedef struct { string netfilename; datafilereader *datafilereader; } globaldata; in c++ code, have: gui.cpp #include <cstdlib> #include <iostream> #include <fstream> #include <string> #include "datafilereader.h" #include "globaldata.h" globaldata globaldata; #include "createnetdialog.h" #include "gui.h" using namespace system; using namespace system::windows::forms; using namespace std; [stathread] void main(array<string^>^ args) { application::enablevisualstyles(); applicati

Fire a jquery event in an iframe, run a callback in parent window -

i can fire event in scope of parent window iframe , listen, can't fire event iframe in scope of iframe , listen in parent windows.. example, in parent window, have iframe , jquery code listen events fired in it's body <iframe id="myframe" src="/vf-install.php" width="500" height="500"></iframe> jquery('#myframe').contents().find("body").on('foo',function(){ alert('foo'); }); in iframe fire event: <script type="text/javascript">jquery("body").trigger("foo");</script> i not event triggered. side note can trigger event in parent window iframe this: parent.jquery("body").trigger("foo"); that unacceptable me though. reasoning vf-install.php being included via iframe installer program. writing regression test qunit includes installer in iframe, clicks install button, , when installer done (an event fired) test make ass

cakephp controller level Authentication -

i doing tourism system in cakephp, have 2 different kind of end-users, 1 admin , register users, need 2 different view users , registers users should not access controllers of admin module, now don't know how separate 2 users. by sounds of you're looking prefix routing should provide need. your url can prefixed admin (if applicable user in question): http://example.com/admin/posts which routed (in posts controller): public function admin_index(){ ... } which renders app/view/posts/admin_index.ctp view. i'm not going more because documentation quite thorough in area. please aware if start introducing more 2 levels of privilege (e.g. user, super-user, administrator) prefix routing isn't suitable. need take @ access control lists instead covered framework.

syntax - what is -> in c++ in a function declaration -

this question has answer here: what “->” after function declaration? 1 answer in wikipedia article on decltype http://en.wikipedia.org/wiki/decltype came across example: int& foo(int& i); float foo(float& f); template <class t> auto transparent_forwarder(t& t) −> decltype(foo(t)) { return foo(t); } though understood motive behind function, didnot understand syntax uses , -> in declaration. -> , how interpreted? edit 1 based on above: wrong here? template <typename t1, typename t2> auto sum(t1 v1, t2 v2) -> decltype(v1 + v2) { return v1 + v2; } the error is: error: expected type-specifier before ‘decltype’ error: expected initializer before ‘decltype answer edit 1: oops! forgot use -std=c++11 compiler option in g++. edit 2 based on below answer. have related question: @ declaration below: te

javascript - change a directive not to use jquery api -

i found beautiful directive tosh want. don't wat clear functionality, details of file opened. trying convert this, uses jquery angular native api. attempt here, not working. http://plnkr.co/edit/i5x3dh?p=preview any appreciated. thanks original: app.directive('fileselect', function() { var template = '<input type="file" name="files"/>'; return function( scope, elem, attrs ) { var selector = $( template ); elem.append(selector); selector.bind('change', function( event ) { scope.$apply(function() { scope[ attrs.fileselect ] = event.originalevent.target.files; }); }); scope.$watch(attrs.fileselect, function(file) { selector.val(file); }); }; }); removed need full jquery , made use of angular directive features (the template , 2 way scope variable binding): app.directive('fileselect', function() { return { template:'<input type=&quo

jquery - Setting a concrete date to start the datepicker -

i doing calendar jquery datepicker , have set initial date in '1/1/2013'. means first date shows datepicker must that. have tried that: $(function() { $('#datepicker').datepicker({mindate: '01/1/2013'}) }); but dont obtain searching for. reading in page , found example: $(function() { var date = new date(); // replace date $('#datepicker').datepicker().val(date.asstring()).trigger('change'); }); but doesnt work. if can me, pleased try this: $('#datepicker').datepicker("setdate", new date(2013,00,01)); fiddle

perl - Finding lines that end with zero and print its sister line -

i have files lines such as: data;moredata;evenmoredata1;200 data;moredata;evenmoredata1;200 data;moredata;evenmoredata2;500 data;moredata;evenmoredata2;0 data;moredata;evenmoredata3;0 data;moredata;evenmoredata3;0 basically every 2 lines related each other. im trying find best way print lines single 0 , line above or below it. output like. data;moredata;evenmoredata2;500 data;moredata;evenmoredata2;0 data;moredata;evenmoredata3;0 data;moredata;evenmoredata3;0 $ awk -f';' 'nr%3!=0{f=$nf;a=$0;getline;if(f==0||$nf==0)print a"\n"$0"\n"}' file data;moredata;evenmoredata2;500 data;moredata;evenmoredata2;0 data;moredata;evenmoredata3;0 data;moredata;evenmoredata3;0

How to get content from my router with AJAX -

let me explain in details want... need content router via address http://user:password@192.168.1.1/dhcp_table.html line (class name): <td class="data_table_data" align="center"> **pc name** </td> i see result this: pc name is looking for? if yes, how? $.ajax({ url: url, data: data, success: success, datatype: datatype }); you can pass username , password router ajax parameters. should specify datatype: 'html' well: var url = "http://192.168.1.1/dhcp_table.html", username = "<username here>", password = "<password here>"; var auth = 'basic ' + base64.encode(username + ':' + password); $.ajax ({ type: "get", url: url, datatype: 'html', username: username, password: password, headers : { authorization : auth }, success: function (data) { var dhcptable = $(data); alert('text of table = '+dhcptable.fi

java - Duplicate Method while Method-Overloading -

following code gives compilation error error "duplicate method" static int test(int i){ return 1; } static string test(int i){ return "abc"; } this expected both overloaded method have same signature , differ in return type. but following code compiles fine warning: static int test1(list<integer> l){ return 1; } static string test1(list<string> l){ return "abc"; } as, know java generics works on erasure, mean in byte-code, both these method have same signature , differs return type. furthur, surprise following code again gives compilation error: static int test1(list<integer> l){ return 1; } static string test1(list l){ return "abc"; } how second code working fine without giving compilation error, though there duplicate method? resolving overloaded methods done @ compile-time, rather runtime, java compiler know difference between 2 in second example. in third example, pro

java - How should I design the classes for a simple CRUD operation in JSF + Hibernate application? -

i trying learn web programming using jsf , hibernate. i have table called mytable in mysql server has 2 columns: name, surname i have mytable.java mapped table, looks this: // listing 1 public class mytable { private string name; private string surname; public mytable() { } public string getname() { return name; } public void setname(string name) { this.name = name; } public string getsurname() { return surname; } public void setsurname(string surname) { this.surname = surname; } } this mapped via hibernate, code ( have used testing purposes ) inserts data mytable: //listing 2 session session = hibernateutil.getsessionfactory().opensession(); session.begintransaction(); mytable mytable = new mytable(); mytable.setname("name"); mytable.setsurname("surname"); session.save(mytable); session.gettransaction().commit(); and form on i

I can not insert into MariaDB table with my PHP script -

i moved mariadb, because since mysql 5.6 has been failing lot me. mariadb works flawlessly but, in new project, cannot insert data database php script. can insert manually. have made no changes scripts working mysql. the insert statement is: insert participantes (nome, curso, email, equipe) values (:nome, :curso, :email, :equipe); and script should inserting is: $stmt = $this->dbh->prepare($this->sql_insert); $nome = $participante->nome(); $curso = $participante->curso(); $email = $participante->email(); $equipe = $participante->equipe(); $stmt->bindparam(':nome', $nome); $stmt->bindparam(':curso', $curso); $stmt->bindparam(':email', $email); $stmt->bindparam(':equipe', $equipe); $stmt->execute(); the "participante" functions return data used, no problems. inside try/catch block, reports no exceptions. my pdo class follows: class connection extends pdo { private $dsn = 'mysql:host=

php - Posting an array() -

if in form post hidden field this: <input type="hidden" name="userarr" value="array([0] => 13 [1] => 10 [2] => 12 [3] => 9 [4] => 14 [5] => 11)"> do keep benefit of array? do need call input name field userarr or userarr[] ? solution array exists: foreach ($userarr $value) { echo '<input type="hidden" name="userarr[]" value="'.$value.'">'; } you'd better like, "user input can never trusted! not when it's hidden!" <input type="hidden" name="userarr" value="<?= htmlentities(json_encode(array(10, 20, 30), ent_noquotes); ?>"> and server side keep array: $arr = json_decode(html_entity_decode($_post['userarr'], ent_noquotes)); the value using handled normal string, can't convert array. there several ways encode , decode it. examples below. have encode quotes not cau

Unable to upload file to google cloud storage using post method -

below code. copied interoperable access keys.. client , secret both same page. used client key in clientaccess id in form , secret hashing. error saying invalid argument. detail error being shown "cannot create buckets using post" below python code used. import webapp2 import cgi import datetime import urllib import base64 import hmac, hashlib import sha policy_document = '''{"expiration": "2016-06-16t11:11:11z", "conditions": [ ["starts-with", "$key", "" ], {"acl": "public-read" }, ] }''' policy = base64.b64encode(policy_document).strip() h = hmac.new('xxx', digestmod=sha.sha) h.update(policy) signature = base64.b64encode(h.digest()) class mainhandler(webapp2.requesthandler): def get(self): self.response.write('<html><

Subtraction in a while loop -

i new programing game. , when run problems can fix them quite little help. on has me stumped. i attempting build basic calculator of sorts, , i'm using while loops it. addition simple because had type: sum += however subtraction, multiplication, , division not easy. wondering if point me in right direction said before stumped. here part of code reference: x = 0; while(x < y){ if(operator == 1){ /*addition portion*/ x += 1; printf("please enter number %d: ", x); scanf("%lf", &a); sum += a;} else if(operator == 2){ /*subtracion portion*/ x += 1; printf("please enter number %d: ", x); scanf("%lf", &b); sum += b - sum;}} /*not working, fix, research*/ printf("\nthe sum of entered numbers = %.f\n\n", sum); you can use other operators -= , *= , , /= subtraction, multiplication, , division, respectively.

android - Should i use push notifications for all new instant messages -

i using custom php webserver im program send push messages, can send push notifications mobile phone not sure how use properly. by mean should send messages push notifications, possible that? there limitations push notification's size? or should start timer check new messages after first notification , finish timer when activity closed? proper way instant messages server? for android limitation on push notification size 4k. if messages smaller that, can use push notifications sending content. however, delivery of push notifications not guaranteed, it's better practice use if means server notify app new data available, when it's not running in foreground. app calls server retrieve data. when app in foreground, can poll server periodically new data.

java - 2D Shooter using JPanel/JFrame. drawImage (bullet) on screen with it's own velocity -

here have: import java.awt.color; import java.awt.component; import java.awt.graphics; import java.awt.image; import java.awt.toolkit; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.keyevent; import java.awt.event.keylistener; import java.awt.image.imageobserver; import java.util.arraylist; import javax.swing.jpanel; public class gamepanel extends jpanel implements actionlistener, keylistener, imageobserver { public image ship; public image enemy; private int xloc; private int yloc = 180; private int xloc2 = 700; private int yloc2 = 180; private int xvel; private int yvel; private int xvel_en; private int xvel_sh = 6; private imageobserver observer = null; private arraylist<base> shield = new arraylist<base>(); private image shieldpiece; private shot shot; public gamepanel() { ship = tool