Home Interests Raspberry Pi

How to Set the Timezone on Your Raspberry Pi

howchoo
howchoo   (467)
August 18, 2023
2 minutes

Share

You’ll Need 1

What you’ll need
Interests
Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.
Posted in these interests:
pi • 92 guides

At some point in your Raspberry Pi hacking career, you’ll need to know what time it is…in your own timezone. This guide will show you how to set the timezone in your Pi.

1 – Open the Raspberry Pi Software Configuration Tool

Connect to your Pi to get to the command line. Then, open the Raspberry Pi configuration tool, better known as raspi-config, with the following command:

How to Connect to a Raspberry Pi Remotely via SSH
The preferred (and most common) method of connecting to your Pi to run commands.

sudo raspi-config

2 – Open “Localisation Options”

With Localisation Options open you’ll be able to choose Change Timezone and select your local timezone.

3 – Confirm the changes were successful

From the command line, you can simply type date and confirm the date is displayed in your desired timezone.

pi@raspberrypi:~ $ date
Wed 28 Nov 11:10:33 PST 2018
NEXT UP

How to Run a Minecraft Server on the Raspberry Pi

A whole world trapped inside your Pi.
howchoo   (467)
December 7, 2023

There are several ways to go about running a Minecraft server on the Raspberry Pi. In this guide, I’ll cover how to install Nukkit—a cross-platform Minecraft server that’s super easy to set up on the Raspberry Pi. This server should work with PCs, consoles, and tablets running Minecraft 1.14. I’ll be using a Raspberry Pi

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo’s writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Home Interests CenturyLink

How to Log in to a CenturyLink Router

howchoo
howchoo   (467)
August 18, 2023
4 minutes

Share

You’ll Need 2

What you’ll need
Interests
Series
Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.
Posted in these interests:
centurylink • 2 guides
internet • 36 guides
router • 32 guides

Need to log into your CenturyLink router? We’ve got you covered. This guide will walk you through accessing your CenturyLink router login. Once inside, you’ll have access to a myriad of network tools to secure your network and more. I’ll also touch on how to change your CenturyLink administrator password to keep your router safe.

1 – Connect to a network

Connect to your Century Link network. You can use WiFi or an Ethernet cable to connect.

Open a browser window and visit the CenturyLink router login address:

http://192.168.0.1

3 – Enter your username and password

You should see a CenturyLink login screen. The admin username and password are located on a sticker found on the modem.

You can visit our guide for more information about how to log into a router.

To change the password choose Advanced Setup. On the left hand menu, click Administrator Password. Enter the new password, confirm it, and save to finish.

5 – Speed up your WiFi connection

Now that your router is secure, it’s time to get your network into tip-top shape! Why not check out our guide on how to optimize WiFi for speed?

Make Wi-Fi Faster: How to Speed Up Your Wi-Fi Connection
Speed up your Internet connection in just a few minutes.

NEXT UP

How to Change Your Frontier WiFi Password

howchoo
howchoo   (467)
November 25, 2023

There are a few reasons you might want to update or reset your WiFi password: making your network more secure, and making your password easier to remember and type. Improved network security You can add an extra layer of security to your network by changing the WiFi password. As long as your new password is

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo’s writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Home Interests Subaru Crosstrek

How to Disable the Lock/Unlock Sound on Your Subaru XV Crosstrek and Impreza

howchoo   (467)
August 18, 2023
5 minutes

Share

Interests
Posted in these interests:
autos • 4 guides
subaru • 3 guides
crosstrek • 3 guides

The audible chirp when my XV Crosstrek is locked or unlocked is quite annoying — worse is when someone hasn’t closed the door completely yet and it beeps 5 times. Here’s a simple (and completely reversible) way to disable your Crosstrek’s lock/unlock sound. This guide also works for other Subarus (including the Outback) of the model year 2013+.

Note: You can still make your car “chirp” (though it uses the horn) by pressing the button on your remote three times. This is handy if you want to locate your car in a parking lot, for example.

1 – Sit in the driver’s seat

Keep the key out of the ignition and make sure all doors are closed.

2 – Hold the unlock button

On the driver’s side door, hold down the unlock button.

3 – Insert and remove the key from the ignition at least 6 times

Do this while continuing to hold the unlock button.

🛈 This must be done inside of a 10 second window from when you began holding the unlock key.

4 – Open and close the driver’s door

