replace using bash – Dynamic value

Uncategorized
Question: I have a Json file that has following values cat file { "key1" = "value1" "key2" = "value2", } I would like to change value1 and value2. Values are dynamic it changes overtime. My sed should work with any value and mylook up should be by key. " my sed command is not helping. sed -i 's/*"key2":*/"key2": "someothervalue2"/' file Answer: It looks like you are dealing with a JSON file? In which case you should be using a proper parser instead of sed, e.g. jq. Assuming your file contains something like this: infile { "key1" : "value1", "key2" : "value2" } You can replace its values with like this:jq '.key1 = "foo" | .key2 = "bar"' < infile Output:{ "key1": "foo", "key2": "bar" } Read more
Read More

Why the process started by a bash script will not exit after the terminal has been closed?

Uncategorized
Question: Case 1: I execute sleep 1000 & in gnome-terminal and then close the terminal. The sleep process does not exist. Case 2: t.sh #!/usr/bin/env bash sleep 1000 & I execute ./t.sh in gnome-terminal and then close the terminal. The sleep process exists(known by ps aux). Should not the process be closed? Thx in advance :) Answer: When using an interactive login shell, bash will send a HUP signal to your jobs on exit if this option is set:juergen@samson:~ → shopt huponexit huponexit on The default handler will terminate your process. When starting a non-interactive bash (like your script) the huponexit option is effectless. See: https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html Read more
Read More

I want to insert data in sql database with a date/time column that update time/date automatically with each insertion in table…? [on hold]

Uncategorized
Question: I have tried timestamp but it come with binary date so is there any possibility to convert binary version to date/time format Answer: I assume you are using MS SQL Server. The datatype DATETIME is your friend here. Combine the datatype DATETIME and a DEFAULT value attribute on your date column. CREATE TABLE dbo.Table_1 ( Id int NOT NULL IDENTITY (1, 1), DateCreated datetime NOT NULL DEFAULT GETDATE(), Description nvarchar(255) NOT NULL ) ON [PRIMARY] GO ALTER TABLE dbo.Table_1 ADD CONSTRAINT PK_Table_1 PRIMARY KEY CLUSTERED ( Id ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] INSERT INTO Table_1 (Description) VALUES('Some text'); SELECT * FROM Table_1 Read more
Read More

KeyCloak Visual Studio

Uncategorized
Question: I am getting an error when I login using KeyCloak. The error I get is "Both the access token and the refresh token have expired" I have followed the example detailed here; https://github.com/dylanplecki/KeycloakOwinAuthentication/wiki/ASP.NET-MVC-Tutorial The code works as far as the login page. I enter my login ID and Password, press the Login button and immediately get the above error on a yellow screen. I have created the client in the Master realm and based all the settings according to what is in the web page above. Does anyone know what I need to do to fix this? Answer: Read more
Read More

The column user_id reference to foun_id of the founder table and the empl_id column of the employee table, any idea how to do it?

Uncategorized
Question: Schema::create('users', function(Blueprint $table) { $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->integer('user_id')->unsigned(); $table->foreign('user_id')->references('foun_id')->on('founder'); $table->foreign('user_id')->references('empl_id')->on('employee'); $table->integer('rol_id')->unsigned(); $table->foreign('rol_id')->references('rol_id')->on('rol'); $table->primary('user_id'); $table->timestamps(); }); Answer: Read more
Read More

Creating Autocomplete Dropdowns with the data comes from database in Javascript

Uncategorized
Question: I want to create a small web application that includes a function to search movies in Javascript. I want to make that when I search a movie's name, the function completes the rest of word. But I couldn't make it. For example: I wrote "bat" and function completes the "man". It is like google search. I wrote "stack" and google completes "overflow" in a dropdown list. So here is my code in script:var dataList = document.getElementById('json-datalist'); var input = document.getElementById('ajax'); var request = new XMLHttpRequest(); request.onreadystatechange = function(response) { if (request.readyState === 4) { var jsonOptions = JSON.parse(request.responseText); jsonOptions.forEach(function(item) { var option = document.createElement('option'); option.value = item; dataList.appendChild(option); }); else { input.placeholder = "Couldn't load datalist options "; } } }; request.open('GET', 'url', true); request.send(); HTML code: Movie name:…
Read More

Spring Data JPA Native Query Pagination Doesn’t work on 2nd Page

sql
Question: I am using pagination on a native query (SQL Server) which works on the initial page request, page 0, but fails with an invalid column name when I try to get the results for the 2nd page. The generated query works in SSMS but does not in Spring. Any insight is appreciated. Here is the error:Hibernate: /* dynamic native SQL query */ WITH query AS (SELECT inner_query.*, ROW_NUMBER() OVER ( ORDER BY CURRENT_TIMESTAMP) as __hibernate_row_nr__ FROM ( SELECT TOP(?) p.ProductKey as page0_, p.ProductName as page1_, p.Sku as page2_, p.MaterialKey as page3_, p.MfgItemNumber as page4_, p.PackageSize as page5_, p.PriceUom as page6_, p.CasePack as page7_, p.ProductDescription as page8_, P.MediaDomain as page9_, p.ImagePath as page10_, p.ImageName as page11_, plp.Price as page12_, plp.ListPrice as page13_, p.SearchText as page14_ FROM [dbo].[BdmProductCategory] pc INNER JOIN…
Read More

Google script email scheduling logic error: all the emails are sent at one designated time, not at their designated time

Uncategorized
Question: I am making an email scheduler using googlescript. Each mail gets a specific date&time to be sent. However, all the mails are sent at the same time, at the first date&time I entered. It seems the second date&time are not recognized. spreadsheet as you see the time, the two emails are sent at the same time Please advice me how to fix this problem. Below is my source. Thank you in advance. function scheduleEmails() { var sheet = SpreadsheetApp.getActiveSheet(); var startRow = 2; // First row of data to process var dataRange = sheet.getRange(startRow, 1, sheet.getLastRow(), 6) // Fetch values for each row in the Range. var data = dataRange.getValues(); for (var i = 0; i < data.length; ++i) { var row = data[i]; var time1 = new Date(row[5]);…
Read More

Ng-model is not picking the input type= “tel” value in AngularJs

Uncategorized
Question: Im trying to add form using couple of input tags..but type='tel' is not working. Here's my html code. Phone Number: I've included intlTelInput plugin in my application. here's controller code $scope.user = {}; $("#mobile-number").intlTelInput({preferredCountries: ['pk']}); $scope.add_user = function (user) { if (user.password != user.confirmPassword) { $scope.passError = "Password does not match.."; } else { $http.post(DataFactory.baseURL + '/user/add.php', {data: user}) .then(function (response) { window.location = "#!/users"; }); } }; Form Data. name:"User1" password:"123456" phone_number:"" how to solve this problem? Answer: Read more
Read More