Programming & Web Design Articles
Ever wonder what makes the software, websites, and blogs you use every day function properly (or improperly)? It's programming. Our articles reveal the ins and outs of programming and web design.
Articles From Programming & Web Design
Filter Results
Cheat Sheet / Updated 03-26-2024
If you want to build your own website from start to finish, this book serves as a great resource. It includes many secrets and best practices that web developers know and implement when building any quality website. This cheat sheet includes bits and pieces of what you'll find in the book.
View Cheat SheetCheat Sheet / Updated 01-18-2024
Tailor your blog with WordPress software, whether you're writing, editing, or publishing WordPress site content. An understanding of WordPress's dashboard controls and of the types of content available to you helps you get the most out of your website. Also, when all else fails, it's good to know where you can turn to for help with WordPress.
View Cheat SheetCheat Sheet / Updated 01-05-2024
One of the handiest features of web coding and development is that once you’ve learned a few basics, you can apply those basics to any project. A good example is the underlying structure of a page, which uses the same set of standard HTML tags, no matter how large or small the project. It’s also worth your time to learn how selectors work, because you use them to save you time both when you’re writing CSS rules and when you’re writing JavaScript code. Errors, too, are a fact of web coding life, so understanding the most common errors can help you debug your code faster and get back to more creative pursuits.
View Cheat SheetCheat Sheet / Updated 11-13-2023
Note: The following cheat sheet is from Building Websites All-in-One For Dummies which published in 2012; therefore, this content may be outdated. For more current information on website building, please see HTML, CSS, & JavaScript All-in-One For Dummies. Whether complex or simple, websites require that you make decisions — such as color, theme, and tone — and that you juggle many pieces of the project — like code, style sheets, and graphics. Knowing which resources to turn to for help implementing HTML5, and a few key points about incorporating graphics and video, can help you.
View Cheat SheetArticle / Updated 10-04-2023
Programming is an important skill. Python will serve you well for years to come. The tables here give you the core words, built-ins, standard library functions, and operators that you'll use most when you're coding with Python. Python Core Words KeywordSummaryExample and Logical operator to test whether two things are both True. andx>2 and x<10 as Assign a file object to a variable. Used with with.Let your code refer to a module under a different name (also called an alias). Used with import. with open(<name of file>,<file mode>) as <object name>:import cPickle as pickle break Stop execution of a loop. for i in range(10): if i%2 ==0: break class Define a custom object. class <name of class>(object): ""Your docstring"" class MyClass(object): ""A cool function."" continue Skip balance of loop and begin a new iteration. for i in range(10): if i%2 ==0: continue def Define a function. def <name of function>(): ""Your docstring"" def my_function(): ""This does... "" elif Add conditional test to an if clause. See if. else Add an alternative code block. See if. for Create a loop which iterates through elements of a list (or other iterable). for <dummy variable name> in <sequence>:for i in range(10): from Import specific functions from a module without importing the whole module. from <module name> import <name of function or object>from random import randint global Make a variable global in scope. (If a variable is defined in the main section, you can change its value within a function.) global x if Create a condition. If the condition is True, the associated code block is executed. Otherwise, any elif commands are processed. If there are none, or none are satisfied, execute the else block if there is one. if : [elif : , ...][else: ]if x == 1: print("x is 1")elif x == 2: print("x is 2")elif x > 3: print("x is greater than 3")else print("x is not greater than 3, nor is it 1 one or 2") import Use code defined in another file without retyping it. import <name of module>import random in Used to test whether a given value is one of the elements of an object. 1 in range(10) is Used to test whether names reference the same object. x = Nonex is None # faster thanx == None lambda Shorthand function definition. Usually used where a function needs to be passed as an argument to another function. lamda :times = lambda x, y: x*ycommand=lambda x: self.draw_line(self.control_points) not Logical negation, used to negate a logical condition. Don't use for testing greater than, less than, or equal. 10 not in range(10) or Logical operator to test whether at least one of two things is True. orx<2 or x>10 pass Placeholder keyword. Does nothing but stop Python complaining that a code block is empty. for i in range (10): pass print Output text to a terminal. print("Hello World!") return Return from the execution of a function. If a value is specified, return that value, otherwise return None. return return x+2 while Execute a code block while the associated condition is True. while :while True: pass with Get Python to manage a resource (like a file) for you. with open(,) as : Extend Python's core functionality with these built-ins. Python Built-ins Built-inNotesExample False Value, returned by a logical operation or directly assigned. ok_to_continue = Falseage = 16old_enough = age >=21(evaluates comparison age>=21 and assigns the result to old_enough) None Value used when representing the absence of a value or to initialise a variable which will be changed later. Returned by functions which do not explicitly return a value. x = None True Value, returned by a logical operation. ok_to_continue = Trueage = 16old_enough = age >=21(evaluates comparison age>=21 and assigns the result to old_enough) __name__ Constant, shows module name. If it's not "__main__", the code is being used in an import. if __name__=="__main__": dir List attributes of an item. dir(<object name>) enumerate Iterate through a sequence and number each item. enumerate('Hello') exit Exit Python (Command Line) interpreter. exit() float Convert a number into a decimal, usually so that division works properly. 1/float(2) getattr Get an attribute of an object by a name. Useful for introspection. getattr(<name of object>, <name of attribute>) help Get Python docstring on object. help(<name of object>)help(getattr) id Show the location in the computer's RAM where an object is stored. id(<name of object>)id(help) int Convert a string into an integer number. int('0') len Get the number of elements in a sequence. len([0,1]) object A base on which other classes can inherit from. class CustomObject(object): open Open a file on disk, return a file object. open(, )open('mydatafile.txt', 'r') # read(opens a file to read data from)open('mydatafile.txt', 'w') # write(creates a new file to write to, destroys any existing file with the same name)open('mydatafile.txt', 'a') # append(adds to an existing file if any, or createsa new one if none existing already) print Reimplementation of print keyword, but as a function.Need to import from the future to use it (srsly!) from future import print_functionprint ('Hello World!') range Gives numbers between the lower and upper limits specified (including the lower, but excluding the upper limit). A step may be specified. range(10)range(5,10)range(1,10,2) raw_input Get some text as a string from the user, with an optional prompt. prompt = 'What is your guess? 'players_guess = raw_input(prompt) str Convert an object (usually a number) into a string (usually for printing). str(0) type Give the type of the specified object. type(0)type('0')type([])type({})type(()) Use the work that others have already done. Try these modules from the Python standard library. Selected Functions from the Standard Library ModuleWhat It DoesSample Functions/Objects os.path Functions relating to files and file paths. os.path.exists() pickle, cPickle Save and load objects to/from a file. pickle.load(), pickle.dump(, ) random Various functions relating to random numbers. random.choice(), random.randint(, ), random.shuffle() String Stuff relating to strings. string.printable sys Various functions related to your computer system. sys.exit() Time Time-related functions. time.time() Tkinter User interface widgets and associated constants. Tkinter.ALLTkinter.BOTHTkinter.CENTERTkinter.ENDTkinter.HORIZONTALTkinter.LEFTTkinter.NWTkinter.RIGHTTkinter.TOPTkinter.YTkinter.Button(,text=)Tkinter.Canvas(, width=, height=)Tkinter.Checkbutton(, text=)Tkinter.Entry(, width=),Tkinter.Frame()Tkinter.IntVar()Tkinter.Label(, text = )Tkinter.mainloop()Tkinter.Menu()Tkinter.OptionMenu(, None, None)Tkinter.Scale(, from_=, to=)Tkinter.Scrollbar()Tkinter.StringVar()Tkinter.Tk() Add, subtract, divide, multiply, and more using these operators. Python Operators OperatorNameEffectExamples + Plus Add two numbers.Join two strings together. Add: >>> 1+12Join: >>> 'a'+'b''ab' – Minus Subtract a number from another.Can't use for strings. >>> 1-10 * Times Multiply two numbers.Make copies of a string. Multiply: >>> 2*24Copy: >>> 'a'*2'aa' / Divide Divide one number by another.Can't use for strings. 1/2 # integer division:Answer will be rounded down.1/2.0 # decimal division1/float(2) # decimal division % Remainder (Modulo) Give the remainder when dividing the left number by the right number.Formatting operator for strings. >>> 10%31 ** Power x**y means raise x to the power of y.Can't use for strings. >>> 3**29 = Assignment Assign the value on the right to the variable on the left. >>> a = 1 == Equality Is the left side equal to the right side? Is True if so; is False otherwise. >>> 1 == 1True>>> 'a' == 'a'True != Not equal Is the left side not equal to the right side? Is True if so; is False otherwise. >>> 1 != 1False>>> 1 != 2True>>> 'a' != 'a'True > Greater than Is the left side greater than the right side?>= means greater than or equal to >>> 2 > 1True < Less than Is the left side less than the right side?<= means less than or equal to >>> 1 < 2True & (or and) And Are both left and right True?Typically used for complex conditions where you want to do something if everything is True:while im_hungry and you_have_food: >>> True & TrueTrue>>> True and FalseFalse >>> True & (1 == 2)False | (or or) Or Is either left or right True?Typically used for complex conditions where you want at least one thing to be True:while im_bored or youre_bored: >>> True | FalseTrue>>> True or FalseTrue>>> False | FalseFalse>>> (1 == 1) | FalseTrue
View ArticleCheat Sheet / Updated 10-03-2023
Python is an incredible programming language that you can use to perform data science tasks with a minimum of effort. The huge number of available libraries means that the low-level code you normally need to write is likely already available from some other source. All you need to focus on is getting the job done. With that in mind, this Cheat Sheet helps you access the most commonly needed reminders for making your programming experience fast and easy.
View Cheat SheetArticle / Updated 09-29-2023
There are plusses and minuses of adding sound to your Web page, but if you decide adding sound is of value to your Web page visitors, HTML offers two competing ways to add it: with the <bgsound> tag and with the embed tag. The <bgsound> tag works well and has useful options for controlling sound, but it’s not supported by all browsers. This example uses the <embed> tag, which is not officially supported by the HTML standard at all, but it works in most browsers. <embed> has options for different media players, such as Windows Media Player or Apple QuickTime. Follow these steps to add sound to a Web page in a text editor: Open your Web page in Notepad. Let your Web page’s user know they can stop sound from playing in your Web page by clicking the Stop button in their browsers. Enter the <embed> tag and a link to the sound file you want to use. An example looks like this: <embed src=<i>“pathname/filename”</i>>, <i>“pathname/filename”</i> is a link to the sound file. The simplest way to be sure you have the link right is to place the sound file in the same folder as the Web page; that way the link is simply the filename. Click File→Save and reopen the file. The sound should play. Test the link right away to be sure it will work. If the sound doesn’t play, experiment to make sure you have the path right and that sound plays on your machine. To make sure you have the link right, put the file in the same folder as your Web page and simplify the link. To make sure that sound playback works on your machine, navigate to the file in Windows Explorer and click it. It should play. If not, identify and fix the files affecting sound playback on your machine.
View ArticleCheat Sheet / Updated 09-25-2023
One of the bonuses you get when you tackle HTML, CSS, and JavaScript is that after you learn a few basics, you can apply those basics to any project. A good example is the underlying structure of a page, which uses the same set of standard HTML tags, no matter how large or small the project. It’s also worth your time to learn the most powerful CSS selectors, because you use those selectors all the time to speed up your work when you’re writing rules. Programming errors, too, are a fact of web coding life, so understanding the most useful JavaScript debugging strategies can help you fix your code faster and get back to more creative pursuits.
View Cheat SheetArticle / Updated 09-13-2023
Many organizations are using Python these days to perform major tasks. You don't necessarily hear about them because organizations are usually reserved about giving out their trade secrets. However, Python is still there making a big difference in the way organizations work and toward keeping the bottom line from bottoming out. Following, are some major ways in which Python is used commercially that will make it easier to argue for using Python in your own organization. (Or you can read about some Python success stories.) Corel: PaintShop Pro is a product that many people have used over the years to grab screenshots, modify their pictures, draw new images, and perform a lot of other graphics-oriented tasks. The amazing thing about this product is that it relies heavily on Python scripting. In other words, to automate tasks in PaintShop Pro, you need to know Python. D-Link: Upgrading firmware over a network connection can be problematic, and D-Link was encountering a situation in which each upgrade was tying up a machine — a poor use of resources. In addition, some upgrades required additional work because of problems with the target device. Using Python to create a multithreaded application to drive updates to the devices allows one machine to service multiple devices, and a new methodology allowed by Python reduces the number of reboots to just one after that new firmware is installed. D-Link chose Python over other languages, such as Java, because it provides an easier-to-use serial communication code. Eve-Online: Games are a major business because so many people enjoy playing them. Eve-Online is a Massively Multiplayer Online Role Playing Game (MMORPG) that relies heavily on Python for both the client and server ends of the game. It actually relies on a Python variant named StacklessPython, which is important because you encounter these variants all the time when working with Python. Think of them as Python on steroids. These variants have all the advantages of Python, plus a few extra perks. The thing to take away from this particular company is that running an MMORPG takes major horsepower, and the company wouldn't have chosen Python unless it were actually up to the task. ForecastWatch.com: If you have ever wondered whether someone reviews the performance of your weatherman, look no further than ForecastWatch.com. This company compares the forecasts produced by thousands of weather forecasters each day against actual climatological data to determine their accuracy. The resulting reports are used to help improve weather forecasts. In this case, the software used to make the comparisons is written in pure Python because it comes with standard libraries useful in collecting, parsing, and storing data from online sources. In addition, Python's enhanced multithreading capabilities makes it possible to collect the forecasts from around 5,000 online sources each day. Most important of all, the code is much smaller than would have been needed by other languages such as Java or PHP. Frequentis: The next time you fly somewhere, you might be relying on Python to get you to the ground safely again. It turns out that Frequentis is the originator of TAPTools, a software product that is used for air traffic control in many airports. This particular tool provides updates on the weather and runway conditions to air traffic controllers. Honeywell: Documenting large systems is expensive and error prone. Honeywell uses Python to perform automated testing of applications, but it also uses Python to control a cooperative environment between applications used to generate documentation for the applications. The result is that Python helps generate the reports that form the documentation for the setup. Industrial Light & Magic: In this case, you find Python used in the production process for scripting complex, computer graphic-intensive films. Originally, Industrial Light & Magic relied on Unix shell scripting, but it was found that this solution just couldn't do the job. Python was compared to other languages, such as Tcl and Perl, and chosen because it's an easier-to-learn language that the organization can implement incrementally. In addition, Python can be embedded within a larger software system as a scripting language, even if the system is written in a language such as C/C++. It turns out that Python can successfully interact with these other languages in situations in which some languages can't. Philips: Automation is essential in the semiconductor industry, so imagine trying to coordinate the effort of thousands of robots. After a number of solutions, Philips decided to go with Python for the sequencing language (the language that tells what steps each robot should take). The low-level code is written in C++, which is another reason to use Python, because Python works well with C++.
View ArticleCheat Sheet / Updated 09-06-2023
Unlike traditional manufacturing, which involves injecting material into a pre-formed mold or removing material from base material objects, 3D printing starts with a virtual 3D model that is transformed into solid form one layer at a time. Each layer is built on top of the layer before, creating a solid form representing the virtual 3D model in all of its complexity and detail without requiring additional forms of machining and treatment necessary in traditional forms of manufacturing. You can buy an off-the-shelf desktop 3D printer or build your own 3D printer using the open-source self-REPlicating RAPid-prototyper (RepRap) family of designs. Check out these helpful articles to guide you toward selecting the right RepRap design for you.
View Cheat Sheet