React-native app not sending DRF OPTIONS request before POST

Uncategorized
Question: We are getting 500 Server error for any POST method we make to Django Rest API. On investigating logs and comparing with web version of the application, we found that web version send OPTIONS request before every POST. This is not happening from the React-native app. Any pointers where the problem might be? "Django": "1.9.3" "axios": "^0.15.2", "react": "16.0.0-alpha.12", "react-native": "^0.45.1", Answer: Read more
Read More

How to Call external DLL in delphi XE8

Uncategorized
Question: i am using this method to activate my app, first connection to Kinvey collection and get the Keys, if the client key exists the app will activate if not, exits,however, with a simple trick using fiddler and AutoResponder feature the client can activate the app. I have the code to stop Fiddler process but its useless when the process name changes. Now, what i should to overcome this problem ?is there better idea ? UPDATE i found out that there is an API for fiddler app called FiddlerCore, the problem its in .Net, i just ned to use this line Fiddler.FiddlerApplication.Shutdown(); in my app the DLL is FiddlerCore4.dll i dint know how to call this in my app. Answer: Read more
Read More

How to handle multiple checkout request from an e-commerce website for limited product items?

Uncategorized
Question: Suppose in one site there are 10 items available and 10000 or more customers doing the checkout for this item at the same time but I did not understand yet about how the most popular e-commerce websites manage the multiple requests during checkout at the same time even in nano seconds, who will get those items on what basis, for example, eBay, Amazon, etc. Thank you in advance. Answer: here is the link that may help you. https://github.com/spree/spree/issues/5070 Read more
Read More

Using single quotes for multiple lines in VueJs

Uncategorized
Question: Hey i'm trying to learn VueJs at the moment and wanted some help with the template property. Currently, I have to enter some text in the template like this template : '' But I wanted to do something like template : ' ' Using the later syntax gives and unexpected symbol syntax error. Any ideas how I could use the second syntax to make the readability of the code better? Cheers Answer: Use back-ticks instead:template : ` ` Read more
Read More

swift client delete object failed

Uncategorized
Question: Environment swift client in CentOS7(10.0.0.2) bash [root@bogon ~]# pip2 show python-swiftclient Name: python-swiftclient Version: 2.7.0 Summary: OpenStack Object Storage API Client Library Home-page: http://www.openstack.org/ Author: OpenStack Author-email: openstack-dev@lists.openstack.org License: UNKNOWN Location: /usr/lib/python2.7/site-packages Requires: futures, six, requests swift server in CentOS7(10.0.0.4) bash [root@bogon ~]# swift --version python-swiftclient 3.2.1.dev9 Question swift client login server ,and delete one .jpg file in the container "temporary". Details [root@bogon ~]# swift -A http://10.0.0.4:8080/auth/v1.0 -U admin:admin -K admin_pass list contract data mask_contract temporary [root@bogon ~]# swift -A http://10.0.0.4:8080/auth/v1.0 -U admin:admin -K 806huayuan list temporary | tail 9f2f8626-a2ad-11e7-ad0b-1866daecc1a0.jpg a25ebf08-a2b0-11e7-ad0b-1866daecc1a0.jpg a6cfc990-a2ad-11e7-ad0b-1866daecc1a0.jpg a8732914-a216-11e7-ad0b-1866daecc1a0.jpg a87cda6a-77f8-11e7-befe-1866daecc1a0.jpg ad186efc-a216-11e7-ad0b-1866daecc1a0.jpg b255e2e6-a216-11e7-ad0b-1866daecc1a0.jpg d1d010f2-0129-11e8-8cef-1866daecc1a0.jpg f779a1ea-a2ad-11e7-ad0b-1866daecc1a0.jpg ff4fbf7e-aa70-11e7-bbe0-1866daecc1a0.jpg [root@bogon ~]# swift -A http://10.0.0.4:8080/auth/v1.0 -U admin:admin -K 806huayuan delete temporary ff4fbf7e-aa70-11e7-bbe0-1866daecc1a0.jpg Error Deleting: temporary/f779a1ea-a2ad-11e7-ad0b-1866daecc1a0.jpg: Object DELETE failed: http://10.0.0.4:8080/v1/AUTH_admin/temporary/f779a1ea-a2ad-11e7-ad0b-1866daecc1a0.jpg 409 Conflict [first 60 chars of response] There was a conflict…
Read More

Unknown provider when unit testing service that relies on providers

