I am intercepting requests from the webview using shouldInterceptRequest below is my code for returning my WebResourceResponse @TargetApi(Build.VERSION_CODES.LOLLIPOP) private static WebResourceResponse handleRequestViaUrlOnly(WebResourceRequest webResourceRequest){ String url = webResourceRequest.getUrl().toString(); Log.i("intercepting req....!!!", url); String ext = MimeTypeMap.getFileExtensionFromUrl(url); String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext); ...
Tuesday, February 28, 2017
Jwt tokens authorization is not working

I'm trying to create Jwt token authorization. For this purpose I have issuer part with the code like that: public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] {"*"}); Users user; using (var db = new UserStore()) { user = Task.Run(()=> db.FindUser(context.UserName, context.Password,...
Dynamically adding Views in a RecyclerView only to current item
I'm dynamically adding Views to my items in a RecyclerView. These added Views should only be related to the item which they're added to, but I'm having a problem when I scroll. It seems the View is recycled and a new item is loaded, but those previously added views are still there, only now on the wrong item. I'm assuming that it's just because the ViewHolder is being reused, so the added items show up again with a new item, when loaded. How would one go about solving this? 10 AnswersAnswers 1 You need to track what...
How to correctly listen to navigation changes on UIWebView?

I noticed that the [UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] is only called with traditional <a href="..."> links and not single page web app JavaScript navigations. For example, if I go to m.facebook.com in a UIWebView and start tapping on the top nav (see screenshot below) it never triggers that delegate method. The reason I want a method to hook into is because I want to add back and forward...
Sort Descriptor based on ordered to-many relationship
Description of my core data model: Project and Issues entities Project has an ordered one-to-many relationship to Issues named issues Issue has one-to-one relationship with Project named parentProject Here is my code to obtain issues: let fetchRequest = NSFetchRequest(entityName: "Issue") fetchRequest.predicate = NSPredicate(format: "parentProject CONTAINS[cd] %@", argumentArray: [project]) fetchRequest.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)] let frc = NSFetchedResultsController(...
Laravel 5.3 - Social login doubts
I am developing a mobile app and currently depending on JWT to maintain the statelessness of the API. The API is consumed by mobile and web devices. The users will use their email and password to register. I am assigned to implement social login option in this API. I would like to clear my following doubts. 1) When Social Login is used, how can I generate a token [like JWT] which will be stored at the client's end? This token is supposed to send with all subsequent requests after login. 2) In case social platforms are...
How to put views on top of an ImageView, in relation to the ImageView's content size?

