Questions

Set date in input type date

I will set today's date in the datepicker input in Chrome. ``` $(document).ready(function() { let now = new Date(); let today = now.getDate() + '/' + (now.getMonth() + 1) + '/' + now.getFull...

19 Aug at 21:25

How to assign the output of a Bash command to a variable?

I have a problem putting the content of `pwd` command into a shell variable that I'll use later. Here is my shell code (the loop doesn't stop): ``` #!/bin/bash pwd= `pwd` until [ $pwd = "/" ] d...

3 Jul at 17:13

What does android:layout_weight mean?

I don't understand how to use this attribute. Can anyone tell me more about it?

Examples for string find in Python

I am trying to find some examples but no luck. Does anyone know of some examples on the net? I would like to know what it returns when it can't find, and how to specify from start to end, which I gues...

7 Jul at 18:52

PHP substring extraction. Get the string before the first '/' or the whole string

I am trying to extract a substring. I need some help with doing it in PHP. Here are some sample strings I am working with and the results I need: ``` home/cat1/subcat2 => home test/cat2 => test s...

2 Sep at 08:21

How to change the opacity (alpha, transparency) of an element in a canvas element?

Using the HTML5 `<canvas>` element, I would like to load an image file (PNG, JPEG, etc.), draw it to the canvas completely transparently, and then fade it in. I have figured out how to load the image ...

24 Dec at 12:53

Java Class that implements Map and keeps insertion order?

I'm looking for a class in java that has key-value association, but without using hashes. Here is what I'm currently doing: 1. Add values to a Hashtable. 2. Get an iterator for the Hashtable.entryS...

3 Nov at 20:25

Build the full path filename in Python

I need to pass a file path name to a module. How do I build the file path from a directory name, base filename, and a file format string? The directory may or may not exist at the time of call. For...

19 Jul at 14:56

Using moment.js to convert date to string "MM/dd/yyyy"

I need to take the date value from jquery datepicker turn it into string format "MM/dd/yyyy" so it can do the right ajax post. When the page loads or upon changing the datepicker, a jquery ajax call i...

14 Mar at 14:19

Official way to ask jQuery wait for all images to load before executing something

In jQuery when you do this: ``` $(function() { alert("DOM is loaded, but images not necessarily all loaded"); }); ``` It waits for the DOM to load and executes your code. If all the images are n...

23 May at 11:47

how to check confirm password field in form without reloading page

I have a project in which I have to add a registration form and I want to to validate that the password and confirm fields are equal without clicking the register button. If password and confirm passw...

19 Dec at 21:10

What is an alternative to execfile in Python 3?

It seems they canceled in Python 3 all the easy way to quickly load a script by removing `execfile()` Is there an obvious alternative I'm missing?

15 Jan at 06:15

Access multiple elements of list knowing their index

I need to choose some elements from the given list, knowing their index. Let say I would like to create a new list, which contains element with index 1, 2, 5, from given list [-2, 1, 5, 3, 8, 5, 6]. W...

Android studio- "SDK tools directory is missing"

When I start Android Studio, it displays a window entitled "Downloading components" which says:  "Android SDK was installed to: C: / Users / user / AppData / Local / android / SDK2`` SDK tools directo...

15 Jul at 14:56

datetime dtypes in pandas read_csv

I'm reading in a csv file with multiple datetime columns. I'd need to set the data types upon reading in the file, but datetimes appear to be a problem. For instance: ``` headers = ['col1', 'col2',...

19 Oct at 14:39

Why does Node.js' fs.readFile() return a buffer instead of string?

I'm trying to read the content of `test.txt`(which is on the same folder of the Javascript source) and display it using this code: ``` var fs = require("fs"); fs.readFile("test.txt", function (err, ...

9 Oct at 03:23

Iterating over all the keys of a map

Is there a way to get a list of all the keys in a Go language map? The number of elements is given by `len()`, but if I have a map like: ``` m := map[string]string{ "key1":"val1", "key2":"val2" }; `...

19 Jul at 23:5

How to clear a textbox using javascript

I have a ``` <input type="text" value="A new value"> ``` I need a javascript method to clear the value of the textbox when the focus is on the textbox. How can this be achieved?

9 Nov at 16:9

Get time difference between two dates in seconds

I'm trying to get a difference between two dates in seconds. The logic would be like this : - - - The reason why I'm doing it it with dates it's because the final date / time depends on some other ...

15 Dec at 17:48

Using PowerShell to write a file in UTF-8 without the BOM

`Out-File` seems to force the BOM when using UTF-8: ``` $MyFile = Get-Content $MyPath $MyFile | Out-File -Encoding "UTF8" $MyPath ``` How can I write a file in UTF-8 with no BOM using PowerShell? ##...

Creation timestamp and last update timestamp with Hibernate and MySQL

For a certain Hibernate entity we have a requirement to store its creation time and the last time it was updated. How would you design this? - What data types would you use in the database (assuming...

21 Oct at 12:6

Calculate the date yesterday in JavaScript

How can I calculate as a date in JavaScript?

22 Dec at 02:48

Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>)

I need some help with this error: > Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse () at Object.success (dashboard.js:22) at fire (jquery-3.3.1.js:3268) at Object.fireWith [as resolv...

Excel 2013 horizontal secondary axis

I have made a scatter plot and I want to have a secondary axis for the x-axis. It used to be easy to do in 2010, but I have no idea where Microsoft put this option in the 2013 version of Excel.

18 Mar at 22:55

How to "pretty" format JSON output in Ruby on Rails

I would like my JSON output in Ruby on Rails to be "pretty" or nicely formatted. Right now, I call `to_json` and my JSON is all on one line. At times this can be difficult to see if there is a prob...

2 Mar at 03:16