Do this while continuing to hold the unlock button.

🛈 This must be done inside of a 10 second window from when you inserted and removed the key 6+ times.

5 – Get confirmation

After you close your door, your hazard lights on the dashboard will flash three times if this process was completely successfully. If you did not see this confirmation, repeat this process again.

🛈 There have been reports from numerous Subaru XV forums that it can take multiple times to get this to work.

6 – Reenabling the audible lock/unlock chirp

To turn the lock/unlock beep back on, simply repeat this process again to reverse the setting.

You’re all done! Next, learn how to replace your XV Crosstrek’s in-cabin air filter!

How to Replace the Subaru XV Crosstrek Cabin Air Filter (2013+)
Change your Crosstrek’s cabin air filter in 5 minutes for less than $15.

🛈 More information on this process can be found in your owner’s manual.
NEXT UP

Build Your Own Raspberry Pi Car Computer, or “Carputer”, with AutoPi

Bring your car into the future!
howchoo   (467)
September 29, 2023

Have you ever wanted to add an entertainment system to your car, only to find that most units are expensive, come with a lackluster feature set, and feature a terrible interface? Well, now you can build your own Raspberry Pi-powered car computer with AutoPi! Monitor your car’s vitals, watch movies, play retro games wiith RetroPie, use open

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo’s writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Home Interests Python

How to Run Python in Terminal

run python in terminal
You can run any Python script in a command-line interface.
howchoo   (467)
August 18, 2023
6 minutes

Share

Interests
Posted in these interests:
python • 18 guides

Python and associated Python scripts can be run using command-line interfaces. Windows users can use command prompt while Mac and Linux users can make use of Terminal. We’ll cover how to run a Python script, open a Python shell, and how to run a Python one-liner.

1 – Run a Python script in Windows

run a python script in windows

Open Command Prompt. An easy way to reach Command Prompt is by opening the Start Menu and searching for cmd. Select Command Prompt from the list of applications.

How to run a Python script

By default, you will need to point Command Prompt to the Python installation location. Here’s an example of what a command would look like when executing a Python script.

C:Python27python.exe C:UsersYourUsernameHereDesktopscript.py

If you don’t want to type the full Python installation path, you can add an exception to your PATH environment variable for python.exe.

Using the Python shell

From the Command Prompt window, type python or python3 and press enter.

Python one-liners

This will as long as Python has been added to your PATH environment variable. Here’s an example of a one-liner you can run from command prompt.

python -c "print('hello world')"

2 – Run a Python Script on a Mac or Linux

Mac users can run Python scripts using Terminal. Launch Terminal to begin.

There are two common ways to run a Python script from the command line. You can call the python program directly, and pass the name of the script to execute. Or you can make the script executable, and call it directly.

Run a script using python

Running a script using the python program is easy, and it’s probably the method most people are familiar with. Simply call python and pass the name of your script, like this:

python myscript.py

# or 

python3 myscript.py

Making a Python script executable