Background Suppose I want to show an image of the something using an ImageView, and I want to put new views on top of it (animated ImageViews that show pins on a world map image, for example, or a Switch view on top of a smartphone image). This means that no matter how the ImageView shows the image, the views should be in it, inside correct spot, with the same size as specified, or in a size related to the imageView itself The problem...
Is it possible to use poison pill approach with bounded queues?
In Java Concurrency In Practice book (p.156), there's a statement regarding poison pill approach: Poison pills work reliably only with unbound queues. Does it mean that with a bounded queue I can get a deadlock, or is it about some other liveness problems? Is it connected with number of producers and customers? 3 AnswersAnswers 1 With a bounded queue, you could be prevented from adding the poison pill. One way to avoid this issue is to make the bounded queue allow one more when a poison pill is added. Answers...
Monday, February 27, 2017
MVC 4: How to maintain sessions and cookies to be still valid after IIS restart?
It seems that my login session (using simple membership) and cookies (verification token) are not valid after IIS server restart. This is a problem for me, if a user in the middle of a transaction then the server restart, the user has to refill the form and do it again, also it can be some code issue when the transaction is interrupted in the middle of the process. How to make them to be still valid after server restart? Here is my web.config: <membership /> ... <sessionState mode="InProc" cookieless="false"...
How to avoid “Invalid byte sequence” when looking for link with text using Nokogiri
I'm using Rails 5 with Ruby 4.2 and scanning a document that I parsed with Nokogiri, looking in a case insensitive way for a link with text: a_elt = doc ? doc.xpath('//a').detect { |node| /link[[:space:]]+text/i === node.text } : nil After getting the HTML of my web page in content, I parse it into a Nokogiri doc using: doc = Nokogiri::HTML(content) The problem is, I'm getting ArgumentError invalid byte sequence in UTF-8 on certain web pages when using the above regular expression. 2.4.0 :002 > doc.encoding...
MvcBuildViews true causes “'/temp' is not a valid IIS application” error
After setting MvcBuildViews to true in my .csproj file in order to have the views compile during build, I get the following error: '/temp' is not a valid IIS application I presume that the '/temp' that this is referring to is the path where the views will be compiled. Here's the relevant section in the .csproj file: <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" /> </Target>...
Android VideoView starting lots of videos sequentially
I'm testing this for about three days nonstop. Here's the simple code: private VideoView videoView; -- videoView = (VideoView) findViewById(R.id.videoView); videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mediaPlayer) { getNewVideo(); } } }); getNewVideo(); -- private void getNewVideo(){ File file = //Any File. I have a list of files and they are executed in order videoView.stopPlayback(); videoView.setVideoPath(file.getPath());...
MySQL server slow to respond with Wordpress
I have a web server running Windows, IIS, PHP that is hosting a fully patched WordPress site. The database sits on a separate server inside the DMZ that is running Windows and MySQL 5.7.13. When making a request to the WordPress site, it takes anywhere from 6 to 16 seconds to get back the first byte. Executing this ridiculously un-optimized query from MySQL Workbench (on the web server) takes only 0.858 seconds. SELECT * FROM wp_posts INNER JOIN wp_postmeta ON wp_postmeta.post_id = wp_posts.ID INNER JOIN wp_comments...
Creating a connection to a subscription site in python
I am looking to open a connection with python to http://www.horseandcountry.tv which takes my login parameters via the POST method. I would like to open a connection to this website in order to scrape the site for all video links (this, I also don't know how to do yet but am using the project to learn). My question is how do I pass my credentials to the individual pages of the website? For example if all I wanted to do was use python code to open a browser window pointing to http://play.horseandcountry.tv/live/ and have...
How to add Text for some duration of video in iOS SDK
I have video having duration 4:00. Now I want to add text in video file as per the frames of video. Say for example from 00:30 to 1:50 duration I want to add text "Welcome". Now from 3:00 to 4:00 duration of video I want to add text "Awesome". How to achieve this functionality. I have referred below tutorial. It adds text in whole video not for some duration of video. https://www.raywenderlich.com/30200/avfoundation-tutorial-adding-overlays-and-animations-to-videos Any help will be appriciated. I am adding lines of...
JUnit test with Embedded tomcat server , how to specify automatic ports for both http and https connectors?
Description I have made a JUnit test that focus on trying to test a call to a SOAP web service. I am using an embedded tomcat server for my test in order to run my test with a mock server. I am also using both http and https connectors. I need to use automatic ports for both these connectors because the test is running on a Jenkins server and i can't just use port 443 or 8443 as they are already taken. I understand that using the port 0 as standard port will result in tomcat using automatic port allocation but I can't...
Sunday, February 26, 2017
Cache is not cleared in Google Chrome
When I deploy the version I will add the number as query string with the JavaScript and CSS file like following? 'app/source/scripts/project.js?burst=32472938' I am using the above to burst the cache in the browser. But in Firefox, I am getting the latest script that I have modified. But in Chrome, I am not getting the latest script that I have modified. Instead of that I am getting the old one. But in developer console, I am seeing the burst number which is modified in latest. 5 AnswersAnswers 1 According to...
Django runserver - can't serve video files
When running Django in local mode using the runserver command video files are not loaded in the browser properly. I get the error An error occurred trying to load the resource. All other static files serve fine such as images, javascript and css. 3 AnswersAnswers 1 I have found the answer finally, Django's runserver does not support byte range requests. See this thread: https://groups.google.com/forum/#!msg/django-developers/NZ1qTkZ6vok/fhdz7rTtL1EJ And this ticket: https://code.djangoproject.com/ticket/22479...
Authentication/access control module for reverse proxy NGINX
I am looking for a module which does the authentication/access control for reverse proxy (preferable nginx). This module should do: 1. user authentication using credential stored in database (such as postgres) 2. Monitoring the ongoing connection and take action if certain access credential is met. For example, time is expired 3. open source (allow customization) and nginx, ruby(rails) preferable. It seems that OpenResty with nginx can do the job. Here is an article talking about access control with Lua on nginx. Here...
OpenVPN routing outside IPV6 tunnel (windows)
I'm struggeling with a general OpenVPN configuration... I've an established OpenVPN connection with IPv6 and I want to exclude an IP for that tunnel... On IPv4 this works by adding --route IP MASK net_gateway default to the config, so for example if I want to exclude the google DNS from the tunnel --route 8.8.8.8 255.255.255.255 net_gateway default does the trick. But how to do that with IPv6? I know there is a --route-ipv6 command to route over the tunnel, but I didn't find a way to exclude an IP from the tunnel...
React stop other events on that element
I have a volume element that shows the volume bar when the user hovers over it. This all works great in desktop. However to get the same functionality on mobile, the user has clicks on the volume element which also toggles the mute click event. I am wanting to stop that mute event when the user clicks (i.e taps) on that element on mobile. I don't want to modify the Mute or VolumeBar classes to fix this because these are generic classes in my library that the developer uses. https://jsfiddle.net/jwm6k66c/2145/ Actual:...
RecyclerView onBindViewHolder called only once inside Tab layout

I've four tabs and four fragments (each one for each tab). Each fragment has a vertical recycler view. Since all fragments view look similar I'm re-using the same layout file, same recycler view items and same adapter. The issue is that only one item is loaded under the first tab and third tab and fourth tab, While the second tab successfully loads the entire data. I hope image added below gives better understanding regarding the...