Wednesday, February 28, 2018

The 'Access-Control-Allow-Origin' header with apache

Leave a Comment
https://api.aonesalons.com/dbsynch/webocitysalonpos/ When I send a request to the mentioned URL from POSTMAN, it works fine. However, when sent through my angular application, running at demo.aonesalons.com, I get: Failed to load https://api.aonesalons.com/dbsynch/webocitysalonpos/: The 'Access-Control-Allow-Origin' header contains multiple values '*, https://demo.aonesalons.com', but only one is allowed. Origin 'https://demo.aonesalons.com' is therefore not allowed access. If I directly hit https://api.aonesalons.com/dbsynch/webocitysalonpos/in...
Read More

matplotlib two different colors in the same annotate

Leave a Comment
I am trying to create a figure in python and make is so that the same annonate text will have two colors, half of the annonate will be blue and the other half will be red. I think the code explain itself. I have 3 lines 1 green with green annonate, 1 blue with blue annonate. The 3rd is red its the summation of plot 1 and plot 2, and I want it to have half annonate blue and half green. ipython -pylab x=arange(0,4,0.1) exp1 = e**(-x/5)...
Read More

Safari doesn't emit pointer events on overflowing SVG contents

Leave a Comment
I'm trying to add click events to an SVG Element which has visible overflow and a shape element(circle/path) inside it which overflows the SVG. On Safari(9,10,11), click event doesn't work in the area where the shape element(circle/path) overflows while it works fine in the area present within the SVG. var count = 0; function clickMe() { console.log("in click func"); count++; document.getElementById("counter").innerHTML = count; } #counter { font-size: 2em; } #starSvg { pointer-events: auto;...
Read More

AWS Cognito - Get user data after login with SignInUI

