Posts

Showing posts from July, 2013

javascript - Unmatched route angularjs (ui-router) -

i wrote in app.js file line of code: $urlrouterprovider.otherwise('/view1'); this htaccess file: <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] rewriterule ^(.*) /index.html [nc,l] </ifmodule> now, if try run myrul/invented_route response's server "not found" if otherwise route setted.

javascript - Sencha Touch infinite scroll paging issue -

i have followed tutorial making infinite scroll page in sencha touch (with page size of 25). though paging works perfectly, have been having trouble scroll position getting resetting top. workaround, have tried manually saving scroll position , setting again did not have desired effect. the code page follows: ext.define('rms.view.common.assetlistpanel', { extend: 'ext.panel', alias: 'widget.asset_list', requires: [ 'rms.model.assetmodel', 'ext.plugin.listpaging', 'ext.dataview.list', 'ext.field.search' ], config: { layout: 'fit', store: null, items: {} }, initialize: function () { ext.viewport.setmasked({ xtype: 'loadmask', message: 'fetching assets...' }); this.setitems( { xtype: 'list', id: 'lis', indexbar:false, grouped: false, store: this.config.store,

ios - Parse and FBv4 Swift share picture -

stuck on posting picture fb, using facebook sdk v4 , parsehelperv4 in swift. user created , logged in read persimmons , can user info mail name , on, fbsdkaccesstoken.currentaccesstoken() empty response fbsdksharingdelegate don`t have permission.... doing wrong? let permissions : nsarray = ["publish_actions"] pffacebookutils.linkuserinbackground(pfuser.currentuser(), withpublishpermissions: permissions, block: { (abool, error) -> void in if abool && error == nil { let atoken = fbsdkaccesstoken.currentaccesstoken() println(atoken.permissions) -- logging , returns empty not read permissions let fbphoto = fbsdksharephoto(image: self.topimageview.image, usergenerated: true) let atest : fbsdksharephotocontent = fbsdksharephotocontent() atest.photos = [fbphoto] fbsdkshareapi.sharewithcontent(atest, delegate

unix - "mailx" -r command not working -

i using below command mail 1 user attachment placed content mailx -r "sendermail@abc.com" -s "testing" "recievermailid@xyz.com" < emailmessagemail.txt and getting below error message.. mailx: invalid option -- r usage: mail [-iinv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ... [-- sendmail-options ...] mail [-iinnv] -f [name] mail [-iinnv] [-u user] can please advise.. in advance just install sudo apt-get install heirloom-mailx bsd-mailx doesn't have option. in order check use command: dpkg -s $(readlink -e $(which mailx))

javascript - Bootstrap 3 Datetimepicker auto submit -

i can't find way submit form after selecting date via bootstrap 3 datetimepicker (eonasdan) without having click button. wonder if possible. please, have @ code. <div class="container"> <div class="row"> <div class='col-md-3'> <form action="date.php" method="post" class="form"> <div class="form-group"> <div class='input-group dp1'> <input type='text' class="form-control" name="startdate" id="start" > <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span> </div> <button class="btn btn-primary">submit</button> </div> </form> &

sockets - Problems with Android Bluetooth Server and Client -

i have couple problems regarding creating bluetooth server , client multiplayer game i'm making. first problem have searching devices. google provides following code: // create broadcastreceiver action_found private final broadcastreceiver mreceiver = new broadcastreceiver() { public void onreceive(context context, intent intent) { string action = intent.getaction(); // when discovery finds device if (bluetoothdevice.action_found.equals(action)) { // bluetoothdevice object intent bluetoothdevice device = intent.getparcelableextra(bluetoothdevice.extra_device); // add name , address array adapter show in listview marrayadapter.add(device.getname() + "\n" + device.getaddress()); } } }; // register broadcastreceiver intentfilter filter = new intentfilter(bluetoothdevice.action_found); registerreceiver(mreceiver, filter); // don't forget unregister during ondestroy but can'

tesseract - PHP TesseractOCR exec command issue -

i have installed tesseractocr terminal of mac. when run following command terminal working. tesseract "hello.png" /applications/mamp/tmp/php/987051047 but same command not working in exec("tesseract "hello.png" /applications/mamp/tmp/php/987051047") and full code $tesseract = new tesseractocr("hello.png"); $tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(); $tesseract->settempdir( $tmp_dir ); $test = $tesseract->recognize(); i feel have load tesseract in php.ini or other configuration file. don't know where. using mac, mamp, php 5.4.10 ok after installation need change path bin $path = getenv('path'); putenv("path=$path:/usr/local/bin"); add these lines , work thanks

ios - UIAlertView with multiple text inputs? -

uialertview *alert = [[uialertview alloc]initwithtitle:@"add new work order (test)" message:@"please fill out fields" delegate:self cancelbuttontitle:@"add" otherbuttontitles: nil]; alert.alertviewstyle = uialertviewstyleplaintextinput; uitextfield *alerttextfieldname = [alert textfieldatindex:0]; alerttextfieldname.placeholder = @"work order name"; alerttextfieldname.keyboardtype = uikeyboardtypedefault; uitextfield *alerttextfieldprojectno = [alert textfieldatindex:1]; alerttextfieldprojectno.placeholder = @"projectno"; alerttextfieldprojectno.keyboardtype = uikeyboardtypedefault; uitextfield *alerttextfieldsubname = [alert textfieldatindex:2]; alerttextfieldsubname.placeholder = @"sub account name"; alerttextfieldsubname.keyboardtype = uikeyboardtypedefault; [alert show]; im trying error: nsrangeexception', reason: '*** -[__nsarraym objectatindex:]: index 1 beyond bounds [0 .. 0]' shouldn't able

find text from visible HTML in python -

i'm trying following: i have text file have values line line. a website generate list of values based on page number. values xxx & yyy in example below. python script reads first text file (efficient 0(1) lookups using set) , search in website page after page +1, , if value match found must print page number. the search must www.site.com/1 www.site.com/2 www.site.com/3 ...etc html source: <pre class="values"> <strong>a</strong> <strong>b</strong> <strong>c</strong> <span id="1"> <a href="/#">+</a> <span title="1">1</span> <a href="/#">xxx</a> <a href="/#">yyy</a> </span> </pre> text file efficient 0(1) lookups using set: with open("values.txt", "r") f1: lines = set(f1) # efficient 0(1) lookups using set li

javascript - Handling unknown number of form values -

Image
i have form which, besides other properties, has link, open modal window enter additional information. additional information unknown when form generated, need generate these items once have been created. thinking might append <form> , wrap <div> every pair of data entered in <div> , , calculate how data entered. my form looks my question is: h ow handle scenario? please ask if left unclear. the question seemed js specific , have not added of asp mvc stuff in snippet , worked around functionality of adding shoes. have take account list needs posted server save changes. think outside scope of question $(function (){ // shoe add $('#savevalue').click(function(){ // shoe name var shoename = $('.modal-body input:first').val(); // shoe number var shoenum = $('.modal-body input:last').val(); // create structure add list $('#addedvalues ul').append("<li>

php - The advantage of having another table for multiple product images? -

this product table in mysql create table if not exists `tbl_products` ( `productid` int(11) unsigned not null auto_increment, `productsku` varchar(6) collate utf8_bin not null, `productname` varchar(75) character set utf8 collate utf8_unicode_ci not null, `productdescription` text character set utf8 collate utf8_unicode_ci not null, `extraspecification` text collate utf8_bin, `productprice` decimal(10,2) not null default '0.00', `mrp` decimal(10,2) not null default '0.00', `productimage` varchar(300) collate utf8_bin not null, `pagetitle` varchar(75) collate utf8_bin not null, `productkeywords` varchar(250) collate utf8_bin not null, `metadescription` varchar(250) collate utf8_bin not null, `dateadded` timestamp not null default current_timestamp on update current_timestamp, `addedby` varchar(300) collate utf8_bin not null, primary key (`productid`), unique key `productname` (`productname`), fulltext key `productname_2` (`productnam

invoke a javascript function through php -

this question has answer here: how call javascript function php? 11 answers i want invoke javascript function php, php script included before javascript. <script type="text/javascript"> function myjsfunction(){ //js code } </script> slightly odd question... if want call js function on page load add bottom of dom on page load page created php script... instance... <script> window.onload = function() { yourfunction(param1, param2); }; </script>

openCV video saving in python -

i trying save video it's not working. followed instructions opencv documentation. import numpy np import cv2 cap = cv2.videocapture(0) fourcc = cv2.videowriter_fourcc(*'xvid') out = cv2.videowriter('output.avi', fourcc, 20.0, (640,480)) while(cap.isopened()): ret, frame = cap.read() if ret==true: frame = cv2.flip(frame,0) out.write(frame) cv2.imshow('frame',frame) if cv2.waitkey(1) & 0xff == ord('q'): break else: break cap.release() out.release() cv2.destroyallwindows() what wrong? try . it's working me. import numpy np import cv2 cap = cv2.videocapture(0) # define codec , create videowriter object #fourcc = cv2.cv.cv_fourcc(*'divx') #out = cv2.videowriter('output.avi',fourcc, 20.0, (640,480)) out = cv2.videowriter('output.avi', -1, 20.0, (640,480)) while(cap.isopened()): ret, frame = cap.read() if ret==true: f

python - Create a Numpy Array from particular text format -

i have text file containing training vectors <vector 1-dimension 1> <vector 1 - dimension 2> .... <vector 1 - dimension n> ............. ............. ............. ............. ............. <vector m - dimension 1> <vector m - dimension 2> .... <vector m - dimension n> another text file mentions class memberships of corresponding vectors vector1-class vector2-class ............. vector n - class now, need convert these numpy arrays x , y, can give them input scikit learn linear svm function ; example in python code, from sklearn import svm x = [[1,1], [1,-1], [-1,1], [-1,-1]] y = [0, 1, 2, 3] clf = svm.svc() clf.fit(x, y) how can achieve this? after bit of research, have used x = np.genfromtxt("x.txt",delimiter=" ") y = np.genfromtxt("y.txt",delimiter=" ") to achieve same. is there better way achieve same? if textfile written in sparse format, is, if no

Haskell - "Non-exhaustive patterns" error with a function using list -

i'm trying make function in haskell know if elements in list of list have same length. (i've search answers in previous posts none of them works). samelength :: [[t]] -> string samelength [] = "empty list" samelength [[items]] | , $ map (\x -> length x == (length $ head [[items]])) [[items]] = "same length" | otherwise = "not same length" the problem doesn't work : *main> :l test.hs [1 of 1] compiling main ( test.hs, interpreted ) ok, modules loaded: main. *main> samelength [] "empty list" *main> samelength [[1,2],[3,4]] "*** exception: test.hs:(2,1)-(5,39): non-exhaustive patterns in function samelength *main> samelength [[1,2]] "*** exception: test.hs:(2,1)-(5,39): non-exhaustive patterns in function samelength i don't see problem. treat case in parameter empty list , in not. wrong ? did miss ? thanks :) you have many [..] in here: samelength [[items]]

javascript - Replacing Div on Submit Not Submitting Form -

i trying replace form div message working, reason it's stopped onsubmit working in form, message displayed form hasn't submit. here form: <div id="domsearch" class="grid_4 right" style="padding-left:20px;padding-top:30px;"> <form action='/dac' id="dac" onsubmit="return check_domain_input()" accept-charset='utf-8'> <input name="domain" class="searchdom" value="www." onclick="this.value=''"/> <input type="submit" class="grey-big-button-submit" id="search" name="search" value="search"/> </form> </div> and here js swap div: $("#dac").submit(function (event) { $("#domsearch").slideup("slow", function () { $(this).replacewith( "<div id='loading' style='float:right;'>" +

c# - How to fix this issue with ASP.NET Menu Control? -

i new asp.net web forms developer , struggling in hiding , showing asp.net menu control items based on user role. roles defined me in database , based on result of checking role of user, system should show or hide of menu items. i have following asp.net menu control in master page: <asp:menu id="menu" runat="server" pathseparator="," orientation="horizontal" enableviewstate="false"> <items> <asp:menuitem text="home" navigateurl="~/pages/default.aspx" value="home"></asp:menuitem> <asp:menuitem text="sheet" navigateurl="~/pages/sheet.aspx" value="sheet"></asp:menuitem> <asp:menuitem text="test" navigateurl="~/pages/test.aspx" value="test"></asp:menuitem> </items> </asp:menu> and in code-behind of master page doing following logic: protected void me

java - which is better setExtendedState(JFrame.MAXIMIZED_BOTH) or GraphicsDevice device? -

i planning on making full screen application in java. have come across 2 sets of ways make application full screen. 1. frame.setextendedstate(jframe.maximized_both) 2. graphicsdevice device = graphicsenvironment.getlocalgraphicsenvironment().getscreendevices()[0]; device.setfullscreenwindow(frame); both of these same make frame full screen. know of these better? if use application on different screen resolution behave same .example projectors etc approach 2. preferred. best thing check if fullscreen mode available: if (device.isfullscreensupported()) { device.setfullscreenwindow(frame); } else { frame.setextendedstate(jframe.maximized_both); } maximizing frame equivalent of double-clicking title bar. not fill parts of screen used desktop's taskbar or other reserved areas, , decorations (title bar, border, close/minimize/maximize buttons) still visible, not want.

javascript - Compare strings that have white space on the left side -

hello comparing 2 strings.. how identify both deference/same if 1 having white space like, a=ashus<br> b=ashus (second 1 white space on left side) now want check whether both values same or not.(according code, both different) if($qopt1a==$qopt2a or $qopt1a==$qopt3a or $qopt1a==$qopt4a or $qopt2a==$qopt3a or $qopt2a==$qopt4a or $qopt4a==$qopt3a){ echo "<script> alert('option should not same'); </script>"; } what need trim() . it'll remove white space on both sides, if want remove white space in left side can use ltrim()

asp.net mvc - Why does the role claim have incorrect type? -

i downloaded webapp-roleclaims-dotnet sample application , somehow cannot work. the page has following rather straightforward piece of code: claimsidentity claimsid = claimsprincipal.current.identity claimsidentity; var approles = new list<string>(); foreach (claim claim in claimsprincipal.current.findall(claimsid.roleclaimtype)) approles.add(claim.value); viewdata["approles"] = approles; return view(); now, expression claimsprincipal.current.findall(claimsid.roleclaimtype) returns empty list, though have proper roles assigned. this guess, because -- according debugger -- role claim have type roles instead of proper namespace http://schemas.microsoft.com/ws/2008/06/identity/claims/role . what missing? did ever working? i found worked: claimsidentity id = claimsprincipal.current.identity claimsidentity; var approles = new list<string>(); foreach (claim claim in

ruby on rails - Linking HABTM Attribute -

i'm trying create link new page displays posts belong category. they're both connected via habtm relationship can see below. category.rb class category < activerecord::base has_and_belongs_to_many :posts end post.rb class post < activerecord::base has_and_belongs_to_many :categories belongs_to :user end index.html.erb <%= post.categories.collect(&:name).join(",") %> how go creating link posts category attribute page displays posts category? any brilliant! thanks this should work: <% post.categories.each |category| %> <% category.posts.each |post| %> <%= link_to post.title, post_url %> <% end %> <% end %> change post.title , post_url appropriately.

android activity - listView- how can you make each item clickable -

i have list of items on listview when 1 pressed open new activity. can help? this question potentially google-able i'll put code here anyway. listview can have listener attached listens clicks of list items: listview.setonitemclicklistener(new listview.onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { youritemtype item = (youritemtype)parent.getadapter().get(position); yourinfo info = item.getinfo(); intent intent; //instantiate intent here info startactivity(intent); } });

ruby on rails - How can I get the carousel to work in landing_page.html.erb without changing the products index view? -

Image
i'm trying pull first 3 or 4 products database , display them individual slides, content (image, name, description, link) populated dynamically. if products ever updated, new ones appear on homepage without needing modify code. i'm getting error in screen shot attached. changed landing_page.html.erb @ https://gist.github.com/faisal-hassan/fc0f19c6efe3fe8756d4 , products controller @ https://gist.github.com/faisal-hassan/828793f22ebb88fcbcc6 . products index , rest of unchanged files on @ https://github.com/faisal-hassan/vzncommerce . you have controllers messed up. page using ( landing_page ) under static pages controller. therefore, code loads @products object should in static pages controller, not in products controller. in static pages controller, landing_page code should this: class staticpagescontroller < applicationcontroller def landing_page @products = product.limit(3) end end

json - How can I resolve "Your requirements could not be resolved to an installable set of packages" error? -

Image
when run composer update receive wired output. here composer.json like. how fix ? your software dependencies have incompatible version conflict. at same time want install laravel 4.2.x version, , "zizaco/entrust" it's master branch. , master branch requires @ least laravel 5.0 (roughly speaking). the problem comes dependency on branches. it's package zizaco/entrust once using laravel 4.2 in it's master branch, , able install dependencies @ day. moment branch gets updated incompatible version requirement, never ever able run composer update , updated dependencies. always use tagged versions! ideally use relaxed version requirement allows compatible updates. should expressed tilde-two-number version requirement: ~1.2 install version 1.2.0 , (like 1.2.99 or 1.2.100), , 1.3 , up. if need patch release: caret-three-number version ^1.2.10 install 1.2.10 or up, 1.3 , up. using version requirement instead of dev-master allow use released

android - java.io.FileNotFoundException when writing to internal memory -

i've written functions making/editing files , worked fine. however, needed use these function in many activities, i've found guide on how globalize functions, , somehow did it. after put functions in separate class, stopped working. logcat not working, can't trycatch it, if could, don't think me. here part of mainactivity.java: myhelper myhelp = new myhelper(this); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); myhelp.synchronizedb("filename"); } here part of myhelper.java: public class myhelper extends actionbaractivity { context mcontext; public myhelper(context context){ this.mcontext = context; } public void writefile(string fname, string fcontent) { bufferedwriter bw = new bufferedwriter(new outputstreamwriter(openfileoutput(fname, mode_append))); bw.write(fcontent); bw.close(); } public void synchronizedb(string filename

activerecord - rails models: can be foreign key null? -

i have event table , place table. events belongs places , while others don't. decided create table: placed_event = events belongs place . question is: should keep way or have placed_event table , delete events table, placed_events have foreign key null - i.e. not belong place? the answer "it depends." if events can in 0 or 1 places, having events table foreign key places table work fine; mohammad said in comment, if place_id null, event doesn't have place. if events can spread across more 1 place, concert many stages, that's when having join table make sense. hope helps.

How to get paper-radio-button, paper-checkbox or core-dropdown-menu values with PHP $_GET after submitting a form -

i using php programmation language adapting mvc architecture. , polymer library view. i found problems particularly when used polymer elements in form . if use paper-radio-button , paper-checkbox or core-dropdown-menu , example, i can not fetch them $ _get or $ _post the elements mentioned don't function normal form elements. have bind values hidden field: <paper-checkbox checked?="{{ischecked}}"></paper-checkbox> <input type="hidden" name="foo" value="{{ischecked}}"> or otherwise serialize/aggregate values them.

wordpress - Fatal error:Call to a member function add_to_cart_url() on a non-object in wp-content/themes/vantage/functions.php on line 398 -

so wanted display price of product in add cart button , followed instruction woocommerce display price on add cart button when refreshed page saw error , sad now. , dont understand edit in answer mean. deleted code took tutorial still error. i desperate , fatal error tells error on line 398 , there 397 lines , maybe deleted curly bracket? and tried find problem of debugger , error https:// ideone.com / ug95gc think better dont post 400 lines of code here so debuggers show problem here if( file_exists( get_template_directory() . '/premium/functions.php' ) ){ include get_template_directory() . '/premium/functions.php'; } else { include get_template_directory() . '/upgrade/upgrade.php'; } so replaced functions.php , problem in solution in woocommerce display price on add cart button , deleted thouse lines of code , smooth.

How to write html code inside a php file -

i want write html form inside login.php , submit in login.php .so how can write html inside php file?if write tag shows error. <?php // php code here ?> html code here <?php // more php code here ?> more html code here if plan use php code anywhere in file, use .php file extension.

html - I was trying to pass a parameter from from view to another ,But I am getting a wrong output? -

what trying , print table:- id content have_read created_at updated_at 1 xyz xxx qwe 0 xxxx xxxx 2 xyz xxx yyy 1 xxxx xxxx 3 xyt xxx xxx 0 xxxx xxxx when user clicks on id , link new page . , there display details of row selected . this html file table:- <% @messages.each |m| %> <% if m.to == get_user %> <tr> <td><font color="blue"><%= link_to m.id, show_message_path(m) %></font></td> <td><%=m.from%></td> <td><%=m.subject%></td> <td><%=m.created_at%></td> </tr> <% end %> <% end %> i using " show_message_path(m)" pass selected row. my controller :- class messagescontroller < applicationcontroller def new @messages = message.all end def show_message

Troubleshooting Unicode string behavior when updating Python 2.x->3.x -

i using python 2.7 in project , since have seen python 3.5 coming soon, decided upgrade python interpreter. i using base64 encoding. since string objects somehow different in new python versions, getting following error: typeerror: 'str' not support buffer interface i have found out have encode string before passing function ( 'string'.encode() ), isn't there way encode string automatically unicode or something? in python 3, str means "unicode text" -- whether express 'mystring' or u'mystring' makes no difference (the latter tolerated facilitate porting/coexistence python 2). to indicate binary string of bytes , you'd use b'mystring' instead. as https://docs.python.org/3/library/base64.html puts it, this module provides functions encoding binary data (my emphasis) -- nothing text (i.e unicode) data. logical consequence, functions in module expect or return byte strings. not sure why can

can't redefine infix + operator in swift -

i wanted able add 2 (int,int) tuples. defined func + (left:(int,int), right:(int,int))->(int,int) { return (left.0+right.0,left.1+right.1) } but xcode not happy, saying "consecutive declarations on line must sparated ';' ". what's wrong infix operation? ok, leave question on since others may find useful, found answer. turns out operators can defined in global scope - @ least that's xcode told me. moved definition of + out of class in, , works. i'm still not sure if want define operator on struct, say, defined within class, hey, needed int tuples...

c# - Trying to launch a projectile towards a gameobject, doesn't move!= -

i'm making 2d tower defense game , want towers launch prefab @ minions. spawns desired prefab, doesn't move it. my 2 scripts: public class attacker : monobehaviour { // public variables public gameobject ammoprefab; public float reloadtime; public float projectilespeed; // private variables private transform target; // use initialization void start () { } // update called once per frame void update () { } void ontriggerenter(collider co){ if (co.gameobject.tag == "enemy" || co.gameobject.tag == "blocktower") { debug.log("enemy tag detected"); if(this.gameobject.tag == "enemy" && co.gameobject.tag != "enemy"){ debug.log("this enemy"); // insert enemey attack block towers. } if(this.gameobject.tag == "tower" && co.gameobject.tag != "blocktower"){ debug.log("this tower"); tower

javascript - Is there a way to use jquery map text into json from a string? -

first of all, asking question due broken api of petfinder. working on rabbit rescue app (its web interface) , need of petfinder's search results. fix public api soon, meanwhile using php load html content of search results , turn json front end display. the current method use load page invisible div tag , use jquery selector map content. not efficient because load of original script , css files petfinder. able manipulate string directly. here of examples: original code structure: <html> <head> ... </head> <body style="background:#ffffff"> <style type="text/css"> ... </style> <body bgcolor="#ffffff" text="#000000" > <table> ... ... <tr class = "pfrow2"> <td><a href="//www.petfinder.com/petdetail/30773115" class="pflink" target="_blank">

python - Search for same values in 2 lists but only once if duplicate -

lst1 = [0.0, 2.0, 2.0, 3.0, 4.0, 6.0, 6.0, 7.0, 8.0, 8.0, 10.0, 10.0, 10.0, 13.0] lst2 = [4., 8.] [i i, j in enumerate(lst1) if j in lst2] i return of: [4, 8, 9] what want achieve want return of: [4, 8] because 8.0 repeated in lst1 , want once. best way of achieving this? the best way can readily think of is, maintain set of seen numbers , if number not in seen set add index result , number seen set. result, seen = [], set() index, item in enumerate(lst1): if item not in seen , item in lst2: result.append(index) seen.add(item) print(result) # [4, 8] note 1: use set maintaining seen items, because lookups fast (constant time lookup) note 2: if lst2 going long list, better convert set, item in lst2 lookup happen in constant time. actual code becomes, result, seen, set2 = [], set(), set(lst2) index, item in enumerate(lst1): if item not in seen , item in set2: result.append(index) seen.add(item) print(result

hibernate - Disabling JPA second level cache is not working -

i use hibernate jpa web application , use apache tomcat web server. problem is, after updating entity obj, call function entity list. in entity list, see old object instead of updated one. i check in database , record updated already. entitymanager returning old object. here persistence.xml : <?xml version="1.0" encoding="utf-8" ?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="default" transaction-type="resource_local"> <description> persistence unit envers tutorial of hibernate getting started guide </description> <provider>org.hibernate.jpa.hibernatepersistenceprovider</provider> <jar-file>d:

file upload - Image validation not working If using ajaxForm -

Image
i tried googling , saw other questions posted @ forum not find solution issue. using jquery ajaxform method submit form. form contains 1 file field in form can used upload picture. have defined validation in model. issue uploading correct jpg file, still getting error message argument 1 passed illuminate\\validation\\factory::make() must of type array, object given. javascript code $('#create_form').ajaxform({ datatype:'json', success: function(response){ alert(response); } }).submit(); controllder code if ($file = input::file('picture')) { $validator = validator::make($file, user::$file_rules); if ($validator->fails()) { $messages = $validator->messages(); foreach ($messages->all(':message') $message) { echo $message; exit; } return response::json(array('message'=>$response, 'status'=>'failure')); } else { //

android - What Are the Differences Between FLAG_ACTIVITY_RESET_TASK_IF_NEEDED and FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP? -

i in process of (finally) writing chapter on tasks book, , encountering few lingering puzzles. things serve home screen launchers seem use combination of flag_activity_new_task , flag_activity_reset_task_if_needed when launch requested launcher activity: intent i=new intent(intent.action_main); i.addcategory(intent.category_launcher); i.setflags(intent.flag_activity_new_task | intent.flag_activity_reset_task_if_needed); i.setcomponent(name); startactivity(i); the documentation flag_activity_reset_task_if_needed has: if set, , activity either being started in new task or bringing top existing task, launched front door of task. result in application of affinities needed have task in proper state (either moving activities or it), or resetting task initial state if needed. that's not clear. in particular, seem same effects seen using combination of flag_activity_clear_top , flag_activity_single_top . quoting docs flag_activity_clear_top : if

java - Display table data from mysql to jsp page -

i have <%@ page import="com.mysql.*" %> <%@ page import="java.sql.*" %> <html> <body> <div id="content"> <p>displaying table contents: </p> <table border="0" cellpadding="10"> <thead> <tr> <th>id</th> <th>name</th> <th>company</th> <th>salary</th> </tr> </thead> <tbody> <% class.forname("com.mysql.jdbc.driver"); connection conn = null; conn = drivermanager.getconnection("jdbc:mysql://localhost:8080/connection", "username", "password"); statement stmt = null; stmt = conn.createstatement(); string query = "select * employeee";

autohotkeys using ifwinactive with expression not working -

i using autohotkeys test if window active along expression. don't seem able work. assigning expression variable , testing ifwinactive , variable. autohotkeys doesn't seem able evaluate expression correctly. script: ^w:: ;hotkey fires done = false settimer, checkpopups, 10000 ; check every 10 seconds window checkpopups: := (done != true) #ifwinactive "volume spike - down" , { ;specific lines when active window true , done false msgbox hello done := true } ifwinnotactive volume spike - down { done = false } when launch script , window not active, shows message box hello. 10 seconds later shows again. should show message box if window active , done = false. idea doing wrong? you're using #ifwinactive , a directive used create conditional hotkeys . should use ifwinactive instead. you can use function version, winactive() inside if-clause. makes little cleaner in opinion. here's short example: #persistent done := false

objective c - Send Data to View Controller of choice -

i trying perform know simple, yet not sure of syntax. first, user input facebook login info, signs them in. code pulls profile picture, username, email, , facebook button , displays in "loginiewcontroller". prof pic view controller called profilepicture , username called lblusername , email lblemail , , fb button called loginbutton . all want write code sends these 4 values profileviewcontroller, not next view controller segue, displays profile picture, username, email , * logout * button. below code loginviewcontroller: ***fyi, code shows initial view of fb login button, regular login button, , sign button, profile picture view, username, , email hidden start. once logged in, have same view controller show profile picture, username, , email, hiding ever login button *not *clicked. #import "loginviewcontroller.h" @interface loginviewcontroller () @end @implementation loginviewcontroller - (void)viewdidload { [super viewdidload]; nologin.la