Thursday, November 30, 2017

Caching reverse proxy for dynamic content

Leave a Comment
I was thinking about asking on Software Recommendations, but then I've found out that it may be a too strange request and it needs some clarification first. My points are: Each response contains an etag which is a hash of the content and which is globally unique (with sufficient probability) The content is (mostly) dynamic and may change anytime (expires and max-age headers are useless here). The content is partly user-dependent, as given by the permissions (which itself change sometimes). Basically, the proxy should...
Read More

Is there a way to find all the global styles that apply to a web page?

Leave a Comment
As a company, we use components (Angular, Vue and React) to build our applications, but we still have a good number of global styles that we inherited from our legacy app. eg: .active { background: red; } Will apply to any element anywhere on the page that has a class of active. Is there a way, in the browser, to generate a list of all the global (i.e. non-namespaced) style rules that apply to a page, bearing in mind that these...
Read More

Checkbox styling doesn't work on Safari mobile

Leave a Comment
I want to style the checkboxes like the following: This is my CSS: .checkboxcontact input[type="checkbox"] { -webkit-appearance: none; background-color: white; border: 1px solid #d44803; padding: 9px; border-radius: 3px; display: inline-block; position: relative; float:left; } .checkboxcontact input[type="checkbox"]:checked { background-color: #d44803; border: 1px solid white; color:...
Read More

Removing # from url of angularJS for SEO with backend as Django

Leave a Comment
I know removing hash from AngularJS is pretty straightforward but the problem is that the backend is in Django. So, the app works unless the page is refreshed using "F5". so, http://127.0.0.1:8000/account works if the button is clicked but refreshing the page gives me Page not found as the server searches for it in urls.py file Can someone please suggest me any fix for this ? 2 AnswersAnswers 1 Everything is right. When you refresh the page, firstly request gets processed on the server (and goes to django router)....
Read More

How can I write data processing code using Pandas that gives me at least as high performance as handwritten, standard Python code?

Leave a Comment
I have a machine learning application written in Python which includes a data processing step. When I wrote it, I initially did the data processing on Pandas DataFrames, but when this lead to abysmal performance I eventually rewrote it using vanilla Python, with for loops instead of vectorized operations and lists and dicts instead of DataFrames and Series. To my surprise, the performance of the code written in vanilla Python ended up being far higher than that of the code written using Pandas. As my handcoded data processing...
Read More

Wednesday, November 29, 2017

Qt-project as a git-submodule for another Qt-project

Leave a Comment
I have a Qt-application. It has a .pro file with TEMPLATE = app. One of the project's subfolders is a git-submodule to another Qt project: a collection of libraries, which has it's own .pro file with TEMPLATE = subdirs. Graphically it looks like: project/ app.pro (TEMPLATE = app) stuff/ libs/ <-- git-submodule libs.pro (TEMPLATE = subdirs) lib1/ lib1.pro (TEMPLATE = lib) lib2/ lib2.pro (TEMPLATE = lib) libs as a standalone project compiles well and produces...
Read More

How to prevent HTTP session flood attack

Leave a Comment
Flood Attack: In short, a hacker can keep hitting the server (without cookie) to force Java container to keep creating new session. I am using Spring Security to manage session. I realize jsessionid keep being created before login, this is not what I want. So I did: 1) in Spring security config: sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER) 2) disable session creation in jsp. Because I am using apache tile, due to it is using dynamic include, so I have to disable session creation in all the...
Read More

How to use JSON.parse in nunjucks

Leave a Comment
i am get data in mongodb and express return occurs without errors but I wanted to use JSON.parse in the final results of my .find see below how I'm trying to do this app.get("/login", (req, res) => { var credentialClient = { expire_at: false, __v: false, _id: false }; rememberMe.find({ username: "test-login" }, credentialClient, function (err, credentialInfo) { if (err) { res.send(err); } else { res.render("login.html", { usernameClient: JSON.parse(credentialInfo)...
Read More

Flexdashboard doesn't work with Shiny URL state

Leave a Comment
I am trying to combine flexdashboard with Shiny state bookmarking. When used alone (example from the docs) Shiny app works fine, but when put in flexdasboard, url is not updated: --- title: "Untitled" output: flexdashboard::flex_dashboard: orientation: columns vertical_layout: fill runtime: shiny --- ```{r setup, include=FALSE} library(flexdashboard) ``` Column {data-width=650} ----------------------------------------------------------------------- ### Chart A ```{r} shinyApp( ui=function(req) { ...
Read More

XPATH in ANTLR4 with Cpp runtime

Leave a Comment
I can't find a way to work properly with Xpath in the cpp runtime of ANTLR4. Precisely, I have noticed that the path.split(..) function always returns an empty vector. As a result the function path.evaluate(context) always returns the unmodified (input) context parameter. I was expecting to get at least two Xpath elements (root // and wildecar *) with the following code : const std::string xpath_str ="//*/ID"; antlr4::tree::xpath::XPath path(&parser, xpath_str);...
Read More

Flask Form data duplicates on submit

