This is a quick summary of how to measure time elapsed in Python.
Code
from timeit import default_timer as timer
import time # needed to support sleep.
start = timer()
time.sleep(5) # delay 5 seconds
end = timer()
print(end - start)
Result
Reference:
Measure time elapsed in Python?
http://stackoverflow.com/questions/7370801/measure-time-elapsed-in-python
Posts
Python - How to get current date time and format its output | DzQ39 |
This is a quick summary of how to get the current date and time and format its output in Python.
The Code
import datetime
print datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
The Code
import datetime
print datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
The Result
Reference:
How to print date in a regular format in Python?
How to view cookies in Chrome and Firefox | DzQ39 |
This post is a quick summary of how to view cookies info. using Chrome and Firefox.
Chrome
1. Launch Chrome web browser and visit the site that you want to check for cookies.
2. Right click on the web page to bring up the menu and left click on the last item (Inspection) in the list.
3. The info. for cookies is under Application.
Firefox
1. Install "View Cookies" (https://addons.mozilla.org/zh-tw/firefox/addon/view-cookies/).
2. Restart Firefox.
3. Visit the website that you want to check for cookies, once there, right click on any part of the webpage to bring up the menu. The View Cookies add-on is under View Page Info..
4. Click on Cookies to see cookies info. There is no domain info. because the page is launched locally.
Chrome
1. Launch Chrome web browser and visit the site that you want to check for cookies.
2. Right click on the web page to bring up the menu and left click on the last item (Inspection) in the list.
3. The info. for cookies is under Application.
Note, Chrome doesn't support local cookies. For local cookies support, use Firefox / IE
1. Install "View Cookies" (https://addons.mozilla.org/zh-tw/firefox/addon/view-cookies/).
2. Restart Firefox.
3. Visit the website that you want to check for cookies, once there, right click on any part of the webpage to bring up the menu. The View Cookies add-on is under View Page Info..
4. Click on Cookies to see cookies info. There is no domain info. because the page is launched locally.
How to get the selected option in a drop down list | DzQ39 |
This post is about how to get the selected option in a drop down list. The source of the code is at https://www.w3schools.com/js/tryit.asp?filename=try_dom_select_option.
Code
Reference:
JavaScript HTML Input Examples
https://www.w3schools.com/js/js_input_examples.asp
Code
1 | <!DOCTYPE html> |
Reference:
JavaScript HTML Input Examples
https://www.w3schools.com/js/js_input_examples.asp
Working with cookies | DzQ39 |
This is a quick summary of how to work with cookies.
The code below is from https://www.w3schools.com/js/js_cookies.asp.
Note that Chrome doesn't support local cookies. That is, the above code won't work if it's run from a local storage (it will run fine if it's run from a server). However, Internet Explorer, Firefox, Safari, and Opera don't have such problem. For detail, see the discussion at https://productforums.google.com/forum/#!topic/chrome/iow88FsnNhQ.
The code below is from https://www.w3schools.com/js/js_cookies.asp.
1 | <!DOCTYPE html> |
Note that Chrome doesn't support local cookies. That is, the above code won't work if it's run from a local storage (it will run fine if it's run from a server). However, Internet Explorer, Firefox, Safari, and Opera don't have such problem. For detail, see the discussion at https://productforums.google.com/forum/#!topic/chrome/iow88FsnNhQ.
How to get input text field using HTML and JavaScript | DzQ39 |
This is a quick example of how to get the input value from the input text filed, display it and reset it back to the original content.
Code
Result
Reference:
https://www.w3schools.com/jsref/prop_text_value.asp
https://www.w3schools.com/tags/att_input_placeholder.asp
Code
1 | <!DOCTYPE html> |
Result
Reference:
https://www.w3schools.com/jsref/prop_text_value.asp
https://www.w3schools.com/tags/att_input_placeholder.asp
How to use swipe gestures to change webpages | DzQ39 |
The original post of is at http://stackoverflow.com/questions/23797331/using-swipe-gestures-to-change-pages-in-multi-page-jquery-mobile-application.
Note that because of minor differences, the code at http://jsfiddle.net/Gajotres/JB22E/3/ doesn't work. The code below is from the stackoverflow post and has been tested to work.
The Code
Result
Note that because of minor differences, the code at http://jsfiddle.net/Gajotres/JB22E/3/ doesn't work. The code below is from the stackoverflow post and has been tested to work.
The Code
1 | <!DOCTYPE html> |
Result

