Just some general notes I’ve stored for personal use.
Author: Tedwood
Centering Images with CSS
img {
text-align: center;
}
That will not work as the text-align property applies to block containers, not inline elements, and img is an inline element.
Put text-align: center on a containing block and as long as the image is still inline, it will be centered.
If the image itself is set to block then it must have left and right margins set to auto.
SO Bookmarklet Code
Just a bookmarklet for personal use.
Continue reading “SO Bookmarklet Code”Simple columns in WordPress content area
It used to be an annoying problem.
Python Working with Directories Reference
My notes compiled on the topic of working with directories, navigating folders and listing files etc.
Continue reading “Python Working with Directories Reference”
Python File Reading and Writing Reference
Just my personal reference notes for everything related to reading and writing files in Python.
Continue reading “Python File Reading and Writing Reference”
Breaking down a function – updateRecords()
A friend asked me to explain this code in detail for a function called updateRecords()
that they were studying on an online learning site. Actually they expect you to create the guts of the function yourself and make sure it meets certain requirements. This is my solution and explanation. It is designed for somewhat beginners so Its deliberately not succinct because the purpose is to explain whats going on in detail in a simple way that is easy to follow. At the end I will demonstrate alternative ways to write the same function in a more concise manner.
Study of a Function – titleCase()
Lets try and do a detailed analysis/deconstruction of a function titleCase()
which takes a string and capitalises the first letter of every word. It uses arrays and some string methods and demonstrates usage of the return keyword and the practice of passing one function as an argument to another.
Reconciling Return
The return keyword and its purpose is actually fairly simple but for some reason it seems to cause beginners a lot of confusion. Even after being exposed to it by example and explanation, it can take some time before understanding really sinks in. I know this was certainly the case for me but I don’t believe it needed to be that way. Lets see if we can’t help lessen that confusion here.
Basic Toggling with javascript
If your not familiar with natural javascript and your only used to using a library like jQuery, then you might be surprised to learn that javascript doesn’t have a predefined toggle function that you can just call up when you want. You need to create your own before you can use it. Here is a bare bones demonstration of toggling in plain old ordinary javascript.