Home » Programming

Using the Python ‘map()’ Function to Process a List, With Examples

Using Python Map()

This article will explain the map() function in Python and show you how to use it. The Python map() function applies a given function for all items in an iterable (iterables are things like lists, dictionaries, sets, or tuples – collections containing items that can be looped over). The syntax and code in this article will work for both Python 2 and Python 3. Syntax for Python map() The map() function is built into Python, so nothing needs to be imported. Here’s the syntax: map(FUNCTION, ITERABLE) Note that: FUNCTION is a standard … Read more

Home » Programming

Using the Python ‘reduce()’ Function to Aggregate Data, With Examples

Using Python reduce()

This article will show you how to use the Python reduce() function to aggregate data from values in an iterable (iterables are things like lists, dictionaries, sets, or tuples – collections containing items that can be looped over) and reduce them to a single accumulated value. The code and examples in this tutorial will work in Python 3. Syntax for Python reduce() functools.reduce(FUNCTION, ITERABLE[, INITIALIZER]) Note that: FUNCTION is a standard Python function, previously defined in your code It should accept two parameters The first parameter is the current accumulated value up until this point … Read more

Home » Programming

PHP vs JavaScript – The Best Choice For Your Project

PHP vs JavaScript

PHP and JavaScript are the most commonly used programming languages on the web – so which one should you use for your project? Check out our recent article on JavaScript vs. Node.js for another commonly searched programming comparison. Choosing which programming language to use for a project is important. Some of the questions you’ll want to run through are: Where will the application be run, and which languages are supported in that environment? Do I already have knowledge of one of the languages being considered? … Read more

Home » Programming

PHP Timezones- How to Set/Change Timezone, With Examples

Managing PHP Timezones

This article provides a combined tutorial for the PHP timezone functions, showing how to change the timezone globally or temporarily for a script/object. Timezones are a huge hassle. If your app has users from around the world, you’ll eventually run into the annoying task of ensuring that date handling works effectively for everyone – including the accuracy of times displayed and the format they are displayed in. PHP provides several tools to make timezone handling easier, allowing you to set the default timezone for the system, a … Read more

Categories PHP

Home » Programming

Looping over Array using JavaScript forEach(), With Examples

JavaScript foreach

This article will show you how to use the JavaScript forEach() method to loop over an array. Pretty much any application of any complexity will require the looping over arrays (lists) of data. The JavaScript forEach() method, which is built into JavaScript array variables, does just this. You’ll be using it a lot – so thankfully, it’s pretty darn easy to use. JavaScript forEach() Syntax arr.forEach(callback(currentValue[, index[, array]]) { // execute something }[, thisArg]); Note that: arr is an array or a variable containing an array callback is the … Read more

Home » Programming

TypeScript Vs JavaScript – What’s the Difference & Which Should You Use?

TypeScript Vs JavaScript

This article will discuss the differences between typescript and JavaScript, the problems they solve, and which is best to use. I really like TypeScript, and I use it a lot. It solves so many of JavaScript’s problems and makes writing good JavaScript code much easier (once you’ve learned to use TypeScript). So, this article is more about why you should use TypeScript (when you can use it), when/where you can use it, and the problems it solves. This article goes well with the following articles, giving you an … Read more

Home » Programming

Using Recursion/Recursive Functions in Python, with Examples

Recursive Functions in Python

This article will explain how to use recursion in Python functions, with some example code to illustrate the concept. A recursive function is a function which calls itself one or more times until a condition is met. If a function that uses recursion calls itself too many times, Python will throw an error. As this is a demonstration of a code structure rather than anything with any specific syntax, I’ll show a simple example of a recursive function and leave comments explaining what is going on. Python … Read more

Home » Programming

Raspberry Pi & Python Powered Tank Part III: More Tank

Python Powered Tank Part III More Tank

This was only meant to be a two-parter, but I couldn’t leave well enough alone. Raspberry Pi & Python Powered Tank Part III is an update with better Python code and an improved design. I’ve gone back to fix the biggest issues that were left after Part II. I’ve omitted a bit of the mucking about in this article to keep it focused on what worked. How Did We Get Here? If you haven’t yet checked out the full build process, here are the previous … Read more

Home » Programming

DIY Arduino Powered Soldering Extraction Fan

Arduino Fan

This article will show you to build a DIY soldering extraction fan (to ventilate fumes) using an Arduino and a temperature sensor to activate the fan when the soldering iron is hot. Before you read this, why not open up my other projects in some new tabs for further reading when you’re done? Smart Mirror Wikipedia Scraper Photo Resizer and watermarker Raspberry Pi Powered Palmtop/Laptop Raspberry-Pi augmented Apple Macintosh Python Powered Tank! The Project A thoughtful commenter on a previous article suggested I get an … Read more

Home » Programming

Converting Bytes To String In Python [Guide]

Converting Bytes To String

This tutorial covers converting Bytes to a string variable (and a string to Bytes) in Python versions 2 and 3. What is the difference between a string and a byte string? A string is a series of characters. When stored on disk, the characters are converted to a series of bytes. What series of bytes represents what character is defined by the character encoding. When a string is stored to disk, it is converted to bytes (encoding). When it is read back into a program, the bytes must be converted back to a … Read more