Joomla 3.x visible Menu Item – but need login to access

Uncategorized
Question: In Joomla having a menu item for reservation a user enters (not logged yet) the website this user should see the menu item, the user clicks on the menu item, If the user is NOT logged in - the user is asked to enter the username/pass and if the user is logged in the user can see the form where the menu item was linked. Answer: You have to display two different link with the same description (but different alias) one for not login user where you can put login page (and set redirect, after login, to your target page) and another that's directly your target page. Read more
Read More

Lucene Filter and Query Concept

Uncategorized
Question: I am working on a search project in Java and I'm using Lucene. I want to filter my final search results with a query from the user (e.g. "x" AND "Y") as a feature of advanced search. My search query consists of queries on different parts of a news and it's working correctly but my filter doesn't work properly So I'm using following code:leadFilter = new QueryWrapperFilter(new QueryParser(LUCENE_VERSION, INDEX_FIELD_LEAD, analyzer).parse(advanceFilter)); titleFilter = new QueryWrapperFilter(new QueryParser(LUCENE_VERSION, INDEX_FIELD_TITLE, analyzer).parse(advanceFilter)); booleanFilter.add(leadFilter, Occur.SHOULD); booleanFilter.add(titleFilter, Occur.SHOULD); topDocs = indexSearcher.search(booleanQuery, booleanFilter,query.getLimit()); maybe I have not understood the concept of "Filter" correctly. So please correct me or propose another way to filter results after a search by Lucene. Thanks in advance Answer: Read more
Read More

Call two pandas columns in a function?

Uncategorized
Question: I have a bunch of URLs I am trying to write to files. I store the URLs in a pandas dataframe. The dataframe has two columns: url and id. I am trying to request each URL from url and write it to a file named id. Here is what I got so far: def get_link(url): file_name = os.path.join('/mypath/foo/bar', df.id) try: r = requests.get(url) except Exception as e:print("Failded to get " + url) else:with open(file_name, 'w') as f: f.write(r.text) df.url.apply(lambda l: get_link(l)) But when I call the function, it obvioulsly fails, since os.path.join expects a string and not a series. Hence I get the error join() argument must be str or bytes, not 'Series' Any ideas how I can simultaenously call df.id and df.url? Thank you/R Answer: You can enhance…
Read More

android studio cant open .sqlite database file

Uncategorized
Question: I'm currently building my first app using android studio that accesses an external database. However the app is crashing and giving errors saying the database can not be opened. I've followed videos on youtube but i still have the problem. When I copy my database .sqlite file from my desktop and paste it into the assets folder I get an error "File was loaded in the wrong encoding: UTF-8". I tried reloading the file in several encodings but I would always get the same error message. I'm guessing this is the issue. Any other tips or notes are also welcome and appreciated. public class DataBaseHelper extends SQLiteOpenHelper { //The Android's default system path of your application database. private static String DB_PATH = "/data/data/invain3219/databases/"; private static String DB_NAME = "partyprobeDB.sqlite";…
Read More

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 2 path

Uncategorized
Question: i have tries many suggestions from other same questions but does not help, how can i run this test successfully:@Test fun isJsonCorrectPersonConvert() { val gson = GsonBuilder().create() val json = gson.toJson("[{"Id":2,"Text":"Математика"},{"Id":5,"Text":"Физика"}]") val results = gson.fromJson(json, Array::class.java) Assert.assertNotNull(results) Assert.assertNotNull(results[0].Id) Assert.assertNotNull(results[0].Text) System.out.println(results.toString()) } data class Person(val Id: Int,val Text:String) Answer: Try this :val json: String = "[{"Id":2,"Text":"Математика"},{"Id":5,"Text":"Физика"}]" val results: List = gson.fromJson(json , Array::class.java).toList() Read more
Read More

How can i execute a stored procedure within current transaction without named query?

Uncategorized
Question: Is there any way to execute a stored procedure in current transaction without @NamedNativeQueries annotation? I have already implemented many stored procedure executions using connection object from datasource. On discovering the mistake that they are executing in a different session than the current session I am in, I would like to know if there is any way to execute stored procedure without rewriting it all to @NamedNativeQueries? Answer: Read more
Read More

Creating drawables for each size and density of screen?

Uncategorized
Question: Should we create multiple drawable folders for each size and screen density for the perfect user experience? For example: drawable-small-ldpi drawable-large-ldpi drawable-small-mdpi drawable-large-mdpi drawable-small-xhdpi drawable-large-xhdpi ...and so on for other densities and sizes. But this approach seems very difficult. Is there any other easy way to support all screen densities and sizes? Answer: just use vector in android. Allows developers to easily use drawables on all devices running Android 2.1 and above. check this link Read more
Read More

View Model Initialization

Uncategorized
Question: In most of the examples I see using MVVM & RxSwift, the View Models have a lot code in the initializer, rather than modularizing it into helper methods. The only reason why this seems to make sense is to prevent optional observable properties. Should I do the same, so I don't need to unwrap optional outputs when binding and so forth? For example, in one of my View models I have an optional output to bind to a collection view named bids. var bids: Observable? its optional because the value is assigned in a method, but in most open source code I see, this is all done in init. which is best approach? private func fetchBids() { let fetchedBids = FetchBidsTask(itemId: item.value.id).execute(in: dispatcher) .materialize() .filter { !$0.isCompleted } .shareReplayLatestWhileConnected()…
Read More

Decompose microservices: Business capability vs Domain

Uncategorized
Question: As I read, there are two patterns to define one microservice, by business capability and by subdomain. But I still find it very ambiguous. I get confused how these two patterns differentiate from each other. Both of them revolve around activities involving an area of business logic. All of components in each service are small enough to get packaged with each other without affecting other services. Could anyone please give me a further explanation about these two? Answer: Read more
Read More

PHP – How to make condition if no image show image no image available Laravel

Uncategorized
Question: I am newbie in laravel so I really need some help. I want to make some code if no image available then it will be showing no image available image, this is the example image of no image available http://imgur.com/ppmPcKA This is my controller to store the image public function store(CreateBannerRequest $request) { $input = $request->all(); //get original file name $filename = Input::file('photo')->getClientOriginalName(); $input['photo'] = $filename; $banner = $this->BannerRepository->create($input); //upload file Input::file('photo')->move($this->path, $filename); Flash::success('Banner saved successfully.'); return redirect(route('banner.index')); } And this is the table image code photo) }} " width="100px" height="100"/> And this is the view http://imgur.com/a/X4udv So if no image it will be show No image available Answer: You can use Blade conditional Default text if no image available @if ($banner->photo) photo) }} " width="100px" height="100"/> @else No…
Read More