Posts

Showing posts from June, 2012

mysql - php login password not accepted -

i not able log in using below code. so, here's code: public function auth($login, $password) { $login = $this->db->real_escape_string($login); $tmp = $this->db->query("select id, password users login = '$login'"); if (!$tmp->num_rows) { return false; } $userdata = $tmp->fetch_assoc(); var_dump($userdata); var_dump(sha1($password.'|'.$login)); if ($userdata[‘password’] == sha1($password.'|'.$login)) { return $userdata['id']; } else { return false; } } } and here's output var dumps array(2) { ["id"]=> string(1) "7" ["password"]=> string(40) "e1c6d95317081ebddaea4cd1a061415c39dafb2b" } string(40) "e1c6d95317081ebddaea4cd1a061415c39dafb2b" how can modify it, can log in? why dont do.. $this->db->query('select `i...

mysql - multiple where clause in sql -

i don't know if possible give try. i have 3 tables: first table: (sender_id , receiver_id foreign key referencing loginportal table) messages sender_id | receiver_id | message 3 | 1 | ... second table: (req_id foreign key referencing request table) loginportal loginportal_id | username | req_id 1 | admin | 1 3 | user | 2 third table: request req_id | firstname | surname 1 | john | doe 2 | jane | me problem: whenever used query: "select id, message_sender_id, message_title, message_body, sent_date, message_status, username, firstname, surname messages m inner join loginportal l inner join request r on m.message_receiver_id= l.loginportal_id , l.req_id=r.req_id m.message_receiver_id=( select loginportal_id loginportal username='".$_session['user']."')"; what g...

javascript - Text Input Value sometimes does't change even though it thows no errors, and seems to work -

so have simple program change value of input field every time blur it. logs used values in array, use array check if it's been used. practically works intended, after few tries return true , logs, yet value wont change. updated code: var dftvalue = ['freddy grocer', 'jack fiddler', 'cane sheep herder', 'arnold fish monger', 'luke car salesman', 'josh tailor', 'carol baker', 'tiara nacho vendor', 'example@email.com', 'your message here.']; var logused = new array(); //create new array log used indexs function setdftvalue() { var newval = dftvalue[math.floor(math.random() * 7)]; if (logused.indexof(newval) == -1) { this.value=newval; logused.push(newval); console.log(logused); } else if (logused.indexof(newval) >= 0) { setdftvalue(); } if (logused.length == 8) { (i=0; i<=7; i++){ logused.pop(); } } } document.getelementbyid('fo...

date - Java Gregorian calendar formatting -

i have camping program has dialog box user inputs date check in , date plan check out text field. once press ok on dialog box, dates input should viewable in jtable. currently, in date column java.utl.gregoriancalendar[time....etc] when user presses ok. other information such name, days staying, , site number appear okay. not formatting date correctly, i'm not sure how fix it. here code gregorian calendar in class dialogcheckintent: public gregoriancalendar getdatein(){ dateformat df = new simpledateformat("mm/dd/yyyy"); gregoriancalendar g = new gregoriancalendar(); try{date date = df.parse(datein.gettext()); g.settime(date); } catch (parseexception ex) { ex.printstacktrace(); } return g; } public gregoriancalendar getcheckoutdate(){ dateformat df = new simpledateformat("mm/dd/yyyy"); gregoriancalendar g = new gregoriancalendar(); try{date date = df.parse(checkouttxt.gettext()); g.s...

python - Retrieving a bytes object of length 1 from another bytes object -

taking following example: >>> bytes_obj = "foobar".encode() attempting retrieve first item bytes iterable returns int : >>> type(bytes_obj[0]) <class 'int'> how possible instead retrieve bytes object of length 1 yielding equal or similar produced using bytes((bytes_obj[0],)) , elegant or succinct. you can slice bytes bytes object: >>> bytes_obj = "foobar".encode() >>> type(bytes_obj[:1]) <class 'bytes'> >>> bytes_obj[:1] b'f'

regex - Lower and Upper Case Regular Expression Patterns -

i not familiar regular expressions. i have following regular expression c-(move|store)-(rsp|rq) match patterns , matches following strings: c-move-rsp c-store-rsp c-move-rq c-store-rq i make such case insensitive. match string c-move-rsp c-move-rq ... .. i guessing should pretty straight forward of experienced regular expressions. i have tried c-/(move|store)/i-/(rsp|rq)/i has not worked me. thanks help like this: /c-(move|store)-(rsp|rq)/i the flag applies entire regex. in python, groovy, write: (?i)c-(move|store)-(rsp|rq)

java - I need an example on how to use the function create created by the RESTful from entity class -

i need example on how use function create created restful entity class my entity class (countries) : package entities; import java.io.serializable; import javax.persistence.basic; import javax.persistence.column; import javax.persistence.entity; import javax.persistence.id; import javax.persistence.namedqueries; import javax.persistence.namedquery; import javax.persistence.table; import javax.validation.constraints.notnull; import javax.validation.constraints.size; import javax.xml.bind.annotation.xmlrootelement; import org.hibernate.sessionfactory; import org.hibernate.session; import org.hibernate.cfg.configuration; /** * * @author oracle */ @entity @table(name = "countries") @xmlrootelement @namedqueries({ @namedquery(name = "countries.findall", query = "select c countries c"), @namedquery(name = "countries.findbycountryid", query = "select c countries c c.countryid = :countryid"), @namedquery(name = ...

Swiffy-converted Flash to HTML5 animated Google AdSense ads cause terrible performance jank in Chrome for Android -

i've been trying figure out what's causing absolutely awful scrolling , general responsiveness performance issues in chrome on our site lately, , conclusion it's swiffy powering of google's adsense ads animations. recently, google announced they're auto converting flash ads html5, presumably swiffy, seems own browser takes huge hit time sees them. the animations choppy. we're talking 2fps. the browser jank increases 1000%. tried pausing chrome debugger attached mobile device via usb debugging , caught swiffy code using touchstart , touchend, known causing performance issues. any time page loads without animated ads, performance fine. we tried apply translatez(0) try force ads go gpu, don't seem have success there. any ideas optimizations force ad rendering on gpu or otherwise? the website http://www.androidpolice.com btw. cross-posted https://productforums.google.com/forum/#!category-topic/chrome/report-a-problem-and-get-troubleshooting-he...

sql - PHP Using % inside mysqli where clause [Havij] -

so website open sql injection , exploited using havij. question program can placeholder in format of getvariable=%inject_here% . now know in statement can use % wild card. do % signs have significance inside equals comparison? or structure literally looking string "%inject_here%". i'm trying understand format further prevent injection. any information on subject appreciated! you can convert string it's hexadecimal value. here website doing in sql http://www.codeproject.com/articles/610089/sql-servers-format-function#13 . every language has easy use method convert strings , hexadecimal. enable place character want in string. if using percentages in mathematical type of way, not proper store them in sql string. should store in decimal format. decimal(p,s) example decimal(5,2)

html - How do I use CSS attribute selector with the adjacent selector? -

for following css how collectively use attribute , adjacent selector? .onoff-checkbox:checked + .onoff-label .onoff-inner {margin-left: 0;} .onoff-checkbox:checked + .onoff-label .onoff-switch {right: 0px;} i using create css toggle style check-boxes, , want have more 1 checkbox on page? following html code (example): <input type="checkbox" name="onoff" class="onoff-checkbox-1" id="myonoff" checked> ... <input type="checkbox" name="onoff" class="onoff-checkbox-2" id="myonoff" checked> i have tried following - input[class*="onoff-checkbox"]:checked + label[class*="onoff-label"] span[class*="onoff-inner"] ... what correct syntax. help. here code try out - https://jsfiddle.net/vedanta_/8z3sqatf/ original code adapted - https://proto.io/freebies/onoff/ you can't use same id more 1 element. use myonoff1 , myonoff2 . then can access css...

java - Utilizing BorderLayout on JFrame. ( Using Container) -

Image
new gui, trying create simple jframe 2 jtextareas positioned right next each other , jpanel @ bottom. public class demo extends jframe { jpanel panel; jtextarea jtextarea1; jtextarea jtextarea2; decisionpanel decisionpanel; public demo() { super( "black jack server" ); jframe f = new jframe(); f.setsize( 400, 400 ); ; f.setdefaultcloseoperation( jframe.exit_on_close ); f.setvisible( true ); decisionpanel decisionpanel = new decisionpanel(); f.getcontentpane().add( decisionpanel ); jtextarea1 = new jtextarea(); add( jtextarea1); jtextarea2 = new jtextarea(); add( jtextarea2 ); } } do use borderlayout result want? if so, how should approach? you nest jpanels and... place jtextareas in own jscrollpanes , place jscrollpanes gridlayout(1, 2) (1 row, 2 columns) using jpanel place jpanel borderlayout using jpanel in bord...

C++ call function with reference to array of const integers -

lets have these 2 function definitions: int* first(int const (& array)[], int const size); void second(int const array[], int const size); and @ implementation of second want make call first this: void second(int const array[], int const size) { int* = first(*array, size); } thats when compiler tells me: "no matching function call 'first'". correct way call first second in case? if have use arrays, suggest using std::array : #include <array> template<size_t n> int first(std::array<int, n> const& array) ; template<size_t n> void second(std::array<int, n> const& array) { int = first(array); } int main() { std::array<int, 3> = {1,2,3}; second(a); } if have array dynamic size, free burden of manually managing array , use std::vector instead.

frontend - The Address Element HTML5 -

how use html 5 specific tag address correctly? semantic markup. this one <address> new york<br> +7 (495) 204-27-22<br> paris<br> +375 (29) 658-77-46<br> +375 (17) 292-91-23 </address> or one? <address> <p> new york<br> +7 (495) 204-27-22 </p> <p> paris<br> +375 (29) 658-77-46<br> +375 (17) 292-91-23 </p> in html 4 first 1 valid. in html5 both valid. ran both examples through validator http://validator.w3.org/check can go there check if have valid on have make full document example this: <!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd"><!-- <!doctype html> --> <html> <head> <title> test </title> </head> <body> <address> new york<br> +7 (495) 204-27-22<br> paris<br> +375 (29) 658-77-46...

Passing SQL data in codeigniter to highcharts with JSON -

i having trouble passing sql data controller view. have verified information shows model. don't know json i'm trying learn. goal populate chart 2 fields numbers highcharts javascript. please help, thank you! controller function dashboard() { // tickets in queue $query = $this->mhedash_model->maint_pending_tickets(); $result3 = $query->result_array(); $this->table->set_heading('work number', 'vehicle number','submit date','submit time'); $data['table']['vehicle in queue'] = $this->table->generate_table($result3); // active tickets $query = $this->mhedash_model->select_active(); $result = $query->result_array(); $this->table->set_heading('service number','start date','mechanic','vehicle number','description','type'); $data['table']['vehicles actively being worked on'] = $this->...

java - Is it possible to configure ANTLR grammar to use two token having the same structure? -

for below grammar, grammar names; fullname : title? first_name last_name; title : 'mr.' | 'ms.' | 'mrs.' ; first_name : ('a'..'z' | 'a'..'z')+ ; last_name : ('a'..'z' | 'a'..'z')+ ; whitespace : ( '\t' | ' ' | '\r' | '\n'| '\u000c' )+ -> skip ; when parsing input "mr. john smith", throw exception mismatched input 'smith' expecting last_name is possible configure antlr handle case? if not possible, alternative way handle it? please note it's not limited simple case. there no syntactic difference between first_name , last_name ; need assign them. grammar names; fullname : title? first=name last=name; title : 'mr.' | 'ms.' | 'mrs.' ; name : ('a'..'z' | 'a'..'z')+ ; whitespace : ( '\t' | ' ' | '\r' | '\n'| '\u...

Tesseract OCR text order for documents with tables or rows -

i using tesseract ocr convert scanned pdf's plain text. overall highly effective having issues order text scanned. documents tabular data seem scan down column column when seems more natural way scan row row. small scale example be: this column a, row 1 column b, row 1 column c, row 1 column a, row 2 column b, row 2 column c, row 2 is yielding following text: this column a, row 1 column a, row 2 column b, row 1 column b, row 2 column c, row 1 column c, row 2 i starting read documentation , guess , test, brute force approach parameters documented here if has tackled issue similar, appreciate insight on fix. training data not know how works. try running tesseract in 1 of single column page segmentation modes : tesseract input.tif output-filename --psm 6 by default tesseract expects page of text when segments image. if you're seeking ocr small region try different segmentation mode, using -psm argument. note adding white border text tightl...

intellij idea - Dropwizard integration test cannot find resource file -

very new dropwizard, trying create integration test "exactly" how have example: https://dropwizard.github.io/dropwizard/manual/testing.html public class loginacceptancetest { @classrule public static final dropwizardapprule<testconfiguration> rule = new dropwizardapprule<testconfiguration>(myapp.class, resourcehelpers.resourcefilepath("dev-config.yml")); @test public void loginhandlerredirectsafterpost() { //client client = new jerseyclientbuilder(rule.getenvironment()).build("test client"); } } so far having 2 issues: first of when run test intellij fails following exception: caused by: java.lang.illegalargumentexception: resource dev-config.yml not found. full stacktrace: java.lang.exceptionininitializererror @ sun.misc.unsafe.ensureclassinitialized(native method) @ sun.reflect.unsafefieldaccessorfactory.newfieldaccessor(unsafefieldaccessorfactory.java:43) @ sun.reflect.reflectionfactory.newfieldaccessor(reflecti...

mysql - PHP code to present query result present as html, and add hyperlink to text that is a url -

i have cell in database $data. contain data. of data might contain url. using mysql need php return text out of cell, hyperlinking url. found preg_replace function elsewhere on overflow not working. im trying find code extract $data present $data text plus hyperlinked url. i found this: preg_replace('/\b(https?:\/\/(.+?))\b/', '<a href="\1">\1</a>', $text); but a) not working , b) need statement extract $data first live regex says works: http://www.phpliveregex.com/p/aqb (click on preg_replace on right). $data = \preg_replace('/\b(https?:\/\/.+)\b/i', '<a href="\1">\1</a>', $data);

How To Add A User Alias Using Google Admin SDK Java API -

i using service account model , google's admin sdk java api retrieve , modify users. the goal add alias existing user. alias newalias = new alias(); newalias.setid(userid); newalias.setalias(alias); directory.users.aliases.insert request = directory.users().aliases().insert(userid, newalias); request.execute(); execute() fails 100% of time error message: "value set through parameter inconsistent value set in request" but of course not identify problem parameter or value, or provide suggestion. i tried 8 combinations of scoped (or not scoped) userid , alias in newalias, , userid in request, same result. 8 combinations, mean: newalias.setid(userid); newalias.setalias(alias); insert(userid, newalias); newalias.setid(userid@domain.com); newalias.setalias(alias@domain.com); insert(userid@domain.com, newalias); and on... any ideas appreciated. i've gotten aliases inserted using following: alias alias = new alias(); alias.setalias(aliasstr...

c - Getting wrong value for ID in pthreads -

i'm trying output be starting professor 1 starting professor 2 starting professor 3 ... but never "starting professor 1" when num_professors = 2. thought making array of ids save whole passing in of address of id, apparently not. there's 70 other things have project , having roadblock on simple thing (that takes few seconds fix) quite frustrating least. appreciated void * professorfunc(void *p){ sem_wait(&workassignment); if(buffer == 0){ buffer++; professor *professor = (professor*)p; fprintf(stdout,"starting professor %d\n", *professor->id); } buffer = 0; sem_post(&workassignment); pthread_exit(0); } int main(int argc, char ** argv){ //semaphore intialization buffer = 0; if(sem_init(&workassignment, 0, 1)){ printf("could not initialize semaphore.\n"); exit(1); } //creating threads pthread_t professor[num_professors]; ...

How to play video with Xamarin forms? -

i have implemented examples here: https://github.com/xlabs/xamarin-forms-labs/wiki/camera , able image camera successfully. additionally have implemented select video - have no way play video... i ended putting browser window , playing video off remove page after uploading it. however, not idea, want play video in app after choosing file system or camera itself. has managed xamarin forms/forms labs without having implement in every single platform manually? and if way it, examples of this? thank much! you can check out video player component on xamarin forms component store. allows render native video player on ios, android, , windows phone. code snippet below shows simplest example of dropping in , using it. have ability hook events playing, paused, stopped, completed, etc. can control volume, autoplay, , repeat among other things. http://go.adams.life/1vqbqnt <?xml version="1.0" encoding="utf-8" ?> <contentpage xmlns="http:/...

Meteor - handling events in nested templates... without polluting 'Session' variable -

i've come across situation several times , realise i'm not confident 'meteor/right' way handle it. suppose have form several parts - each represented template - , within each part there more templates representing eg. datepickers etc. <template name='myform'> {{>partone}} {{>parttwo}} <button class='submit'>submit</button> </template> <template name='partone'> {{>widget}} {{>widget}} </template> <template name='widget'> <input class='datepicker' /> </template> i want keep track of form user fills out - on level of 'myform' template - events happening @ level of 'widget'. one solution keep seeing (e.g. in answer ) put in global session variable. so template.widget.events({ 'click .select' : function(event, template){ var name = template.data.name; session.set(name, $(event.currenttarg...

Understanding variable scopes in python: An Exercise Program -

this exercise wanted try because thought interesting. exercise unnecessarily complex doing, trying act practice understanding class, function , variable behavior in more complex python programs. import os class grabfile: fileobject = none def __init__(self, filename): self.fileobject = open(filename, "r") def getfile(): return self.fileobject class counter: filec = none linecount = 0 def __init__(self, fileobject): self.filec = fileobject def linecounter(self): while true: self.filec.readline() print(x) return linecount def main(): filegrabber = grabfile("test.txt") fileobj = filegrabber.getfile countobj = counter(fileobj) linecount = countobj.linecounter() print(linecount) main() however, when run this, following error: traceback (most recent call last): file "/home/may/desktop/tree/programming/miscprojects/textanalyzer.py", ...

How to add another menu item on magister bootstrap theme? -

seems mission impossible!! 4 elements allow me add!! idk why :s when try add 1 more, icon bar messes , don't know do!! here's code example <nav class="mainmenu"> <div class="container"> <div class="dropdown"> <button type="button" class="navbar-toggle" data-toggle="dropdown"><span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <!-- <a data-toggle="dropdown" href="#">dropdown trigger</a> --> <ul class="dropdown-menu" role="menu" aria-labelledby="dlabel"> <li><a href="#head" class="active">hello</a></li> <li><a href="#about">about me</a></li> <li>...

javascript - Compute differences between 2 HTML pages and dynamically change first -

i have hmtl page (re-)generated every 3 seconds , need expose these changes users. since can't change generator write in different format (json) , read using ajax, right have javascript refreshes whole page every 10 seconds. ideally, need instead of refreshing whole page, refresh fields changed. the page structure never changes, value of table cells. every table cell has different class name. ex: original html, running @ user's browser contains: <html><body><div class="firstdiv">1000</div></body></html> after 3 seconds changes in server to: <html><body><div class="firstdiv">2000</div></body></html> a javascript read via ajax changed html every 3 seconds, calculate difference , apply changed page opened @ user's browser, using javascript: $('.firstdiv').html('2000'); so question is: there tool/library can me task?

php - Zend Route is not loading the controllers -

i have route settings: return array( 'router' => array( 'routes' => array( 'padrao' => array( 'type' => 'segment', 'options' => array( 'route' => '/:controller[/:action][/:id]', 'constrants' => array( 'id' => '[0-9]+' ), 'defaults' => array( 'controller' => 'index', 'action' => 'index' ), ), ), ), ), 'service_manager' => array( 'abstract_factories' => array( 'zend\cache\service\storagecacheabstractservicefactory', 'zend\log\loggerabstractservicefactory', ), ), 'controllers' => array( 'invokables' => array( 'index' => ...

c++ - push_back or emplace_back with std::make_unique -

based on answers in these questions here , know preferred use c++14's std::make_unique emplace_back(new x) directly. that said, preferred call my_vector.push_back(std::make_unique<foo>("constructor", "args")); or my_vector.emplace_back(std::make_unique<foo>("constructor", "args")); that is, should use push_back or emplace_back when adding std::unique_ptr constructed std::make_unique ? ==== edit ==== and why? c: <-- (tiny smile) it doesn't make difference, have unique_ptr<foo> prvalue (the result of call make_unique ) both push_back , emplace_back call unique_ptr move constructor when constructing element appended vector .

mysql - PHP Redirection Error (even tho I'm pretty sure I wrote this right...) -

login.php if(isset($_post["submit"])){ if(!empty($_post['user']) && !empty($_post['pass'])) { $user=$_post['user']; $pass=$_post['pass']; $con=mysql_connect('localhost','haha forgot take stuff out.','whoops. wouldve been bad.') or die(mysql_error()); mysql_select_db('jesus. forgot 1 too!') or die("cannot select db"); $query=mysql_query("select * login username='".$user."' , password='".$pass."'"); $numrows=mysql_num_rows($query); if($numrows!=0) { while($row=mysql_fetch_assoc($query)) { $dbusername=$row['username']; $dbpassword=$row['password']; } if($user == $dbusername && $pass == $dbpassword) { session_start(); $_session['sess_user...

python - Beautiful Soup filter function fails to find all rows of a table -

i trying parse large html document using python beautiful soup 4 library. the page contains large table, structured so: <table summary='foo'> <tbody> <tr> bunch of data </tr> <tr> more data </tr> . . . 100s of <tr> tags later </tbody> </table> i have function evaluates whether given tag in soup.descendants of kind looking for. necessary because page large (beautifulsoup tells me document contains around 4000 tags). so: def isrow(tag): if tag.name == u'tr': if tag.parent.parent.name == u'table' , \ tag.parent.parent.has_attr('summary'): return true my problem when iterate through soup.descendants , function returns true first 77 rows in table, when know <tr> tags continue on hundreds of rows. is problem function or there don't understa...

Python: What happens when main process is terminated. -

i working multiprocessing module on unix system. have noticed memory leaks when terminate 1 of programs. thinking might because processes started in main process kept running. correct? i think i'd refer this post great job of explaining how other threads behave.

sql - Access 2010 set variable to single field of a table -

i feel should easy, haven't been able come clear answer after searching off , on day. i have users table has email addresses in it. i have combo box references table. all want do, set email address field of selected user string, can things that. just trying string sql query : "select emailaddress tblusers id = " & me.cmbuser.value & "" can point me in right direction here? you can use combo box return email address after user select user list. assume user tblusershas user , email fields set combo box property: 1.row source = select user, email tblusers 2.column count = 2 3.bound column = 0 (0 first column , 1 second column email) 4.column width = x";0" (x combox box width) you can email address me.combobox.column(1). both me.combobox.value , me.comboxbox.column(0) selected user

javascript - when is a String not a String? when it doesn't have an includes() method? -

i'm trying write simple javascript(well coffeescript) test , have confusing: dclib.appendvartourl = (base, k, v) -> check base, string console.log("base a:", typeof(base)) if base.includes("?") ... // called dclib.appendvartourl("some/url", "score", 5) gives me: base a: string typeerror: object some/url has no method 'includes' so why string not have .includes() method? coffeescript wrapping object in weird way? aha, looks browser supports es6 method, node version i'm using doesn't. running unit tests on server whereas method ran fine on client. https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/includes this experimental technology, part of ecmascript 6 (harmony) proposal.

vagrant ssh failed since the network segment changed -

i using vagrant long time. recently our office has moved new place, network segment has changed 192.168.10.x 192.168.1.x. since then, command vagrant ssh failed. , when tried vagrant up again, it shows default: ssh address: 127.0.0.1:2222 default: ssh username: vagrant default: ssh auth method: private key default: warning: connection timeout. retrying... default: warning: connection timeout. retrying... default: warning: connection timeout. retrying... default: warning: connection timeout. retrying... default: warning: connection timeout. retrying... default: warning: connection timeout. retrying... default: warning: connection timeout. retrying... but when turned off wireless in osx. vagrant commands works fine. , failed again when turned on network. could 1 give me hint solve issue? thanks.

Polymer drawer-panel wont close -

i have core-drawer-panel core-menu. able open drawerpanel when click on menu option. problem having when click on item in drawer panel not close. have added javascript code @ bottom copied spa demo on polymer-projects, still doesn't close. <template is="auto-binding" id="template"> <core-drawer-panel id="drawerpanel"> <core-header-panel drawer id="drawer"> <core-toolbar id="navheader"> <span>menu</span> </core-toolbar> <core-menu selected="{{option}}" on-core-selected="{{selectedoption}} valueattr="data-category"> core-items... </core-menu> </core-header-panel> </core-drawer-panel> </template> <script> var template = document.queryselector('#template'); var navicon = document.getelementbyid('navicon...

xml - How to create custom edittext with button in android? -

Image
how can create kind of edittext button on android. i've done relative layout won't presentable. thanks ahead. use android:drawableright property of edittext.code as <edittext android:id="@+id/edit_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/enter_the_value" android:drawableright="@drawable/ic_launcher" />

Paypal - Upgrade and Downgrade subscription -

i have 2 types of yearly subscription on website, 1 @ 99$ , 1 @ 299$. want user able upgrade/downgrade subscription when wants to. i've tried use "modify" option of paypal gives me possibility upgrade 20% every 180 days not need. i've searched web , find was: it's not possible use paypal payflow cancel , start new subscription the #2, can't find documentation. #3, don't want user cancel , ask him create new subscription. because if payed 99$ , after 3 months , wants change 299$ subscription, want able charge him 9/12 of 299$ left minus 9/12 of 99$ not suppose pay because switching subscription. (299*9/12 - 99*9/12 = amount left) anyone has way proceed? also, of shared links, in answers find, not valid anymore makes harder. when working standard subscriptions or express checkout w/ recurring payments run limitation you've described. if use payments pro, though, done on payflow gateway or dodirectpayment / createrecurringpayments...

Defining NULL for an array of pointers in C++ -

i wrote class in c++. in wrote: class node{ private: node*m[200]=null; }; (this part of class) receive errors. should defining array of pointers, null ? to make 200 pointers null, write: class node { node *m[200] = {}; }; this valid in c++11 , later.

Submit iOS apps update -

i planning apps update submission. however, new apps update need data patching on server. unable patch data immediately, because existing users old apps facing issues new data. any idea how resolve issue? you need maintain old data indefinitely. plenty of users not update apps (no matter how want them to. ) large variety of reasons. so time around should move new data different location (and reflect new location in app.) ensure old users maintain connection old data , new users can use new data. in future might prudent have app stop function when new dataset , application published , harass user update.

Why would there be a need to call a JavaScript function from code behind? -

i been looking around online calling javascript function code behind, examples have seen registerstartupscript method on click event. why want or need instead of wiring onclientclick event? there ever need call javascript function code behind? registerstartupscript 1 of many options infinite number of scenarios. in end, can registerstartupscript can done way. used consider convenience, avoid it, separation of concerns , such higher stages of "enlightenment". mainly see registerstartupscript still in use custom controls expected wire without end-user knowing them. see ajaxcontroltoolkit , updatepanel , scriptmanager , etc. require javascript obvious reasons not expect include client-side scripts or register them. random scenario: if (user.identity.name == "frank") registerstartupscript(this, gettype(), "frank", "alert("hey frank, owe me money!"); alternative scenario, have server-side set hidden field. <inpu...

angularjs - Apply a state class to ui-view to allow different ng animation -

i need apply different animations depending on current state using ui-view . following on this question.. i have following code (edit: see plunker preview ) <section ui-view ng-class="stateclass"></section> stateclass gets applied in each controller e.g: .controller('logincontroller', function($scope, $state) { // set state class name $scope.stateclass = 'slide-left'; console.log($scope); this works , class gets added fine - animation wont kick in. if update ui-view code to: <section ui-view class="slide-left"></section> with class hardcoded, works (but can't apply different animations). does ng-class added after ng-enter ? can suggest how achieve animations? edit>> oddly enough ng-leave animations work fine. css still doesn't apply ng-enter add ui-view following directive state-class : .directive('stateclass', ['$state', function($state) { retur...

Stuck in an Android Application Project -

in android app there 3 activities.. 1st 1 has username(textview , edittext),email(textview , edittext),password(textview , edittext).... 2nd 1 has alternate number(textview , edittext) user has enter these once when starts app first time(i.e once after download) , these should saved somewhere in storage.. 3rd activity displays these information along device id , sim number.. so when user starts app second time,directly 3rd activity should displayed..how can this??? the manifest make 3rd activity initial one. in 3rd activity's oncreate, check sharedpreferences if initialization has taken place. if not, start 1st activity. if yes, continue normally.

multiple inheritance - JAVA - extends vs interface - Strategy design pattern -

Image
i have scenario multiple concrete classes extends multiple abstract classes. @ loss come clean structure, reduce number of files , avoid code repetition. the ask display various sensor values in different ways based on criteria. sensor values temperature, voltage, current etc can have anlaog widget, numeric label or combination of both. have 3 abstract classes 3 different kind of views. these 3 abstract classes implement method defines how view drawn. each sensor view extends 3 abstract classes , implements methods read sensor, perform engineering conversion , display sensor value. problem here code implemented concrete classes same no matter abstract class extends. canalogtempview , cdigitaltempview , ccustomtempview have same implementation extend different classes. this seems awkward. code repeated , number of source files increases factor of 3. missing simple here? there pattern problem this? can extends sensor view classes @ run time? actual code more complicated...

pointers - Implement BST in c: segmentation fault -

i'm trying implement binary search tree in c. use lldb trace code , found out when function put return, return node pointer key = 5 , value = 9, , assigned node pointer p in main. however when pass tree_walk function , try print out everything, gave me segmentation fault. can please tell wrong code. thank you typedef struct node{ int key; int value; int size; struct node *left; struct node *right; }node; node* put(node **node, int k, int val){ if(*node == null){ node *newnode = (node *)malloc(sizeof(node*)); newnode->key = k; newnode->value = val; return newnode; }else if((*node)-> key == k){ (*node)->value = val; }else{ int cmp = k > ((*node)->key) ? 1 : 0; node **ptr = null; if(cmp == 1){ ptr = &((*node)->right); (*node)->right = put(ptr, k, val); }else{ ptr = &((*node)->left); (*node...

asp.net - AngularJS loads at the very end -

i making application using asp.net 4.5 web forms , angularjs 1.2. i encounter problem in web pages, angularjs takes time load , during time, curly brace template expressions not rendered correctly in page. i mean, these in page while angularjs still loading : {{exp1}} visit on {{date}} i pages page_load asp.net function lot of work, problem more prominent. these template expressions stay on page 3/4 seconds. i tried solve using loading gif, toggle visibility of loading gif using angular.js no either. use in body <body ng-cloak> </body> and in css [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; }

android - OnItemLongClickListener only deletes SD card file once, then no more -

i have arraylist<> in listview , need adapter. list items saved file in activity, , load sd card once cutecollection.java activity runs. put onitemlongclicklistener on each list item, when click it, item not removed list (the adapter), sd card. however, need not have full file name, when displaying title in listview , used substring take off file extension, works well. new problem developed... click listener wouldn't delete file sd card (since needs full file name extension know 1 delete). work around that, used title of file, , through stringbuilder , added .txt extension onto string. delete 1 item file, no more. before messed removing extension, worked fine. delete list item, long-clicking , pressing ok. anyone know why works once, doesn't delete anymore? remove item list (the adapter), when rerun activity, old ones load again (except first 1 deleted). tells me sd card had 1 deleted it. need able delete many want. help. update: i logged both singlefile ,...

java - Is there a way to limit the maximum number of processing records in a Job of Spring Batch? -

is there way limit maximum number of processing records in job of spring batch? i need have configuration control maximum number of records can processed job. the job reading database using stored procedure, limit maximum number of fetched rows in procedure itself, looking features provided in spring batch , not able find yet. write custom itemreader holds record count , return null ('stop reading') when limit reached. store variable used count records step-execution context. remember let custom itemreader implements itemstream : in manner sb save/restore record count into/from context automatically. hope clear, english not native language.

php - Display friend post according to the friend connected to each other? -

i have 2 tables in mysql frnd_request , nsm_post want show post according user share post primary school mate , secondary school mate etc. frnd_request table referece column user connected each other. table structure below 1 id 2 user_id 3 frnd_id 4 status 5 referece (how friend connected each other primay, secondary school mate) 6 confirmation 7 note 8 date nsm_post post table show_to field define friend group of logged in user can see post. 1 id 2 uid (user id of user posted post) 3 post 4 ip 5 show_to (to friend group post display) 6 img_video_name 7 date select nsm_post.post frnd_request, nsm_post frnd_request.user_id = nsm_post.uid this should work. guess trying restricting posts user's school mates. not possible current table structure. have setup additional table this: primary | uid1 | uid2 | type 0 | 10004 | 10005 | school mate

android - How to use getLastVisiblePosition? -

public void ongroupupdated(newgroupmessage msg) { if (!msg.getgroupid().equals(mgroupid)) { return; } else { boolean lastitemvisible = mlist.getlastvisibleposition() == madapter.getcount() - 2; updateconversation(); if (lastitemvisible) { smoothscrolltolast(); } } } i use above code judge if last item of listview visible. if visible, scroll list bottom. it works, don't know why must use madapter.getcount() - 2 instead of madapter.getcount() - 1 . sure header view count zero. the listview doesn't contains footer views. override onscroll method , following: @override public void onscroll(abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount) { if (listview.getlastvisibleposition() == listview.getadapter() .getcount() - 1 && listview.getchildat(listview.getchildcount() - 1) != null ...

html - CSS Button applies to every link, how do I stop this? -

i'm trying put link website applies whole css style button link, want plain text anchor link.. the css below, sorry it's alot of code, used button generator it.. i'm new this! a.nav { width: 80%; display: inline-block; list-style-type: none; margin-bottom: 10px; } nav ul { padding: 0; margin-bottom: 10px; display: inline-block; } a:hover { color: #900; background: #fff; } { -moz-box-shadow: inset 0px 1px 0px 0px #ffffff; -webkit-box-shadow: inset 0px 1px 0px 0px #ffffff; box-shadow: inset 0px 1px 0px 0px #ffffff; background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f9f9f9), color-stop(1, #e9e9e9)); background: -moz-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%); background: -webkit-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%); background: -o-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%); background: -ms-linear-gradient(top, #f9f9f9 5%...

android - Activity Launch Mode Single Instance Usage -

i have 2 activities. webviewactivity , camerapreviewactivity i should able switch between 2 activities on click of button. once have started camerapreviewactivity, further loads of activity should not take time initialize camera view. should getting resumed previous state. is idea keeping launch mode of both activities 'single instance' , start activities when respective button clicked? is idea keeping launch mode of both activities 'single instance' , start activities when button clicked yes, mark launchmode singleinstance in manifest, not call finish() method in of them. call activity there in stack.

android - Merging two audio files takes more time on Nexus -

in project working on audio , call recording functionality. need merge 2 audio files. merging have written following code: try { fileinputstream fistream1 = new fileinputstream(file1); // first // source file fileinputstream fistream2 = new fileinputstream(file2);// second // source file sequenceinputstream sistream = new sequenceinputstream(fistream1, fistream2); file audiodir = new file(environment.getexternalstoragedirectory(), constants.path_to_merged_audio); if (!audiodir.exists()) { audiodir.mkdirs(); } fileoutputstream fostream = new fileoutputstream(audiodir + "/mergedfile.wav");// destinationfile int temp; while ((temp = sistream.read()) != -1) { fostream.write(temp); // write file } fostream.close(); sistream.close(); fistream1.close(); fistream2.close(); } catch (exception e) { e.printsta...

jpa - orphan removal issue in hibernate 3.6.10 -

i facing issue orphan removal in hibernate. problem: have entity a, has 1 one relation entity b. i've used 1 one annotation orphan removal attribute ( @onetoone(cascade = cascadetype.all, orphanremoval = true) ). associated entity b referenced other entities too. while deleting entity a, getting constraint violation exception saying 'child record found'. want delete associated entity deleted, if not referenced other entities. if has existing association, don't want delete b, deleted. is there way this, using hibernate 3.6.10. read orphanremoval trick, didn't in case. any appreciated.. thanks ! if same b, there can 1 or more as, annotation should like: @entity public class { @manytoone private b b; } there no orphanremoval available in case, different expect. map reverse: @entity public class b { @onetomany(mappedby="b", orphanremoval=true) private list<a> alist; } which means: when removed list, enti...

parsing - how to parse inner level json objects if the keys are unknown in groovy -

i doing automation script in m getting inner levels json , keys unknown me how can parse json convert json map key value pairs contains json array json object want create them separately can distinguish b/w these. i m having json format as-: { "seatbid":[ { "bid":[ { "id":"1", "impid":"1", "price":3.5999999046325684, "nurl":"abc.com", "adomain":[ "zagg.com", "zagg.com" ], "iurl":"abc.com", "crid":"30364.s320x50m", "h":0, "w":0 } ], "group":0 } ], "cur":"usd", "nbr":0 } my code follows not wor...

android - How to open dialer on click of ListView -

i have 1 application in list view there in list view number , button there , want button click number goes dial screen... please suggest i think asking call functionality, try below code on button click, intent intent = new intent(intent.action_dial); intent.setdata(uri.parse("tel:" + "2356894745")); startactivity(intent);

javascript - How do you check the difference between an ECMAScript 6 class and function? -

in ecmascript 6 typeof of classes is, according specification, 'function' . however according specification not allowed call object created via class syntax normal function call. in other words, must use new keyword otherwise typeerror thrown. typeerror: classes can’t function-called so without using try catch, ugly , destroy performance, how can check see if function came class syntax or function syntax? i think simplest way check if function es6 class check result of .tostring() method. according es2015 spec : the string representation must have syntax of functiondeclaration functionexpression, generatordeclaration, generatorexpression, classdeclaration, classexpression, arrowfunction, methoddefinition, or generatormethod depending upon actual characteristics of object so check function looks pretty simple: function isclass(func) { return typeof func === 'function' && /^class\s/.test(function.prototype.tostring.call(fu...

javascript - Change font color and URL Dynamically -

i working on website (html+php) .here fiddle of have done far(sharing 1 example). each image should point different urls. there few images color matches font color.i want change font size/color image changes. url should change automatically image changes. html: <div class="grid"> <figure class="effect-lexi effect-chocolate"> <div id="cf3" class="shadow"> <img src="http://tympanus.net/development/hovereffectideas/img/22.jpg" alt="image" class="bottom" /> <img src="http://tympanus.net/development/hovereffectideas/img/21.jpg" alt="image" class="top" /> </div> <figcaption> <h2>dark <span>chocolate smoothie</span></h2> <p>description</p> <a href="#">view more</a> </figcaption> </fi...

regex - How to write a Regexp for any character, but it must be the same a specific number of times -

i want find strings same character multiple times in row. these can character (including null char), cannot specify character is, occurs 20 or more times in row. the dot "." matches character, how specify in regexp, must same character if don't know beforehand? example: bla bla blub oooooooooooooooooo must in xxxxxxxxxxxxxxxxx string. i want find o-s , x-s lines. ".{10,}" matches line. you can capture letter , use back-reference 9 times check if same letter repeated 10 times: /([a-za-z])\1{9,}/g regex demo ps: check of character use: /(.)\1{9,}/g

security - Python: Script to check for login attempts and auto hard disk wipe out -

i running on linux server ( debian ) , have encrypted hard disk cryptsetup . in order access hard disk, need decrypt password. however, in order protect hard disk in case being stolen, write script after hacker fails authenticate after 3 times (when password prompt decrypting hard disk), python script run , wipe out hard disk. is possible that? the concern have encryption key seems residing on hard disk itself, thus, not give me insurance hacker might hack using maybe brute force or etc. why there way trigger python script when fails login thrice?