How do I get the user in tomcat’s access log?

Uncategorized
Question: I have a spring application running on tomcat running on an EC2 instance managed by AWS Elastic Beanstalk. The application uses HTTP Basic Authentication and the log properties are not overriden. I believe the default log format for access logs is: "%h %l %u %t "%r" %s %b" where %u is supposed to give the user in HTTP Authentication. However, my logs have a - in the user column. A line of log looks like: 127.0.0.1 - - [15/Aug/2017:05:43:33 +0000] "GET /v1//client/test/team HTTP/1.1" 200 319 How do I get it to display the username that was passed in the HTTP Basic Auth header? Answer: Read more
Read More

button handler not getting called in jquery/jasmine

Uncategorized
Question: My code is working fine on browser but not when I use Jasmine. This fails my unit test set up. I have a form with a button. Check Answer I have set handler for the button in app.js inside a function learnjs.problemView = function(data) { var view = $('.templates .problem-view').clone(); function checkAnswerClick(){ console.log('checking answer'); if(checkAnswer()){ console.log('setting to correct'); resultFlash.text('Correct!'); }else{ console.log('setting to incorrect'); resultFlash.text('Incorrect!'); } return false; } console.log('inside pv') var b = view.find('.check-btn'); b.click(checkAnswerClick); } From Jasmine, I am calling its click method but it is not getting working. I do not see console print console.log('checking answer'); I see error in browser Expected '' to equal 'Correct!'. This is because the should be set to either Correct or Incorrect but it is empty! describe ('answer section',function() { it('can…
Read More

Chrome 60 enable logging in headless mode

Uncategorized
Question: I'm using Geb (Selenium & Webdrivers 3.40) with Chrome 60 on Windows 7 Enterprise. My GebConfig.groovy defines a chrome environment that configures Chrome with the following start arguments --headless --disable-gpu --disable-plugins --enable-logging --v=1. environments { chrome { ChromeDriverManager.instance.setup() driver = { ChromeOptions options = new ChromeOptions() options.addArguments('--headless', '--disable-gpu', '--disable-plugins', '--enable-logging', '--v=1') def capabilities = DesiredCapabilities.chrome() capabilities.setCapability(ChromeOptions.CAPABILITY, options) def driver = new ChromeDriver(capabilities) return driver } } } According to this post Chrome should log to ~/.config/google-chrome but after running my Geb tests I cannot find any log on that path. I'm trying to enable the log since I have trouble connecting a internal website using HTTPS and I need more information on what is going wrong. Can you tell me how to enable the log correctly and where I…
Read More

How exactly does Keras take dimension argumentsfor LSTM / time series problems?

Uncategorized
Question: I can't seem to find a concrete answer to the question of how to feed data into Keras. Most examples seem to work off image / text data and have clearly defined data points. I'm trying to feed music into an LSTM neural network. I want the network to take ~3 seconds of music and nominate the next 2 seconds. I have my music prepared into .wav files and partitioned into 5 second intervals that I've decomposed into my X (first 3 seconds) and Y (last two seconds). I've sampled my music at 44,100 hz so my X is 132,300 observations 'long' and my Y is '88,200' observations long. But I can't figure out exactly how to bridge Keras to my data structure. I'm using a Tensorflow backend. In…
Read More

Is it possible to fetch / query the pressed keys on keyboard without events?

Uncategorized
Question: I wanted to know if events are required to get the currently pressed keys (or mouse buttons by extension) with Javascript. Is there any way to fetch or query the keys without any events, and thus be able to get them with a simple loop (for example). Answer: The act of pressing a key fires an event, regardless of whether or not you have an event handler for that event configured. As to whether or not you need an event handler to detect a key press - I believe the answer is yes you do. However, you could simulate the functionality you are requesting with a global object variable, and an event handler each for keydown and keyup which stores the pressed key and removes the released key in…
Read More

VBS copy paste one cell in Excel

excel
Question: I have found vbscripts to copy ranges and between different worksheets, but who has a simple script for simply copying one cell to another in the same sheet? I have tried this script, but without luck: ws.Cell(2,35).Value = Cell(1,16) Answer: Sub Paste_Values_Examples() 'Set a cell C1 value equal to another cell A1 value Range("C1").Value = Range("A1").Value End Sub Copied from https://www.excelcampus.com/vba/copy-paste-cells-vba-macros/ Read more
Read More

Pass a connected component into React Route causing error

Uncategorized
Question: When I pass a connected component export default connect(ComponentName) to a React Route route like code below, I get the following errors, You must pass a component to the function returned by connect. Instead received {"match":{"path":"/:code","url":"/sample- code","isExact":true,"params":{"code":"sample-code"}},"location":{"pathname":"/sample-code","search":"","hash":""},"history":{"length":40,"action":"POP","location":{"pathname":"/sample- code","search":"","hash":""}}} Can I pass a connected component to route component? Answer: connect take as its arguments functions like mapStateToProps. You probably meant connect()(ComponentName). You can definitely pass a connected component to a route with the component prop, no need to use something like the render prop. Read more
Read More

Send InLine message to channel with bot

Uncategorized
Question: Is it possible to Send InlineMessage to Channel with Bot Automatically ? in InlineMessage after trying user to use Inline method Telegram sends InlineQueryUpdate, after that Bot should AnswerInlineQuery with InlineQueryResults. and then, User after select any of InlineQueryResults , Result is Send to user. In channel because no body there to select any of Results, InlineKeyboardSwitchInlineQueryButton is removed from Markup. So, What we can do? Answer: Read more
Read More

How to sync deleted files to server in PhpStorm

Uncategorized
Question: is there a clean way how to "push" deleted file to the remote server through PhpStorm? (And I am not looking for the solution with "automatically upload files to server on explicit action". I don't want to use this feature since it rewrote our code many many times.) All I could came up with was to sync parent folder and mark the file for delete, but it does not seem right. Answer: Read more
Read More

Same git repository on multiple private network

Uncategorized
Question: We have two private networks and one of them has local git repository. Only one computer can connect each networks. Other developers cannot connect each networks, developer should develop in their networks. We want to make two git repository for each networks, we must sync these git repositories daily using computer that connects these networks. How can we setup two git repositories and sync it daily? Answer: Read more
Read More

How to str_slug into model?

laravel
Question: search.blade.php @foreach($search as $item) @endforeach SearchController.php public function postSearch(SearchRequest $request){ $search_key = $request->input('search'); $key_space = str_slug($search_key," "); $search = moives::where('row_name','like',"%$key_space%") ->orderBy('id','DESC') ->get(); if(count($search) > 0){ return view('user.pages.search',compact('search','search_key')); } else { return view ('user.pages.search')->withMessage('No Details found. Try to search again !'); } } Url results: http://lar.dev/blog/11609/Beauty%20and%20the%20Beast.html But I want results: http://lar.dev/blog/11609/Beauty-and-the-Beast.html The condition here is that I can not add columns to the database, I can only retrieve data from the database. Answer: In order to divide words with - use str_slug like this:str_slug($string,"-"); Read more
Read More