Uncategorized
Question: Here is my test, I am using jasmine, and karma for unit testing. Previously it was giving error about $urlRouterProvider so I added a dependency to module. My application is running fine without it. But when I apply unit testing it gives an error. describe('Brand factory', function () { beforeEach(module('BlurAdmin.admin.brands')) var service; var brandService; beforeEach(inject(function (brandService, _$httpBackend_) { service = brandService; $httpBackend = _$httpBackend_; })); it('should invoke service with right paramaeters', function () { $httpBackend.when('GET', 'http://localhost:3000/admin/brands', { }).respond({}, { 'x-access-token': 'hidden by my self' }); service.getBrands(); $httpBackend.flush(); }); }); Below is my service:(function () { 'use strict'; angular.module('BlurAdmin.admin.brands').factory('brandService', brandService); function brandService($http, $q, APIURL) { return{ getBrands:function() { var deferred = $q.defer(); $http({ method: 'GET', url: APIURL+'admin/brands', headers: { 'x-access-token':localStorage.getItem('admin-token') } }).success(function (result) { deferred.resolve(result); }).error(function (err) { deferred.reject(err); })…
Read More

Why doesn’t the dates between given range are not getting picked?

Uncategorized
Question: I am trying to pick dates between ranges. I have hard coded date and month but the year is dynamically concatenated with it. I am trying to pick dates between these ranges from the table but it doesn't always give the dates between the given range. Declare @year varchar(10) Set @year= '2017-2018' Declare @YearFrom varchar(15) Set @YearFrom= (Select SUBSTRING(@year, 1, 4) ) Declare @YearTo varchar(15) Set @YearTo= (Select SUBSTRING(@year, 6, 9) ) Set @YearFrom= '01-07-'+@YearFrom Set @YearTo= '30-06-'+@YearTo Select Convert(varchar(11),c.RegistrationDate,106) from Contractors c where Convert(varchar(11),c.RegistrationDate,106) between Convert(varchar(11),@yearFrom,106) and Convert(varchar(11),@YearTo,106) the registration date is saved as: YYYY-MM-DD e.g. 2017-07-03 Answer: Another way to solve this is by using DATEFROMPARTS, where Year, Month and Day inputs are converted into dates, as follows:Declare @year varchar(10) Set @year= '2017-2018' Declare @YearFrom int Set…
Read More

Regex to find the words or sentences that enclosed with custom sign

Uncategorized
Question: I need to replace some words or some sentences and convert it to underline. I'm using PHP and find one reference: PHP Regex, extract all custom tags from text Somehow, the case only covers for single words but not sentences. How to make the regex also can catch everything enclosed by ## tag? Let say my input will be such as: "ll the Lorem Ipsum ##generators## on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over ##200 Latin words##, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always ##free from repetition##, injected humour, or non-characteristic words etc." Then the output will…
Read More

Issue with finding Euler angles

Uncategorized
Question: When i try to calculate roll, pitch, yaw values from a rotation matrix given below: i get math error in my calculator. But, matlab (using peter corke's robotics toolbox) gives me some values as result. %Rotation Matrix 5 R = [-0.9122 0.4098 0; -0.4098 -0.9122 0; 0 0 1]; tr2rpy(R,'deg') Output: 0 0 -155.8083 Does that mean the rotation matrix is invalid ? Can i believe the matlab output ? Thanks and regards ! Answer: This is correct answer, so you have only roll, you can see it from rotation matrix, last row-column is [0,0,1] meaning that no change in z axis, meaning no pitch or yaw applied. (In case of roll only, the roll angle is arccos(R(1,1)) ) Read more
Read More

Confuse about String Interpolation in C# 6.0 [duplicate]

Uncategorized
Question: This question already has an answer here:Why can't I use the conditional operator in an interpolated string without brackets? [duplicate] 1 answer How to use the ternary operator inside an interpolated string? 1 answer I have this code where this inline variable { (hour > 12 ? "PM" : "AM") } I create it and it works but I am confused because without the braces () I have some issue with code lots of red underlines there, infect compiler code suggestions refactor it with red underlines but after wrap my expression with () it works. I just want to know what is status of () in this interpolation inline variable? WriteLine($"{hour}:{minout}:{seconds} { (hour > 12 ? "PM" : "AM") }"); Answer: : operator is valid operator for string formatting…
Read More

Generating Google Cloud Endpoints v2 frameworks in Eclipse

Uncategorized
Question: I have a Google App Engine project which was recently migrated from Cloud Endpoints v1 to v2. In v1, generating client libraries for the endpoint APIs was a simple matter of running this maven command:mvn appengine:endpoints_get_client_lib But now in v2, endpoints have to be generated with a more involved process described in: https://cloud.google.com/endpoints/docs/frameworks/java/generate-client-libraries-android Is there any way to integrate this process with Eclipse, such that when the project is run (either with Run or Debug), the endpoints are automatically generated? Answer: Read more
Read More

Private heap implementation for Linux

Uncategorized
Question: I have code that uses HeapCreate/HeapDestroy/HeapAlloc/HeapFree for private heap management under windows. But I need to implement similar functionality for linux. I know that I can use mmap call for allocation of private heap, but I don't know what can be used instead of HeapAlloc/HeapFree on preallocated private heap, I don't want to write my own implementation of private heap manager to manage all allocations. Maybe boost has something suitable for my needs? Answer: Read more
Read More

Flushing MemoryCache ASP.NET Core 2

c#
Question: I am trying to flush my cache after I update an item, and I have tried a few different options and none are working as expected public class PostApiController : Controller { private readonly IPostService _postService; private readonly IPostTagService _postTagService; private IMemoryCache _cache; private MemoryCacheEntryOptions cacheEntryOptions; public PostApiController(IPostService postService, IPostTagService postTagService, IMemoryCache cache) { _postService = postService; _postTagService = postTagService; _cache = cache; cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromDays(1)); } [HttpGet("{url}", Name = "GetPost")] public IActionResult GetById(string url, bool includeExcerpt) { Post cacheEntry; if (!_cache.TryGetValue($"GetById{url}{includeExcerpt}", out cacheEntry)) { cacheEntry = _postService.GetByUrl(url, includeExcerpt); _cache.Set($"GetById{url}{includeExcerpt}", cacheEntry, cacheEntryOptions); } if (cacheEntry == null) { return NotFound(); } return new ObjectResult(cacheEntry); } [HttpPut("{id}")] public IActionResult Update(int id, [FromBody] Post item) { if (item == null) { return BadRequest(); } var todo = _postService.GetById(id); if…
Read More