Posts

Showing posts from September, 2012

FORTRAN logic notproblem -

if use function once, works properly. if make loop down below, 4 lines of commented code, code malfunctions. can't figure out why return t or f every other number after initial value. asterisks in parenthesis of write , read doesn't show here reason. program prime integer :: n = 0, = 1,x = 0 logical :: ip write (*,*) "enter number:" read (*,*) n !do while ( n < 1000) ip = isprime(n) write (*,*) ip, n !n = n + 1 !end read(*,*) x contains function isprime(n) logical :: isprime integer, intent(in) :: n isprime = .true. if (n == 2) write (*,*) n else while (i <= (n/2)) = + 2 if (mod(n,i) == 0) isprime = .false. end if end end if return end function isprime end program prime you're forgetting reset i 1 during each call isprime . the first time isprime called, i=1 top of program main . however, i incremented during first isprime call other 1 second call starts i/=0 . note because isprime contai

python - Break Existing Dataframe Apart Based on Multi Index -

i have existing dataframe sorted this: in [3]: result_gb_daily_average out[3]: nrel avert month day 1 1 14.718417 37.250000 2 40.381167 45.250000 3 42.512646 40.666667 4 12.166896 31.583333 5 14.583208 50.416667 6 34.238000 45.333333 7 45.581229 29.125000 8 60.548479 27.916667 9 48.061583 34.041667 10 20.606958 37.583333 11 5.418833 70.833333 12 51.261375 43.208333 13 21.796771 42.541667 14 27.118979 41.958333 15 8.230542 43.625000 16 14.233958 48.708333 17 28.345875 51.125000 18 43.896375 55.500000 19 95.800542 44.500000 20 53.763104 39.958333 21 26.171437 50.958333 22 20.372688 66.916667 23 20.594042 42.541667 24 16.889083 48.083333 25 16.416479 42.125000 26 28.459625 40.125000 27 1.055229 49.833333 28

java - Apache Tiles - HTTP Status 500 - Servlet.init() for servlet dispatcher threw exception -

i want use apache tiles in spring project. added these dependencies pom.xml file: <dependency> <groupid>org.apache.tiles</groupid> <artifactid>tiles-api</artifactid> <version>3.0.5</version> </dependency> <dependency> <groupid>org.apache.tiles</groupid> <artifactid>tiles-core</artifactid> <version>3.0.5</version> </dependency> <dependency> <groupid>org.apache.tiles</groupid> <artifactid>tiles-jsp</artifactid> <version>3.0.5</version> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-log4j12</artifactid> <version>1.7.6</version> </dependency> that's dispatcher-servlet.xml file: <beans xmlns="http://www.springframework.or

mysql - Trigger to change all the rows after an update is done -

having table name transitions , i want change values of rows after update made. i'm using following trigger, changes row i'm making update to. create trigger signaturetrigger before update on `transactions` each row begin set new.signature = '288'; end i'm trying change rows signature = 288 , how can modify trigger in order archieve that? thought using for each row enough. thanks in advance. you can use after update trigger update statement: create trigger signaturetrigger after update on `transactions` each row begin update transactions set new.signature = '288'; end; this seem strange thing do, however. consider alternative: add updatedat column table , update signature in row. then, when want recent signature use: select signature transactions order updatedat desc limit 1; an index on transactions(updatedat, signature) make quite speedy. and, update go much, faster updating rows.

JAVA JFileChooser Window showing on last place -

don't know how ask /english isn't mother language :)/, i'm adding screenshot show this. when use jfilechooser, opens dialog window on last place /see screenshot/, not in front place - have click on last window, window, not showing first window = doesn't "pop up" after run program. enter image description here it works fine, when use in main, when use in method, doing this. import javax.swing.jdialog; import javax.swing.jfilechooser; public class jframechooser { public static void vybersuboru() { jfilechooser filechooser = new jfilechooser(); jdialog dialog = new jdialog(); int result = filechooser.showopendialog(dialog); if (result == jfilechooser.approve_option) { system.out.println(filechooser.getselectedfile().getabsolutepath()); } } } you creating file chooser newly created dialog empty , not visible. instead use applications's main window parent. something wa

