Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

My favorite way to do it is by using /dev/urandom together with tr to delete unwanted characters. For instance, to get only digits and letters:
***
tr -dc A-Za-z0-9 ***
Alternatively, to include more characters from the OWASP password special characters list:
***
tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' ***
If you have some problems with tr complaining about the input, try adding LC_ALL=C like this:
***
LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' ***
3 years ago
There are many ways to calculate. For simple expressions you can use bash itself:
***
echo $((20+5))
***
or expr:
***
expr 20 + 5
***
And for complex cases there is great tool bc:
***
echo "20+5" | bc
***
Btw, bc can calculate even very complex expression with roots, logarithms, cos, sin and so on.
3 years ago
Assume your iFrame's id is "targetFrame" and the function you want to call is targetFunction():

document.getElementById('targetFrame').contentWindow.targetFunction();
You can also access the frame using window.frames instead of document.getElementById.

// this option does not work in most of latest versions of chrome and Firefox
window.frames[0].frameElement.contentWindow.targetFunction();
3 years ago
These are properties of 'window' object in JavaScript, just like document is one of a property of window object which holds DOM objects.

Session Storage property maintains a separate storage area for each given origin that's available for the duration of the page session i.e as long as the browser is open, including page reloads and restores.

Local Storage does the same thing, but persists even when the browser is closed and reopened.

You can set and retrieve stored data as follows:

sessionStorage.setItem('key', 'value');

var data = sessionStorage.getItem('key');
Similarly for localStorage.
3 years ago
The only difference is that localStorage has a different expiration time, sessionStorage will only be accessible while and by the window that created it is open.
localStorage lasts until you delete it or the user deletes it.
Lets say that you wanted to save a login username and password you would want to use sessionStorageover localStorage for security reasons (ie. another person accessing their account at a later time).
But if you wanted to save a user's settings on their machine you would probably want localStorage. All in all:

localStorage - use for long term use.
sessionStorage - use when you need to store somthing that changes or somthing temporary
3 years ago
Not HTML5, but practical anyway: if you happen to use AngularJS, you can use ng-minlength (or data-ng-minlength) for both inputs and textareas.
3 years ago
You need to add a tag in your containing name="theme-color", with your HEX code as the content value. For example:
***

***
3 years ago
I just discovered the magic of flex boxes (display: flex). Try this:
***


Tree

View


***
3 years ago
Another way of achieving this horizontal and vertical centering is:
***
.Absolute-Center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
***
3 years ago
Here's a straightforward script for finding out the limit:
***
if (localStorage && !localStorage.getItem('size')) {
var i = 0;
try {
// Test up to 10 MB
for (i = 250; i <= 10000; i += 250) {
localStorage.setItem('test', new Array((i * 1024) + 1).join('a'));
}
} catch (e) {
localStorage.removeItem('test');
localStorage.setItem('size', i - 250);
}
}
***

The script will test setting increasingly larger strings of text until the browser throws and exception. At that point it’ll clear out the test data and set a size key in localStorage storing the size in kilobytes.
3 years ago
The @ symbol allows you to use reserved word. For example:
***
int @class = 15;
***
The above works, when the below wouldn't:
***
int class = 15;
***
3 years ago
The solutions posted so far either only replace Environment.NewLine or they fail if the replacement string contains line breaks because they call string.Replace multiple times.

Here's a solution that uses a regular expression to make all three replacements in just one pass over the string. This means that the replacement string can safely contain line breaks.
***
string result = Regex.Replace(input, @"\r\n?|\n", replacementString);
***
3 years ago