Leave a Comment
I followed the instructions at Add AWS Mobile User Sign In The code looks like this: public class LoginActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); AWSMobileClient.getInstance().initialize(this, new AWSStartupHandler() { @Override public void onComplete(AWSStartupResult awsStartupResult) { SignInUI signIn = (SignInUI)...
Read More

Providing way to configure spring security?

Leave a Comment
Is it possible to configure spring security in a way that it reads configuration details from external file and configures accordingly. (I am not taking about changing config at runtime. I am talking about reading from a file at the time of startup) An example of my existing Sporing security config is: @EnableWebSecurity @Configuration public class SecurityConfig { @Bean public UserDetailsService userDetailsService() throws Exception { InMemoryUserDetailsManager...
Read More

Tuesday, February 27, 2018

Facebook Open Graph og:video tag for YouTube videos

Leave a Comment
I have a question that was initially asked here: Open graph og:video Meta Tags content in 2010, but the answer no longer works. I'm trying to show a YouTube video in Facebook (and have it play inside Facebook) when a link is shared. The following og:video tag on the page doesn't work (it never really did): <meta property="og:video" content="https://www.youtube.com/watch?v=ZH4YSF-i5dY" /> The solution proposed here https://stackoverflow.com/a/17811187/188740 in 2013 worked really well until recently. It was to...
Read More

Websocket backend client connection stops receiving stream updates after a while

Leave a Comment
I'm using nodejs's socket.io-client to get a stream of data from a remote websocket server. After a while, I simply stop receiving data from the remote server. There are no errors, or close events. The data simply stops arriving. What's interesting is that the time before I stop receiving data varies with the specs of the host system. For instance, on my laptop, which is a 4-core i7 with 16GB memory, it can run overnight (about 8-9 hours) before I stop receiving data. On a small AWS EC2 server, I stop receiving data within...
Read More

How control vertical spacing of div children?

Leave a Comment
Task: Keep a vertical list of thumb nails. Thumb nails must scale with window dimensions. Thumb nails are contained in a div the dimensions of which are given using vw, vh. On every resize, a Javascript function recomputes width and height of all thumb nails so that a fixed number of them appears in the visible area of the div and is as big as possible. To keep the thumb nails' vertical spacing constant, the height of the visible thumb nails is added up, increased by a factor and assigned to the div's height. Problem:...
Read More

How to get PyTest working in Visual Studio

Leave a Comment
I want to integrate PyTest into Visual Studio so my tests show up in Test Explorer. So far I have not found any way to do this while some really old posts here suggest that people have done it before. As far as I can tell, as this article suggests, someone should develop an adapter interface for PyTest. However, other posts like this show that others were successful getting this to work. Those have not worked for me so far. Is there a way to get this working? 0 Answe...
Read More

Multi-mixin helper leads to unexpected non-assignable compiler error. Am I doing it wrong?

Leave a Comment
I'm trying to type a multi-mixin helper function that accepts a map of constructors and returns a map of those constructors extended with some new interface. Consider the following contrived base classes: class Alpha { alpha: string = 'alpha'; }; class Beta { beta: string = 'beta'; }; I have a mixin helper function that accepts a map of these classes and returns optionally extended versions of them. Without typings, it looks like this: // The multi-mixin helper function: const Fooable = ({ Alpha, Beta }) => { ...
Read More

Change ID in elasticsearch

Leave a Comment
I'm having trouble with ElasticSearch, how can I change id to another field in log file ? 1 AnswersAnswers 1 In the elasticsearch output you can set the document_id for the event you are shipping. This will end up being the _id in elasticsearch. You can use all sort of parameters / field references / ... that are available in logstash config. Like so: elasticsearch { host => yourEsHost cluster => "yourCluster" index => "logstash-%{+YYYY.MM.dd}" document_id => "%{someFieldOfMyEvent}" }...
Read More

Parsing UTM coordinates to DBGeography in C#

Leave a Comment
I'm writing a WinForms app in C#. I need to ensure no two Datarows in my Datatable are more than 100 km apart. Each row has a UTM Zone, Easting, and Northing in separate DataColumns. All coordinates use the same datum, but some have different zones (otherwise, I would just use pythag math since UTMs are in metres). So far, I'm using the following code to do this, but it doesn't seem like my DbGeography.PointFromText method is working quite right (see * in the code), as when the code reaches the line of code with the...
Read More

Monday, February 26, 2018

Chat history forwardedMessages is empty ArrayList

Leave a Comment
I am trying to implement a java smack client interacting with Openfire server. I have added the plugin for Monitoring service, also enabled archiving. Now I can see the chat history in the openFire Admin Console. I would like to do the same using Smack. This is the code I have written. XMPPTCPConnection connection = connectToXMPP(Constants.XMPPADMINUSERNAME, Constants.XMPPADMINPWD ,Constants.XMPPDOMAIN); MamManager mamManager = MamManager.getInstanceFor(connection); try { DataForm form = new DataForm(DataForm.Type.submit);...
Read More

WordPress - Add gallery overlay to a metabox using wp.media

Leave a Comment
I'm trying to use a metabox to store a comma separated string of attachment IDs in WordPress. I have the metabox working fine, but I'm trying to get the wp.media overlay to open in a way that allows the user to select multiple images, and drag and drop order them, then when clicking "select" button, that it puts the string of IDs into the metabox. Please don't suggest a plugin. I know there are lots of them out there, but I'm building this into a theme and want the bare minimum code. The JS & PHP I have is this:...
Read More

Amazon web services AWS: how to host java app, assign custom domain, custom domain name doesn't work properly

Leave a Comment
I have a site hosted here: http://testapp-test.us-west-2.elasticbeanstalk.com/someservlet.do The site contains an index.jsp and a someservlet. In https://my.freenom.com cabinet I tried: to set nameservers and to set url forwarding to http://testapp-test.us-west-2.elasticbeanstalk.com. The former doesn't work: I set the nameservers as the screen shows and when trying to access codingrecords.tk it is just blank. URL forwarding however...
Read More

Why does Tomcat memory Zig Zag Pattern

Leave a Comment
I have an application deployed on Tomcat and there are no users on it and there is no timer or anything like that on the application, but the memory keeps growing then GC kicks in and bring it down again My question is, what is causing the memory to grow like this even when the application is completely idle note - I have observed this in on two separate applications, both running on Tomcat. The memory usage in the example below...
Read More

How to write equivalent Tensorflow code with same logic?

Leave a Comment
myx=np.array([2.4,0.2,0.5,1.6]) myy=np.array([10.1,3.2,7.5,8.6,1,0.1,11,18]) I want to write a program that match each element of “myx” to “myy” using a greedy algorithm. The match will be 1:1, with caliper distance <=0.5, without replacement. The algorithm is simple: import numpy as np myx=np.array([2.4,0.2,0.5,1.6]) myy=np.array([10.1,3.2,7.5,8.6,1,0.1,11,1.4]) Xxx=np.transpose(np.repeat(myx[:, np.newaxis], myy.size , axis=1)) Yyy=np.repeat(myy[:, np.newaxis], myx.size , axis=1) # define a caliper calp=0.5 matches...
Read More

Listing unpublished posts via Facebook API

Leave a Comment
How does one list draft posts via the Facebook API? There are endpoints for published_posts and scheduled_posts, but nothing for draft_posts. The posts endpoint seems to be the same as published_posts. The Graph API does not seem to mention draft or hidden posts. The page/feed documentation mentions: /page-id/posts shows only the posts that were published by this page. /page-id/tagged shows all public posts in which the page has been tagged. /page-id/promotable_posts shows only boostable posts (includes...
Read More

tf.keras.optimizers.Adam and other optimizers with minimization

Leave a Comment
I want to use the tf.contrib.keras to play around with it. However, there is something I don't understand. The classes from tf.train have a function minimize that you use for the optimization of your function. However, this minimize function does not exists for the classes in tf.contrib.keras.optimizers. Let's say we have the following code: # tensorflow tf.train.AdamOptimizer(learning_rate=0.001) updateModel = trainer.minimize(loss) # keras wrapper trainer=tf.contrib.keras.optimizers.Adam() updateModel = trainer.minimize(loss)...
Read More

JS, Vue: how to split text based on window height?

Leave a Comment
I have text that I want to split at a specific point so that you dont need to scroll down. That means I want to know when the text gets longer than the availible height of the window. This needs to be known before I show the text. The problem with that is that I need to know how my layout will look like before I render it, because the whole thing should be responsive to width and height. I also plan to resize the fontsizes a little. So taking all that to account, does anyone of you know of you know how to split the...
Read More