Leave a Comment
i am trying to populate a table of current values, then change it with intention of finding the diffs of original and after. i simplify my code in the following to replicate the issue: - webapp.py from flask import Flask, render_template from flask_wtf import FlaskForm from wtforms import StringField, DecimalField, fields import pandas as pd app=Flask(__name__) app.config['SECRET_KEY'] = 'wtf' class stockForm(FlaskForm): stock=StringField() price= DecimalField() def __init__(self, csrf_enabled=False, *args,...
Read More

Relinquish rights on Windows

Leave a Comment
I have a C++ application that runs as administrator (it is compiled with a manifest with requestedExecutionLevel set to requireAdministrator. At some point, once all the tasks requiring administration rights are done, I would like to relinquish those rights and perform the remaining tasks as the user that launched the application. Windows provides the ImpersonateLoggedOnUser function, but I can't find any way to obtain a token for the user that called the application. Are there any other ways to do what I have described...
Read More

How to start a non existent Activity mentioned in Manifest?

Leave a Comment
I am attempting to develop a "Dynamic" Android application. Dynamic in the sense that I have an activity listed in the manifest that is "built" at runtime. I can build the required activity fine, however when I attempt to start it my application fails with... java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.research.ps/com.research.Dynamic}: java.lang.ClassNotFoundException: Didn't find class "com.research.Dynamic" on path: DexPathList[[zip file "/data/app/com.research.ps-1/base.apk"],nativeLibraryDirectories=[/data/app/com.research.ps-1/lib/arm,...
Read More

Tuesday, November 28, 2017

Rails .js.erb templates no longer work with Webpack

Leave a Comment
I've just switched my Rails app over to use WebPack to deal with assets etc. It's working well apart from I have some JS templates in my views directory (*.js.erb) . These require jQuery and as jQuery is pulled in as part of my WebPack bundles, it is not working in those templates. Is there a way to allow those templates to work? 1 AnswersAnswers 1 Well in order to make things work you need to include jquery using yarn which works with the latest version of rails. In Rails 5.1 this is done with the new JavaScript...
Read More

Identifying conflicting dates on create in rails

Leave a Comment
Making a reservation app. How can I check or validate the date for example date_start and date_end has the value of date_start date_end 26-11-2017 27-11-2017 I will create another reservation which has these starting and end date values but it conflicts with the other values. How can I check for conflicting dates? date_start date_end 25-11-2017 28-11-2017 Used this to validate the dates in between Model validate :no_reservation_overlap scope :overlapping, ->(period_start, period_end) do where "((date_start...
Read More

Monday, November 27, 2017

How to convert OAuth code with an access token

Leave a Comment
Imagine you're going through a standard OAuth2 process to retrieve an access_token for some third-party API. This is the usual process. User is redirected to http://some-service.com/login User successfully logs in and is redirected to some destination http://some-destination.com. In this step, there's usually a code parameter that comes with the request. So the actual URL looks like http://some-destination.com?code=CODE123 I need...
Read More

Changing external CSS from chrome extension

Leave a Comment
I am writing a chrome extension that needs to iterate over ALL stylesheets in the page it is injected into and modify certain styles. I iterate/modify styles for example like this: const iterate = (doc, f) => { for (const styleSheet of doc.styleSheets) { const rules = styleSheet.rules || styleSheet.cssRules; if (!rules) continue; for (const cssRule of rules) { if (!cssRule.style) continue; const selector = cssRule.selectorText, style = cssRule.style; if (!selector || !style.cssText)...
Read More

Capistrano is failing because it cannot connect to remote git repository

Leave a Comment
I am trying to deploy using capistrano 3.x I configured AgentForwarding in my /.ssh/config file: Host git-codecommit.*.amazonaws.com Hostname xxxx ForwardAgent yes IdentityFile /path/to/codecommit_rsa I did the same thing for my server connection with ForwardAgent 'yes' also. I verified my server allows agent forwaridng in the /etc/ssh/sshd_config file also. AllowAgentForwarding yes INFO ---------------------------------------------------------------- INFO START 2017-11-18 16:09:44 -0500 cap production...
Read More

LocalDateTimeType in FilterDef translates to bigint instead of timestamp

Leave a Comment
On my entity class I have the following filter definitions: @FilterDefs({ @FilterDef(name="courseStartsBetween", parameters = { @ParamDef(name="startDateTime", type="LocalDateTime"), @ParamDef(name="endDateTime", type="LocalDateTime") }) }) @Filters({ @Filter(name="courseStartsBetween", condition="scope_id NOT IN (select scope_id FROM course_time_slot WHERE course_time_slot.end_date_time < :startDateTime OR course_time_slot.start_date_time > :endDateTime)") }) Based on the Hibernate...
Read More

Soap UI vs Curl Response tIme Difference

Leave a Comment
I have hosted a soap service built using spring in one of our data centers. When I test via SOAP UI , I get the response in 1 second or less. However when I run the same request via CURL , it takes more than 30 seconds to execute. I am running both the commands from same machine. What could be causing this difference? curl -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:" -d @request.xml <endpoint> 1 AnswersAnswers 1 A few things to consider: the media type (Content-Type header field) for SOAP...
Read More

Sunday, November 26, 2017

How to sync scrolling first-positions of 2 RecyclerViews?

Leave a Comment
Background I have 2 RecyclerView instances. One is horizontal, and the second is vertical. They both show the same data and have the same amount of items, but in different ways, and the cells are not necessary equal in size through each of them . I wish that scrolling in one will sync with the other, so that the first item that's shown on one, will always be shown on the other (as the first). The problem Even though I've succeeded...
Read More