If your Python script includes a “shebang” (#!/usr/bin/env python or #!/usr/bin/env python3). You can make your script executable, like this:

chmod +x myscript.py

and execute it like this:

./myscript.py

Using the Python shell

You can open a Python shell simply by typing python or python3 into a Terminal window. Then you can run Python commands directly in the shell.

Python one-liners

You can also execute Python directly on the cli using the -c option. Example:

python -c "print('hello world')"
NEXT UP

Class Vs. Instance Variables in Python 3

howchoo
howchoo   (467)
November 22, 2023

When learning object oriented programming in Python, there can be a few gotchas when it comes to distinguishing between class and instance variables. In this guide I’ll explain the difference between class and instance variables and provide examples demonstrating various use cases. 1 – Class vs. instance variables First, a quick review if you’re new

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo’s writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Home Interests iPhone

What the Symbols on Your Apple iPhone Mean

what the symbols o your iphone mean
what the symbols o your iphone mean
howchoo   (467)
August 18, 2023
21 minutes

Share

Interests
Posted in these interests:
iphone • 9 guides

iPhone symbols demystified!

Over the years, as iOS versions improve and advance, the symbols and status indicators on our iPhones have changed too. Oftentimes, this creates confusion, curiosity, and even stress surrounding particular symbols, especially those that indicate the use of microphones and other privacy concerns.

This is totally understandable, and it’s another reason why knowledge is power. First off, I was to make sure you know that these symbols and status indicators are here for your benefit and to assist you and only you. They are there to let you know what is being used or accessed on your iPhone, as well as to alert you that certain apps may be accessing certain information.

Secondly, also know that when you are downloading third-party applications you are often giving that app access to your microphone, data, or camera. Luckily, this is nothing to fear, because Apple has recently included a feature that allows to disable or enable access to certain privacy concerning parts of your data or iPhone. Also, you can always alter what apps you have and don’t have access to.

To take it one further, also consider that some of these accesses are completely normal. For example, a third-party messaging and calling application might need access to your mic to allow you to make calls, or a photo editing app might need access to your photos to edit them. Regardless, it’s important to know what the symbols mean on your iPhone, especially the more ambiguous ones so that you can make the necessary changes.

In this guide, I will cover some of the most asked about iPhone symbols meanings and indications, I will provide steps on how to see a third-party app’s access and alter that access, and I will also provide a full list of all iPhone symbols and what they represent.

Green Dot

green dot
green dot

The green dot is a newer iPhone symbol that sparked some concern by iPhone users, but don’t worry. This green dot will appear at the top of your iPhone screen when your iPhone’s camera and/or microphone are being accessed.

Examples of when the green dot will appear:
1. When using FaceTime or other third-party video chatting apps
2. When taking pictures
3. When scanning documents using the camera
4. When using Snapchat
5. When recording video
6. When scanning QR codes

These are only a few examples of what might prompt the green dot.

To disable an app’s camera access:
1. Open Settings.
2. Click “privacy.”
3. Click “camera.”
4. Disable and enable any app you prefer from the list below.

Consider that these apps might need access to the camera to be fully functional.

Orange Dot

orange dot
orange dot

The orange dot will appear at the top of your screen when the microphone is being used. This is pretty standard behavior for many apps, and is usually harmless. If you do not want an app to have access, and want to disable it, follow the steps below. First, check out some of the apps that prompt this indicator.

Examples of when the orange dot will appear:
1. When using the Voice Memo app
2. When voice chatting via Snapchat, Messenger, and other third-party apps
3. When calling your voicemail
4. When on the phone

To disable an app’s microphone access:
1. Open Settings.
2. Click “privacy.”
3. Click “microphone.”
4. Disable and enable any app you prefer from the list below.

Consider that these apps might need access to the microphone to be fully functional.

Status Bar (blue, green, or red)

status bar blue green or red
status bar blue green or red

Status bars are another ambiguous symbol on iPhones that most iPhone users feel uncertain of, and understandably so. They aren’t self-explanatory and haven’t always been an iOS feature. Don’t worry, these symbols are there to let you know what your iPhone is currently up to.

Each of the three status bars you will see on your iPhone have different but similar meanings that indicate certain parts of your iPhone are being used or accessed at that moment.

Status bar meanings

1. Blue status bar- The blue status bar is the more complex of the three status bars because it can indicate multiple uses. The blue status bar is most commonly associated with screen sharing because that’s when it’s generally noticed is on-screen sharing sessions with tech support. However, it can also appear when you are screen mirroring (sharing your screen to another device), or if an app is currently using your location. You will notice this appears when using the Maps app to navigate somewhere.
2. Green status bar- This one is simple. If you are on a call, the green status bar will appear.
3. Red status bar- The red status bar indicates that your screen and/or your microphone are being recorded. This is especially apparent when recording your own screen or using the Voice Memo app.

To find out which app is doing this, simply click the status bar, and it will either open the app or prompt you with a pop-up asking you if you want to close the app and which app it is.

It’s important to note that these bars are there to tell you what your iPhone is currently doing, not to scare you. Many third-party apps do have access to different apps, data, and features on your iPhone because permission is given when you download the app. However, you can also go to an app’s settings to alter some of them.

To change an app’s settings:
1. Open Settings.
2. Scroll down until you find the app.
3. Disable any of the following: location services, face ID, tracking, Camera, Photos, or microphone.

Rember, some apps might need the above access to be fully functional, so depending on the app’s function, you may not want to disable all access.

Do Not Disturb

do not disturb
do not disturb

Do Not Disturb is one of my favorite iOS features since it allows me to unplug when needed, but the symbol can be confusing for those who don’t know much about DND.

This symbol can pop up next to a particular message thread in Messages if you have turned it on for that person. It can also appear at the top of your screen if DND is on at that moment. This is important to know, especially if you noticed you haven’t been hearing your calls or notification and aren’t sure why.

Location Services

location services
location services

Location services is a big one, but don’t worry. This little symbol will tell you when your location is being accessed, so that you can disable that access if you would like, though it is completely normal for some apps to access your location services.

Apps that use location services:
1. Uber
2. Lyft
3. Pokémon Go
4. Uber Eats
5. DoorDash
6. Google Maps
7. Maps
8. Weather (and other weather apps)
9. Road Trippers
10. Compass
11. Google (when searching for restaurants, etc. near you)

How to disable location services:
1. Open Settings.
2. Click “privacy.”
3. Click “location services.”
4. Disable and enable any app you prefer from the list below.

Some of these apps may need access to location services to provide accurate information.

Orientation Lock

orientation lock
orientation lock

If you bring up, or down depending on your iPhone model, you will see the orientation lock symbol there. If it is on, that is when the symbol will appear at the top of the screen. This can be turned on and off in the command center.

Its purpose is to stop your screen from orienting every time you move. For example, if you are reading in bed, you may notice the screen flips if you put it at too much of an angle, and this feature will prevent that so that you can turn the phone without the screen flipping each time you do.

Syncing to iTunes

syncing to itunes
syncing to itunes

This is a good one to be aware of, especially if you plug your iPhone into a computer that isn’t yours and you are syncing to a computer at home. This symbol shows up when your iPhone is syncing to a computer via iTunes.

A Full List

Here is a full, simple list of the symbols on your iPhone as referenced from support.apple.com. These may change over time and with different iOS versions. So, make sure you are up to date before viewing this list.

If your iPhone has plateaued and cannot update to the most recent version, you may just notice some of these symbols don’t apply to your iPhone.

SymbolMeaning
Blue Status AppleBlue status bar can indicate a few things, specifically location services, hotspot, or screen mirroring
Green Status AppleGreen status bar indicates an ongoing call
Red Status AppleRed status bar indicates screen or mic recording
Orange Dot AppleYour microphone is being used by one or more applications on your iPhone.
Green Dot AppleYour camera is being used by one or more applications on your iPhone.
AirDrop AppleAirDrop
Hotspot AppleHotspot
Cellular Data AppleCellular data
Bluetooth AppleBluetooth
Airplane Mode AppleAirplane mode
5G Apple5G available
5G High Frequency AppleHigh frequency 5G
5G E Apple5G E available
LTE AppleLTE
3G Apple3G available
4G Apple4G available
GPRS AppleGPRS available
Edge AppleEdge available
Cellular Service AppleCellular service
Dual Sim Service AppleDual sim cellular service
Wi-Fi Calling AppleWi-Fi calling available
Wi-Fi Connection AppleWi-Fi connection
VPN AppleVPN connected
VPN Not Connected AppleVPN not connected
Location Services AppleLocation services is being used
Network activity AppleNetwork activity or loading
Call Forwarding AppleCall forwarding is on
TTY AppleTTY (teletypewriter) is on
Airplane Mode On AppleAirplane mode is on
DND AppleDND is on
Syncing AppleiPhone is currently sycning to iTunes
Orientation Lock AppleOrientation lock is enabled
Headset AppleHeadset or earbuds connected (wireless)
iPhone is Locked AppleiPhone is Locked via touch ID, face ID, or passcode
Alarm AppleYou currently have an alarm set
Hotspot Connected AppleYour iPhone is currently connected to a hotspot
Battery Level AppleCurrent battery charge level
Bluetooth Battery AppleBluetooth battery charge level
CarPlay AppleCarPlay is currently connected to your iPhone
NEXT UP

How to Block a Website with Screen Time on Your iPhone

Block inappropriate or spammy websites with screen time!
howchoo   (467)
November 30, 2023

Screen time gives iPhone users the opportunity to track and manage their iPhone usage, making staying productive easier than ever before. Since screen time holds iPhone users accountable for their iPhone use, it’s become increasingly popular among those who want and need to unplug during various time frames. However, that’s not all screen time is capable

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo’s writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Home Interests Fitbit

How to Reset a Fitbit Charge 3 & Charge 4

It’s like running though a maze to find the reset button on your Fitbit!
howchoo   (467)
August 17, 2023
5 minutes

Share

You’ll Need 1

What you’ll need
Interests
Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.
Posted in these interests:
fitbit • 1 guides
fitness • 5 guides

Because of the Fitbit Charge 3 and Charge 4’s compact nature, Fitbit has crammed as much as they could into the small amount screen space available on the Charge, making it tricky to do simple tasks like changing the time. This includes the reset feature. I’ve had a Fitbit Charge 3 and now a Fitbit Charge 4, and I still make discoveries from time to time about a new app or feature I never knew existed.

So let us help guide you through the metaphorical maze that is the Fitbit Charge 3 and Charge 4, and get you to that reset button pronto!

1 – Press the left button to show screen

Press the left button to show the screen on your Fitbit Charge 3 or 4.

2 – Swipe to the left until “Settings”

  • Swipe left on your Fitbit Charge 3 or 4 screen, until you reach the “Settings” button.
  • Press Settings.

3 – Swipe up until “About”

  • Swipe up to scroll down and find the button labeled “About.”
  • Press About.

4 – Swipe up until “Clear User Data” and “Reboot Device”

Now, you’ll swipe up until you see the two buttons labeled “Clear User Data” and “Reboot Device.” Each of these buttons can reset your Fitbit Charge 3 or 4 in a different way.

Clear User Data

Selecting this will essentially factory reset your device. It will remove

  • Apps
  • Stored data
  • Personal information
  • Credit and debit cards (for Fitbit Pay-enabled devices)
  • Saved settings

On some other Fitbit devices, this is called “Factory Reset.” You’ll want to do this if you get a new Fitbit and sync it to your phone, for example.

Reboot Device

Selecting this will reboot the device itself. It will not reset or remove any user data. Rebooting the device troubleshoots many issues that Fitbit wearers might experience, such as when:

  • The device stops responding.
  • The device will not sync.
  • It stops tracking your stats and steps.
  • The buttons stop responding.

Your Fitbit Charge may need to plug in for the device to restart after being shut down.

NEXT UP

How to Clean Vibram Five Finger Toe Shoes Without Ruining Them

howchoo   (467)
November 22, 2023

Vibram Five Finger shoes are awesome pieces of running gear. But you can also use them for hiking and looking weird around town. Unfortunately, toe shoes start to smell if you don’t wear socks with them every time you wear them. While Vibram claims that the shoes are machine washable, you will ruin them if you wash

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo’s writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Home Interests Code

Learn the slow (and fast) way to append elements to the DOM

howchoo
howchoo   (467)
August 17, 2023
13 minutes

Share

Interests
Posted in these interests:
code • 11 guides
javascript • 4 guides
jquery • 1 guides

jQuery is a powerful tool for front-end developers, but it does not alleviate the responsibility of ensuring your code is efficient. One common pitfall for developers is the method used to append elements to the DOM. This guide will examine the handful of different ways of doing this and point you to the most efficient way.

This subject matters most at a large scale. So for this guide, we will assume that our task is to append 10,000 divs to the body of a webpage.

1 – A naive approach

Early on I would’ve done this:

for (var i=0; i<10000; i++) {
  $("BODY").append($("
").addClass("test-div")); }

This code produced an average running time of 779.463ms. This means it took over three quarters of a second to append these elements to the DOM.

So what is the problem here?

Well, there are a few – too many reflows and too many jQuery objects. We’ll address the latter in the next step, so let’s look at reflow here.

Simply put, reflow is when the browser needs to process and draw the webpage, and it is one of the most expensive browser processes. One of the easiest ways to improve the performance of your application is to minimize the number of reflows, and that’s what we’re going to do.

Many different operations can cause a reflow, and it isn’t the same for every browser. But rest assured, appending an element to the DOM will cause a reflow. So the obvious problem with our code snippet is that we are generating 10,000 reflows. Some browsers may handle this intelligently and reduce some of the cost, but we can do better.

2 – Fix the reflow problem

Let’s fix our reflow problem by creating a node that has not yet been added to the DOM. Then we will append our divs to this node. And finally, we will append this single node to the DOM which should trigger a single reflow.

var $c = $("
").addClass("container"); for (var i=0; i<10000; i++) { $c.append($("
").addClass("test-div")); } $("BODY").append($c);

This is a little bit better but still not great. Our running time is now 432.524ms. This is still pretty bad, and there is a lot we can do to improve.

The problem here is that we’re still creating too many jQuery objects. Even though we’ve solved the reflow problem, there is a lot of overhead to create a jQuery object. Of course, for a single object the convenience of jQuery far outweighs the minimal performance hit. But if we’re dealing with 10,000 elements the inefficiency is more than noticeable.

Let’s see what happens when we skip using jQuery altogether and write this in plain JavaScript.

var c = document.createDocumentFragment();
for (var i=0; i<10000; i++) {
    var e = document.createElement("div");
    e.className = "test-div";
    c.appendChild(e);
}
document.body.appendChild(c);

Incredibly, this change reduced our total running time from 432.524ms to 16.237ms. And this makes sense because it actually takes jQuery some time to create the object. Let’s see just how long it takes to create a single jQuery object vs. creating the element using vanilla JavaScript.

console.time("jquery div");
var jqDiv = $("
"); console.timeEnd("jquery div"); // jquery div: 0.272ms console.time("js div"); var jsDiv = document.createElement("div"); console.timeEnd("js div"); // js div: 0.006ms

This is a significant difference – 0.006ms vs. 0.272ms. The point of this comparison isn’t to say that jQuery is bad but rather that as a developer you should know when to use it and when not to. jQuery provides a lot of functionality that isn’t necessary for our purpose so it doesn’t make sense to create 10,000 jQuery objects at such a high cost.

3 – Using strings instead of nodes

We don’t actually have to create 10,000 nodes. Instead we can see what happens when we use one long string of HTML.

var s = "";
for (var i=0; i<10000; i++) {
    s += "
"; } $("BODY").append(s);

At 69.874ms this performs much better than our original, but not quite as well as the pure JavaScript version. However, there is one small improvement we can make. String concatenation is expensive, especially at this scale. Let’s use an array of strings and join them in the end.

var a = [];
for (var i=0; i<10000; i++) {
    a.push("
"); } $("BODY").append(a.join(""));

This runs in 63.885ms. This probably isn’t enough of an improvement to stress out about, but since it’s faster we’ll keep it.

Let’s measure the cost of using jQuery to append the string. As we learned in the previous step, using pure JavaScript may be faster.

var a = [];
for (var i=0; i<10000; i++) {
    a.push("
"); } document.body.innerHTML = a.join("");

The main difference here is that we’re not using jQuery.append. Instead we’re setting the innerHTML attribute on the body to our string of HTML. This runs in 22.908ms so the improvement is obvious. But we’re still not as fast as the pure JavaScript version from the last step.

4 – Conclusion

In summary, the fastest code was the pure JavaScript version:

var c = document.createDocumentFragment();
for (var i=0; i<10000; i++) {
    var e = document.createElement("div");
    e.className = "test-div";
    c.appendChild(e);
}
document.body.appendChild(c);

Based on these experiments there are two major takeaways.

First, be aware of which operations will cause a reflow. This is an expensive process, and it should be reduced as much as possible.

Second, be aware of the cost of using jQuery. For operations at a low scale, the convenience of jQuery will often outweigh the performance cost. But at a large scale, jQuery should be avoided unless it is actually needed.

NEXT UP

Secure Your Sensitive Data with Kubernetes Secrets

Learn how to create and use Kubernetes secrets.
howchoo   (467)
November 26, 2023

Kubernetes secrets are objects that store and manage sensitive data inside your Kubernetes cluster. One mistake developers often make is storing sensitive information like database passwords, API credentials, etc in a settings file in their codebase. This is very bad practice (hopefully for obvious reasons). Most developers know this, but still choose the option because it’s easy.

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo's writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Home Interests WWW

How to commit and push in Git

howchoo   (467)
August 17, 2023
3 minutes

Share

Interests
Posted in these interests:
computers • 2 guides

Git

git • 5 guides
github • 1 guides
webdev • 10 guides

WWW

www • 2 guides

This guide will show you how to properly commit and push your work in Git. It is assumed that you have Git installed and that you’re currently in a clean master branch.

1 – Create a task branch

With a clean master branch checked out, you can create a task branch by typing:

git checkout -b task_branch

where the task_branch is the name of the branch you want to create. By using the -b option it will both create a new branch and check it out.

2 – Do your work and commit

As your are doing work you can commit regularly, and you must also commit when you are finished with your task. You can commit by typing:

git commit -am "commit message"

and you should leave a detailed commit message describing the changes you made.

3 – Merge your work into master

Now that you’ve finished your task you need to checkout master and merge your work. To checkout master simply type:

git checkout master

and to merge your task branch type:

git merge task_branch

where task_branch is the name of your branch.

4 – Push the master branch

Now that your work is merged, go ahead and push the master branch by typing:

git push origin master
NEXT UP

How to Set up Git Tab Completion

howchoo
howchoo   (467)
November 26, 2023

Tab completion, or auto-completion, is essential if you’re using Git on the command line. Tab completion is a nice feature of many shells that allows you to complete a word by hitting tab. In this case, we want to be able to use tab completion for things like branches and tags in git. Fortunately, setting

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo’s writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Home Interests Vim

How to Change Your Leader Key in Vim

howchoo
howchoo   (467)
August 17, 2023
4 minutes

Share

Interests
Posted in these interests:

Vim

vim • 5 guides

One of the strengths of Vim is that it’s highly customizable. And while remapping keys is possible, we often want to create shortcuts without changing the default key bindings. The leader key allows us to do this elegantly.

The leader key, which is basically a command prefix, allows us to create shortcuts to some of our most commonly used commands. Sadly, though, the default leader key is . So if you’re concerned with efficiency,  might cost you a few seconds a day, in contrast with something a little closer to home row.

1 – Use the mapleader variable in your .vimrc file

First, open your .vimrc file. This is typically found in your home directory:

vim ~/.vimrc

Now use the following to set the leader key.

let mapleader = ","

In the above example, I mapped the leader to ,. This is much easier to access than , but you can map the leader to whatever key you’d like!

For this change to take effect, you’ll have to re-launch Vim.

2 – An example shortcut using the leader key

Even though it isn’t the main purpose of this guide, I figured it would be useful to provide an example shortcut using the leader key.

One of the commands I use frequently is :buffdo e!. Sometimes the files in my current project have been changed by another program (like changing branches in git). This command force reloads the files in each of my buffers.

As you can imagine, typing this is a pain. Typing ,e is much easier. Add the following to your .vimrc file to create shortcuts like this one:

map e :bufdo e!

So whenever ,e is typed, it will be as if I typed :buffdo e! ( means return).

NEXT UP

How to Change or Switch the Case of Characters in Vim

howchoo
howchoo   (467)
September 18, 2023

Need to change the case of characters to all caps or all lowercase? This is easily done using Vim. This guide will show you how to change the case of characters in Vim. tl;dr Toggle “Hello” to “hELLO” with g~. Uppercase “Hello” to “HELLO” with gU. Lowercase “Hello” to “hello” with gu. 1 – Select the text you’re

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo’s writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Home Interests Raspberry Pi

How to Look Up Raspberry Pi Display Resolution

howchoo
howchoo   (467)
August 17, 2023
3 minutes

Share

You’ll Need 1

What you’ll need
Interests
Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.
Posted in these interests:
pi • 92 guides

This short guide will show you how to find your Raspberry Pi’s screen or display resolution.

1 – Connect to the Pi

Open Terminal or Command Prompt and connect to your Pi via SSH to get to the command line.

How to Connect to a Raspberry Pi Remotely via SSH
The preferred (and most common) method of connecting to your Pi to run commands.

If you don’t want to log into the Pi remotely, you can alternatively connect a USB keyboard and plug your Pi into a monitor or TV.

If you’re running a system such as RetroPie, you’ll need to press F4 to exit to the command line.

2 – Run the following command

Once on the command line, run the fbset command:

fbset

You will now see your Pi’s display resolution represented in terms of pixels and the overall geometry. For example, the RetroFlag GPi resolution is 320×240 (WxH):

mode "320x240"
    geometry 320 240 320 240 32
    timings 0 0 0 0 0 0 0
    rgba 8/16,8/8,8/0,8/24
endmode
NEXT UP

How to Run a Minecraft Server on the Raspberry Pi

A whole world trapped inside your Pi.
howchoo   (467)
December 7, 2023

There are several ways to go about running a Minecraft server on the Raspberry Pi. In this guide, I’ll cover how to install Nukkit—a cross-platform Minecraft server that’s super easy to set up on the Raspberry Pi. This server should work with PCs, consoles, and tablets running Minecraft 1.14. I’ll be using a Raspberry Pi

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo’s writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.