google maps - I can not use feature.get Geometry () in a MultiLineString -

i'm plotting geojson on map using google maps api v3. point of layers functioning normally. have multilinestring camda , center map on geometry gives error.this occurs polygon, points works well. there other way centralize multilinestring , polygons? google.maps.event.addlistener(cicloviaslayer, 'addfeature', function (e) { console.log(e.feature.getgeometry().gettype()); // multilinestring ok! map.setcenter(e.feature.getgeometry().get()); }); erro: e.feature.getgeometry(...).get not function the data.multilinestring class doesn't have get method, has getat , getarray methods. getat(n:number) return value: data.linestring returns n-th contained data.linestring. the returned linestring has getat method returns google.maps.latlng object getat(n:number) return value: latlng returns n-th contained latlng. google.maps.event.addlistener(cicloviaslayer, 'addfeature', function (e) {

oracle - stored procedure using the IF NOT EXISTS -

Image
i researching issues regarding oracle. i'm creating stored procedures , boot following errors show them in picture, hope me resolve error. [ ] you can add variable v_count number :=0; in procedure check if value exists. example: create or replace procedure procedure_name(parameters) v_count number := 0; begin select count(1) v_count your_table .. . if v_count = 0 insert ... elsif update ... commit; end if; end;

php - I am trying to perform a cross domain ajax request from a phonegap app and its not working -

i trying perform cross domain ajax request phonegap app , not working. trying submit form data database. have uploaded test domain using on server , works on mobile browser not when package phonegap. have looked on stackoverflow , can't find solution. help. html: <form id="uploadimage" method="post" action="" enctype="multipart/form-data" > <label>name</label> <input type="text" name="product_name" id="product_name" size="50"/> <label>image</label> <input type="file" id="image_file" name="image_file"/> <input type="submit" class="button_style" value="add item"> </form> jquery: $(document).ready(function() { //detect deviceready event , call ondeviceready function document.addeventlistener("deviceready", ondevi

Generate a random double between -1 and 1 in Swift -

this 1 should quite simple somehow can't find way this: have random double between -1 , 1. everything found on internet either integers, 0 1 or didn't work. i hope of guys can me! let = (double(arc4random()) / double(uint32.max)) * 2 - 1 ps: use uint32.max swifty code ;)

javascript - Web API - Reserved Word? -

**have simple web api: webapiconfig.cs: config.routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{action}/{id}", defaults: new { id = routeparameter.optional}); i can make calls web api calling via data service controller: [httpget] public httpresponsemessage getusers(string id) { var cl = _securityrepository.getusers(id); return request.createresponse(httpstatuscode.ok, cl); } logic simple: searches db last names start last 3 letter in id the call: http://example.com/api/dataservice/getusers/lop the results: [ { "userid": "dlopez", "firstname": "don", "lastname": "lopez", "department": "information technology" }, { "userid": "sloper", "firstname": "steve", "lastname": "loper", "department": "first services&

bottom sheet - android BottomSheet how to collapse when clicked outside? -

i have implemented bottomsheet behavior nestedscrollview. , wondering if possible hide bottomsheet view when touched outside. finally able this, used following lines of code: @override public boolean dispatchtouchevent(motionevent event){ if (event.getaction() == motionevent.action_down) { if (mbottomsheetbehavior.getstate()==bottomsheetbehavior.state_expanded) { rect outrect = new rect(); bottomsheet.getglobalvisiblerect(outrect); if(!outrect.contains((int)event.getrawx(), (int)event.getrawy())) mbottomsheetbehavior.setstate(bottomsheetbehavior.state_collapsed); } } return super.dispatchtouchevent(event); }

polynomials - What is the Numerically Stable Way to Compute the Coefficients of a Quadratic Function from Three Points -

i compute coefficients a0 , a1 , , a2 of quadradic function (polynomial of degree 2) given 3 points (x0, y0) , (x1, y1) , , (x2, y2) , yi = a0 + a1*xi + a2*xi*xi ? i have tried following 2 formulas, not impressed precision of output final double x0mx1, x0mx2, x1mx2, t0, t1, t2; double a2, a1, a0; x0mx1 = (x0 - x1); x0mx2 = (x0 - x2); x1mx2 = (x1 - x2); // method 1 t0 = (y0 / (x0mx1 * x0mx2)); t1 = (y1 / (-x0mx1 * x1mx2)); t2 = (y2 / (x0mx2 * x1mx2)); a2 = (t0 + t1 + t2); a1 = -((t0 * (x1 + x2)) + (t1 * (x0 + x2)) + (t2 * (x0 + x1))); a0 = (t0 * x1 * x2) + (t1 * x0 * x2) + (t2 * x0 * x1); // method 2 a2 = ((((y1 - y0) * (x0mx2)) + ((y2 - y0) * ((-x0mx1)))) / (((x0mx2) * ((x1 * x1) - (x0 * x0))) + (((-x0mx1)) * ((x2 * x2) - (x0 * x0))))); a1 = (((y1 - y0) - (a2 * ((x1 * x1) - (x0 * x0)))) / ((-x0mx1))); a0 = y0 - (a2 * x0 * x0) - (a1 * x0); the results sort of fit, i.e., seem within +/- 1e-5 * max{ |a0'|, |a1'|, |a2'| } window

android - findFragmentByTag null for Fragment A, if setRetain(true) on Fragment B -

my problem involves activity hosting 3 support fragments. 1 normal programmatic fragment (let's call home fragment). 1 portrait fragment added on top of home fragment when device orientated, , 1 'headless', continue async task regardless of configuration changes. simple, working off this nice example . public class headlesscustomerdetailfetchfragment extends fragment{ private requestcustomerdetails mrequest; private asyncfetchcustomerdetails masyncfetchcustomerdetails; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setretaininstance(true); mrequest = (requestcustomerdetails)getactivity(); } public void startfetching(string scannedbarcode) { if(masyncfetchcustomerdetails != null && masyncfetchcustomerdetails.getstatus() == asynctask.status.running) return; if(masyncfetchcustomerdetails == null || masyncfetchcustomerdetails.getstatus() == asynctask.status.finished) masyncfetchcustom

How to grab fingerprints from AET65 fingerprint reader in java -

i beginner in biometric fingerprint area, doing project on fingerprint recognition. using aet65 smart card reader fingerprint sensor. have found api of aet65 in internet, has many functions abs_status absgrab,abs_status absenrol etc. not able find examples of these functions. these functions useful grab fingerprint reader, if not can please me find how grab images fingerprint reader

firefox addon sdk - sdkaddon: How ('sdk/window/utils').openDialog can navigate to url? -

in sdkaddon, have part of code win = require('sdk/window/utils').opendialog({ features: object.keys({ resizable: true, }).join() + ',width='+w+',height='+h+',top='+pos.top+',left='+pos.left, name: 'mywin' }); win.addeventlistener('load', function () { tabs.activetab.on('ready', function (tab) { }); tabs.activetab.url = "http://www.example.com"; }); which creates new popup , goes example.com how can later change url of win (navigate url ?) win.url = "http://www.example2.com" not work you pretty close! to open new tab particular url: const tabs = require("sdk/tabs"); tabs.open("http://www.example2.com"); that's it, there's nothing it.

MySQL: How To Show Month By Name, Not Number -

Image
i trying show number of site leads per month. succeeding in of task, unable put finishing touches on it. i need this... i work looks this... my code follows... select concat(clients.first_name, " ", clients.last_name) name, count(leads.leads_id) total_leads, month(leads.registered_datetime) clients join sites on clients.client_id = sites.site_id join leads on sites.site_id = leads.site_id leads.registered_datetime between '2011-01-01' , '2011-06-31' group leads.registered_datetime i need month shown "january" , "february" rather "1" , "2". doing wrong? you close, can use monthname function in same manner. http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_monthname

jQuery nextAll until the following class -

Image
so i'm trying assign .subs previous div able assign 1 go after preceding div . i can't figure out how assign .subs after .right until next .right here example idea $(".right").each(function() { var = $(this).find('ul li:last-child'); $(this).next('.subs').insertafter(a); }); .right { border: 1px solid #000; padding: 10px margin-bottom: 10px } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <div class="right"> <ul> <li>one</li> <li>two</li> </ul> </div> <div class="subs"> <div class="right"> <ul> <li>subs one</li> <li>subs two</li> </ul> </div> </div> <div class="subs"> <div class="right"> <ul> <li>subs one<

python - django modelformset_factory POST request data retrieval -

i got django 1.9 , found out modelformset_factory useful can setup forms without major afford. now came realise upon submitting form (post method)i need figure out objects have added , removed . this view got : def def_accounts(request): list_services_list() services_list_topicformset = modelformset_factory(services_list, form=services_list_nameform, fields=('accounts',), can_delete=true) items = services_list.objects.all() formset = services_list_topicformset(queryset = items) if request.method == 'post': t_formset = services_list_topicformset(request.post) if t_formset.is_valid(): t_formset.save() i have looked post request , seems full data submission, seems doing full object refresh cannot distinguish post action in there.. any on this? thanks! edit seems can figure object being added toe form follows: if t_formset.is_valid(): instances = t_formset.save() instance in instances:

php - Drupal 8 change image style in first row on views list -

i have created view displays on page 10 newest article. have in row 2 fields: image , content. in settings of image field chose image style (for example: medium). how can change image style (example: large) in first row? i have tried in preprocess don't know stored information image style: function theme_preprocess_views_view_unformatted__lista_depesz_default(&$variables) { $view = $variables['view']; $rows = $variables['rows']; $style = $view->style_plugin; $options = $style->options; $variables['default_row_class'] = !empty($options['default_row_class']); foreach ($rows $id => $row) { $variables['rows'][$id] = array(); $variables['rows'][$id]['content'] = $row; $variables['rows'][$id]['attributes'] = new attribute(); if ($row_class = $view->style_plugin->getrowclass($id)) { $variables['rows'][$id]['attributes']->addclass($row_class); }

java - How to convert ObjectProperty<String> to StringProperty in JavaFX? -

there method convert objectproperty<integer> integerproperty . here is: https://docs.oracle.com/javase/8/javafx/api/javafx/beans/property/integerproperty.html#integerproperty-javafx.beans.property.property- why there no analogous method convert objectproperty<string> stringproperty ? how convert then? looking @ source integerproperty , bidirectional binding (and unbinding in finalize). you copy integerproperty does, , modify use stringproperty : public static stringproperty makestringproperty(final property<string> property) { objects.requirenonnull(property, "property cannot null"); return new stringpropertybase() { { bindbidirectional(property); } @override public object getbean() { return null; // virtual property, no bean } @override public string getname() { return property.getname(); } @override protect

axapta - Dynamics Ax 2012 R3 system label dont change -

Image
i change language sys labels dont change. file menu , right click. can do? we able solve problem of andré arnaud de calavon in this thread from link: these labels part of ktd files. can find them in bin directory of clients , server (e.g. axsysen-us.ktd).

firefox addon - jpm run shows demo ActionButton, but jpm xpi does not -

broken mdn demo i copied first demo, added own custom icons, nothing else. tested using jpm run , works fine, buttons appear in navigation bar, can customized , move around, clicking button opens tab mozilla.org expected, great. jpm xpi , installation generates 2 error messages, same mentioned in a similar question , unlike question, icon won't show anywhere in interface. however, if exit restart browser -jsconsole , not error message, yet still no button appearing anywhere. this error message confusing, mentions low level , has nothing of basic high level code have entered. [exception... "component returned failure code: 0x80004005 (ns_error_failure) [nsiuri.hostport]" nsresult: "0x80004005 (ns_error_failure)" location: "js frame :: resource://gre/modules/popupnotifications.jsm :: popupnotifications_refreshpanel/< :: line 667" data: no] popupnotifications_refreshpanel/<() popupnotifications.jsm:667 foreach() self-hosted popupn

java - Change value of variable? -

Image
i have variable application class. want change value of variable (which originates application class) activity. right now, can create instance of variable, , change value of instance, defeats whole purpose of creating variable application class (so can used throughout activities in project) here variable. long, , represents number of activities have passed by: i trying change value of numberofactivities every activity trying this: ((activitycount) getapplicationcontext()).numberofactivities++; as can see here, changing instance of it. when try access variable later, value 0. shouldn't case, have declared static. popup comes when hover on line saying static member accessed via instance reference. how can change value of variable separate activity? thank much, , if need more information, feel free let me know. feedback appreciated. thanks! by doing this: currenttime = ((mycurrenttime) getapplicationcontext()).currenttime; you erase value of local curren

java - How to get quality of jpeg 100? Camera2API -

i spend lot of time question how set jpeg quality if use camera2api , , find such solution i achieved increasing jpeg quality adding key capturerequest.builder the jpeg quality set in capturestillpicture() method in camer2basicfragment so: // capturerequest.builder use take picture. final capturerequest.builder capturebuilder = mcameradevice.createcapturerequest(cameradevice.template_still_capture); capturebuilder.addtarget(mimagereader.getsurface()); //set jpeg quality here capturebuilder.set(capturerequest.jpeg_quality, (byte)100); thanks @blinkingcahill but issue case if set quality 100 evetually in saved image 96 ... maybe know how can 100 ? or depends of device or smth else?

c# - Generating .rdlc report works on local but not after deploying to azure -

in asp.net mvc 5 application have following method: public actionresult sendmailasastudent(string studentid, string companyid, int applicationid, string companycvr, string studentcpr) { var manager = new usermanager<applicationuser>(new userstore<applicationuser>(new applicationdbcontext())); var student = manager.findbyid(studentid); var company = manager.findbyid(companyid); var application = db.applications.find(applicationid); project projectobj = db.projects.find(application.projectid); var mymessage = new sendgridmessage(); mymessage.from = new mailaddress("info@leepio.dk"); mymessage.addto(student.email); mymessage.addto(company.email); mymessage.subject ="the contract " + projectobj.title + " signed!"; mymessage.html = "here final contract"; localreport localreport = n

Call Scala & Spark code from Python -

i have codebase written in scala uses spark. i'd method foo called externally python code. def foo(a: int, b: string): string i saw here java python integration can use jython. think that's overkill though. can't add pyspark method wraps scala/spark existing method? if not, isn't there simpler solution, wouldn't need special module jython?

python - Run script from main script in spyder-project -

i have spyder-project 2 scripts: "mainscript.py" , "subscript.py". how can run "subscript.py" "mainscript.py" thing current workspace-variables? kind of command must use? you should able call subscript.py within mainscript.py call file library. easier if contents of `subscript.py' within function. e.g. if setup is: project file - mainscript.py - subscript.py and subscript.py file like: #imports def some_function(some_variable): #does here then in mainscript.py should able import , use it. e.g.: from sub import some_function def main(): variable = 'some value' some_function(variable) #should call function using variable #rest of code main()

database - How to create Set from Pydblite in Python -

hello i'm using pydblite in order store url in python database. script add urls time in database want delete duplicate (or make set) keeping 1 same url @ ending of program. i have 2 fields url , date: self.db = base('url_database.pdl') self.db.create('url', 'date', mode="open")

swift - Recursive function to replace json objects -

i have json file: [ { "person": { "@id": "value1", "name": "mattia" }, "person1": { "@ref": "value1" }, "subpersons": [ { "@id": "value2", "name": "luca", "key": { "@ref": "value1" } }, { "@ref": "value1" }, { "@id": "value3", "subsubpersons": [ { "again": { "@ref": "value2" } } ] } ], "key": { "subkey": { "@ref": "value1" } } } ] i need map objects contains @id replace @ref values related @id values mapped. i'd obtain this: [ { "person": { "@id": "value1", "name": "mattia" }, "person1": { "@id": "value1", &quo

Using Java if we run two JVM's at the same time what are the limitations I must keep in mind? -

is possible spawn off 2 separate java programs , program apples.java , grapes.java , , each 1 of these runs in own separate jvm on machine ? my motivation want have monitor class, checking log-files output class (call undersurveillance class) . , once child class forcibly shutdown, monitor class act on (it call batch file via processbuilder spawn off undersurveillance class ). to summarize , if call ctrl+c command-line on undersurveillance , should respawned again. , when respawned resume state. example, if knockknock joke app, restart in logical position left off before (so if had 10 knock-knock jokes, , forcibly shutdown before completing kk-joke #5, restart , resume @ joke #5 ) thanks yes. can run many seperate jre processes like. limitation finite resources of machine. 2 (or more) processes cannot open , listen on same socket on same ip (for example).

amazon web services - Install python library on elasticbeanstalk which requires sudo -

i'm trying install boto3 django project deployed aws elastic-beanstalk. library requires run sudo , therefore gives me permission denied error. i'm putting boto3==1.2.1 in requirement.txt file. thanks! turns out forgot double = signs. no need sudo.

Date(); returning same time even with an event in php -

is there way this? because both $timestart , $timestop give me same result tho theres event between both. <?php $timestart = strtotime(date('h:i:s', time())); if(isset($_post['choix186']) ){ $timestop = strtotime(date('h:i:s', time())); $duree = $timestop - $timestart; } print $duree"; ?> the "standard" timer script one: example #1 timing script execution microtime() $time_start = microtime_float(); // sleep while usleep(100); $time_end = microtime_float(); $time = $time_end - $time_start; echo "did nothing in $time seconds\n"; ?> example #2 timing script execution in php 5 <?php $time_start = microtime(true); // sleep while usleep(100); $time_end = microtime(true); $time = $time_end - $time_start; echo "did nothing in $time seconds\n"; ?> example #3 microtime() , request_time_float (as of php 5.4.0) <?php // randomize sleeping time usleep(mt_rand(100, 10000

batch file - Highlight all occurrences of a word within Windows command line -

i muxing 100's of (.mkv)'s via mkvmerge command line (.bat) file , know if it's possible have occurrences of words warning , error highlighted in yellow(warning) , red(error) , or change text color. tried " setting text color in batch file " outcome not specific i'm trying accomplish. batch is: @echo off cls md output %%a in (*.mkv) ( "mkvmerge" --track-name -1:"" --no-attachments --no-track-tags --no-global-tags --disable-track-statistics-tags --display-dimensions "0:1280x720" --language -1:eng --default-track -1:yes --compression -1:none --no-chapters -o output/"%%~na.mkv" -a 1 -d 0 -s "%%~na.mkv" --track-order 0:0,0:1 --language 0:eng --stracks 0 "%%~na.idx" ) this gave me results looking for... mtee mtee commandline utility @echo off md output md results %%a in (*.mkv) ( "mkvmerge" --track-name -1:"" --no-attachments --no-track-tags --no-global-tags --disab

java - Lazy Fetching doesn't work with many to one -

i have class a has 1 many relationship b , when want fetch b don't want fetch a , means want lazy fetching, in case code looks (didn't write setter , getter methods) @jsoninclude(jsoninclude.include.non_null) @jsonignoreproperties(value = {"hibernatelazyinitializer", "handler"}, ignoreunknown = true) @generated("org.jsonschema2pojo") @entity public class b{ @manytoone(fetch = fetchtype.lazy, cascade = cascadetype.all, optional = false) @joincolumn(name = "aid") private a; } @jsoninclude(jsoninclude.include.non_null) @jsonignoreproperties(value = {"hibernatelazyinitializer", "handler"}, ignoreunknown = true) @generated("org.jsonschema2pojo") @entity public class { @onetomany(mappedby = "a", fetch = fetchtype.lazy, cascade = cascadetype.all) private set<b> bs; } the problem given infinite recursion, b contains , contains bs , on, tried use @jsonbackreference() @ manytoo

css file not workin properly on rails 4.2 -

css not working in rails 4.2.5 on implementing home page looks the gem file are gem 'rails', '4.2.5.1' gem 'pg' gem 'activeadmin', github: 'gregbell/active_admin' gem 'devise' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'bootstrap-sass', '3.2.0.0' gem 'coffee-rails', '~> 4.1.0' gem 'coffee-script-source', '1.8.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc my routes are rails.application.routes.draw 'pages/about' 'pages/contact' 'pages/resources' devise_for :admin_users, activeadmin::devise.config activeadmin.routes(self) resources :categories 'categories/index' 'categories/edit' 'categories/new' 'categories/show' 'home/index'

android - php mysql sort by date (Recent) -

i have code fetching data in mobile application sql first added showing first, need set showing last added first in android application. have api code below, in latest showing per requirement cid , aid need same latest ( must show recent first). code below thanks <?php include("includes/connection.php"); error_reporting(0); mysql_query("set names 'utf8'"); if(isset($_get['cid'])) { if(isset($_get['cat_id'])) { $cat_id=$_get['cat_id']; $query="select * tbl_quotes left join tbl_category on tbl_quotes.cat_id= tbl_category.cid tbl_quotes.cat_id='".$cat_id."'"; } else if(isset($_get['latest'])) { $limit=$_get['latest']; $query="select * tbl_quotes left join tbl_category on tbl_quotes.cat_id= tbl_category.cid order tbl_quotes.id desc limit $limit"; } else { $query="select cid,category_name,category_image tbl_

asp.net - Convert Query string to Route Path -

i have issue , cant seem resolve it. have url, thats like: myurl/?culture=fr what want is myurl/fr my controller looks : public actionresult index(string culture = null) and routeconfig: routes.maproute( name: "languages", url: "{controller}/{action}/{culture}" ); this results in page isn't redirecting properly. hints solve it? give default controller , action in route if appending "fr" root of url(www.yoururl.com/fr). :- routes.maproute( name: "languages", url: "{controller}/{action}/{culture}", defaults: new { controller = "home", action = "index"} ); replace "home" default controller , "index" default action.

javascript - Cannot assign info from request properly Angular JS -

i need send few requests server , info write in array. function looks like: $scope.addinstrument = function(themat) { $scope.data = '{"func":"addinstrument", "thematerial":"' + themat + '", '; $scope.data += '"lifespan":"' + $scope.lifespan + '"}'; server.fetch($scope.data, $rootscope.token).then(function(data) { return data[0].addinstrument; }) } code in controller calls function: for (var = 0; < $scope.amount; ++) { $scope.inventnum[$scope.inventnum.length] = $scope.addinstrument(themat); } angular.foreach($scope.inventnum, function(value) { alert(value); }) function sends requests server: app.service('server', function (authservice) { this.fetch = function (data, token) { return fetch('http://104.197.58.108:8080', { method: 'post', headers: { 'accept':

onclicklistener - How to get out from onClick method for Button Listener in Android -

consider following code: button add_product_button = (button) findviewbyid(r.id.add_product_button); add_product_button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { //before going further, check whether information provided or not edittext item_title_text = (edittext) findviewbyid(r.id.item_title); if(isempty(item_title_text)){ break; } i want 'break;' response not want proceed further (not executing rest code , out). this alarm user insufficient information has been provided. how can achieve this? i recommend disabling button if required information not there user isn't able click it. display message on whatever dialog/view inform user information required, or add string "(required)" after edittext hint. button add_product_button = (button) findviewbyid(r.id.add_product_button); edittext item_title_text = (editte

Git: how to completely delete commit before a specified one? -

after years of git commits, we'd delete old ones. we have commit number want consider new 'base'. how can ask git remove all(and remove) commits before specified one? create temporary branch commit , rebase against it: git checkout --orphan temp commitid git commit -m "truncated history" git rebase --onto temp commitid master git branch -d temp where commitid new base. check the article details.

Java Lwm2m Bootstrap Server -

i connect 1 lwm2m client multiple servers lwm2m bootstrap server. i'm using leshan (lwm2m implementation in java). so i'm using lwm2m demo github.com/eclipse/leshan. run server demo, bootstrap server demo, , client demo. want register client in server user interface using bootstrap server (i entered client endpoint, server uri, no security mode). when run them both, client not registered , have message in terminal matching client : [bootstrap=bootstrap server [uri=coap://192.168.1.100:5683], devicemangements={123=dm server [uri=coap://192.168.1.85:8081,lifetime=20, binding=u]}]. [2016-07-05 12:48:17,684 info registrationengine] trying register coap://192.168.1.85:8081 ... [2016-07-05 12:49:39,113 error registrationengine] registration failed: timeout. [2016-07-05 12:49:39,116 info registrationengine] unable connect server, next retry in 600s ... how can implemented this? coap://192.168.1.85:8081 doesn't sound standard coap port mo

html - Trying to remove the third column of a table when the browser gets smaller (CSS) -

i've made table 4 col , 4 rows. browser gets smaller, want have table smaller well, removing first 4th col, gets smaller, 3rd col. i able remove 4th col, using media query and: table th:last-child, table td:last-child { display:none; } i've tried work third column using table th:nth-last-child (2), table td:nth-last-child (2){ display:none; } but not work. thanks help! find full code: https://jsfiddle.net/kahealani1996/vtjf5dnr/ the problem between nth-last-child , (2) there should no whitespace . otherwise works fine. code should be: table th:nth-last-child(2), table td:nth-last-child(2){ display:none; }

php - Build a nested array from a menu in database -

i have following output database , want build menu data. $output = [ ['id_struct' => 1, 'title' => 'a', 'parent' => 0], ['id_struct' => 2, 'title' => 'b', 'parent' => 0], ['id_struct' => 3, 'title' => 'b1', 'parent' => 2], ['id_struct' => 4, 'title' => 'b2', 'parent' => 3], ['id_struct' => 5, 'title' => 'c', 'parent' => 0], ]; with output need build array this: array (size=3) 0 => array (size=1) 'title' => string 'a' (length=1) 1 => array (size=2) 'title' => string 'b' (length=1) 'children' => array (size=1) 0 => array (size=2) 'title' => string 'b1' (length=2) 'children' =>

In Angular2 With Bootstrap - Tooltip, Tooltip Need setup by executing javascript, How to do it? -

angular2 (2.0.0-rc.4) use bootstrap's tooltip, tooltip need execute follow javascript when ready: $(function () { $('[data-toggle="tooltip"]').tooltip() }) in angular2,how execute it? <div data-toggle="tooltip" #tooltip></div> class mycomponent { @viewchild('tooltip') tooltip:elementref; ngafterviewinit() { this.tooltip.nativeelement.tooltip(); } }

Installing g++ 5 on Amazon Linux -

Image
i'm trying install g++ 5.x on ec2 instance running amazon linux; in amazon's central repository latest version 4.8.3. configuration can make allow yum find newer gcc-c++ package? probably "amazon linux ami release 2016.03", when have gcc-4.8.3 . os close centos 7.2 / rhel 7. please try : # yum install centos-release-scl if ok, can : # yum install devtoolset-4-gcc-c++ ... , g++, gcc version 5.2.1 . enabling "5.2.1" : $ scl enable devtoolset-4 bash . aware setting valid current terminal session only. if issues, can supply link 4 packages required g++, gcc.

Stop Keil uVision build when warning detected -

i building project keil uv5.17 . build stops when detects error, have same behavior warning. using option target >> user >> stop on exit code . seems ignore warnings, options on how stop build, when warning appears? if want warnings treated error, go options target>>c/c++. in misc controls add: --diag_error=warning

html - How to print local pdf file using javascript -

for example, having local pdf file contains 6 pages. if using window.print() function, in print preview shown 1 page ever in browser. instead of single page have show pages in print preview mode. bind required pages or data around div , print div instead , printing div have place of code. <html> <head> <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js" > </script> <script type="text/javascript"> function printelem(elem) { popup($(elem).html()); } function popup(data) { var mywindow = window.open('', 'my div', 'height=400,width=600'); mywindow.document.write('<html><head><title>my div</title>'); /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />'); mywi