One thing that was missing from my blog was the ability for people to “Subscribe” to my blog to get email updates when I write new articles. In order to enable this, I searched for WP Plugins that would enable this with a shortcode so that I can make a special menu button for a … Continue reading WordPress: How to add an email subscription page
Month: July 2018
Python: How to open and read a .docx document
To open and read a Word (.docx) file in Python, we need to import the docx module. If you don’t have the docx module, it can be downloaded with pip. Specifically, we will use the opendocx and getdocumenttext functions of the docx module: from docx import opendocx, getdocumenttext The opendocx() method will be used to … Continue reading Python: How to open and read a .docx document
Python: How to write to a .csv file
Just like reading from .csv files, writing to .csv files also requires importing the csv module. Python: How to open and read .csv documents First define the path and name of your output file, then carefully build your output such that every line you want to write in the .csv file is a list with … Continue reading Python: How to write to a .csv file
Python: How to open and read .csv documents
Unlike text documents, which Python has a native open() function for: Python: How to open and read text documents Opening and reading .csv files requires importing the csv module and using a csv.reader(). For example, this code will open and read the first 10 lines in a .csv file: import csv csv_path = r’C:\Users\Chris\Desktop\Python Scripts\Python … Continue reading Python: How to open and read .csv documents
Python: How to install WinPython and Jupyter Notebook
To use Python with a Jupyter Notebook for Data Science and other projects, you will first need to make sure you have Python 3 and Jupyter Notebook installed. There are Jupyter Notebook installation instructions here: https://jupyter.readthedocs.io/en/latest/install.html This site recommends installing Anaconda, which bundles installation of Python 3 with Jupyter Notebook, which is just fine. However, … Continue reading Python: How to install WinPython and Jupyter Notebook
Python: How to open and read text documents
This article will details some basic Python techniques for opening and reading text files. This applies to any plain text files, they don’t have to have a .txt file extension. I will detail three different techniques. Example 1: Open text files and read one line at a time with .readline() This technique demonstrates probably … Continue reading Python: How to open and read text documents
JavaScript: How to create a custom range slider using bootstrap-slider
This article describes how to create a custom HTML range slider using Bootstrap 3, jQuery, HTML, CSS, and a JavaScript package called “bootstrap-slider”. There are download and installation instructions for this package on github. This slider can be custom styled with CSS and comes with a built-in tooltip. See the graphic below for a description … Continue reading JavaScript: How to create a custom range slider using bootstrap-slider
AngularJS: How to write a simple To Do app
In this article I will describe how to create a simple “To Do” app in AngularJS and write about some of the basic concepts of AngularJS. The app I will be describing looks like this: Step 1: AngularJS CDN To create an AngularJS app, the first thing you will need is a CDN in … Continue reading AngularJS: How to write a simple To Do app
jQuery: How to toggle switches programmatically
Let’s say you have some HTML/CSS switches in place of a traditional checkbox. jQuery makes it easy to toggle switches on or off. For example: function toggle(){ $(‘.slider’).click(); } Which can be called in a button like so: <button type=”button” class=”btn btn-primary” onClick=”toggle();”>Toggle</button> For example: Note: This same jQuery can be triggered without clicking … Continue reading jQuery: How to toggle switches programmatically
JavaScript: How to calculate the number of days between two dates
The following function takes in two dates and returns the number of days between them: // Calculate the difference of two dates in total days function diffDays(d1, d2) { let numDays = 0; let tv1 = d1.getTime(); // msec since 1970 let tv2 = d2.getTime(); numDays = (tv2 – tv1) / 1000 / 86400; numDays … Continue reading JavaScript: How to calculate the number of days between two dates