teleren/devto huggingface dataset:
KAPE 8bit Homebrew Console/Computer
Published: 2020-10-25 04:30:16

I started on designing my own homebrew 8bit computer this summer. I've been at for a couple of months already now, and expect it to take it a lot more months if not years to finish it. 

People have been suggesting I write stuff and show pictures of it on the internet, so I started a blog to document my progress. There's not that much stuff there yet, and I hope I don't forget to update it every now and then. Currently the GPU part is starting to look like something and soon I'll start designing the CPU portion - or the actual computer part of it.

https://kape-8bit.blogspot.com/
Avoiding the awkward 2 seconds after a Zoom call looking for that end button
Tags: zoom, remote, automation, video
Published: 2020-10-25 04:21:14

You’ve just wrapped up your meeting, you’re saying bye to your colleagues but then there’s a second or two of awkwardness as you are fumbling to hang up the Zoom call.

Using [Keyboard Maestro on macOS](https://www.keyboardmaestro.com/) you can set up a macro to quickly hang up your Zoom call using a single keyboard shortcut.

{% youtube kBiq47EYpq0 %}

If you've found this tip to be helpful, [tweet at me](https://twitter.com/michaelsoolee) and let me know if I can help you with any other ways to speed up your workflow.
Solving LeetCode - Two Sum
Published: 2020-10-25 04:00:43

# Question

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Example 1:
```
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Output: Because nums[0] + nums[1] == 9, we return [0, 1].
```
Example 2:
```
Input: nums = [3,2,4], target = 6
Output: [1,2]
```
Example 3:
```
Input: nums = [3,3], target = 6
Output: [0,1]
```

Constraints:

* 2 <= nums.length <= 105
* -109 <= nums[i] <= 109
* -109 <= target <= 109
* Only one valid answer exists.

## Let's Go!

Solve by using [PREP](https://dev.to/phariale/prep-technique-for-algorithms-in-js-5b0g).
* **P** - Two parameters. First is an array of integers _(nums)_. Second is an integer _(target)_.
* **R** - An array of two integers which are the indices of the numbers that add to the target.
* **E** - Examples provided by question. (See Above)
* **P** - See Below

```javascript
var twoSum = function(nums, target) {
  // Iterate over nums array with for loop where i is the indice of the first integer
    // Perform a second iteration starting from j where j is the is the indice of the next integer (j=i+1)
      // If nums[i] + nums[j] equals target integer
        // return [i, j] 
}

```

Translate into code...

```javascript
var twoSum = function(nums, target) {
  // Iterate over nums array with for loop where i is the indice of the first element
    for (let i=0; i<nums.length; i++) {
    // Perform a second iteration where j is the is the indice of the second element
        for (let j=i+1; j<nums.length; j++) {
      // If nums[i] + nums[j] equals target integer
        // return [i, j] 
            if (nums[i] +nums[j] === target)
                return [i, j]
        }
    }
}

```

### Conclusion

& Remember... Happy coding, friends! =)

#### Sources
* https://leetcode.com/problems/two-sum/
How to easily switch between PHP versions on macOS?
Tags: phpversion, switchphpversion, brewphp, macosphp
Published: 2021-07-24 07:21:00

---
title: How to easily switch between PHP versions on macOS?
published: true
date: 2021-07-27 04:00:00 UTC
tags: phpversion, switchphpversion, brewphp, macosphp
canonical_url: https://postsrc.com/posts/how-to-easily-switch-between-php-versions-on-macos
---
![How to easily switch between PHP versions on macOS? Cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zu8danbiysmrs9i9mso8.jpg)

In this post, we'll learn how to switch between PHP versions in the macOS system. Firstly I assume that PHP is installed using [Homebrew](https://brew.sh/) and if you have not done so, do follow this tutorial on [How to install PHP 8 on macOS Big Sur using Homebrew](https://postsrc.com/posts/how-to-install-php-8-on-macos-big-sur-using-homebrew).  
  
##Using Homebrew
By right when using Homebrew, we can install multiple different versions of PHP at the same time but only use it one version at a time. To see which PHP version you have installed do run the command below and if you see it's ticked ✔︎ then it means it's installed.

```
brew search php
```

  
If none of the PHP is ticked then by default the PHP that's on the system is the default one shipped with macOS. Installing different versions is very important as many projects use a different version of PHP. In this case, let's assume that we have version 7.4 and 8.0.  
  
By default PHP version on Homebrew is "php@7.3", "php@7.4" and "php" which means that the PHP that has no version number is the latest / highest version, in this current time of writing is version 8.0.  
  
##Changing PHP Version
To switch to the PHP version you can simply do run the command below. Switching from PHP version 7.4 to 7.3.

```
brew unlink php@7.4
brew install php@7.3
brew link php@7.3
php -v
```

  
Otherwise, if it's from PHP version 7.4 to 8.0 all you have to do is specify the version number.

```
brew unlink php@7.4
brew link php
php -v
```

  
##Warning when switching
Sometimes there will be a warning while switching mentioning that linking should use "force" and if that's the case do use the flag option.

```
brew link php --force
```

  
That's all, by now you should be able to change to any PHP version that your project requires. One piece of advice is that it's better to have a project to always stay up to date so having maintained aka latest PHP version is always a good practice.

This post is originally published at [PostSrc](https://postsrc.com/). If you like this kind of tutorial, I would really appreciate it if you give it a visit.
Learning Memoization in Javascript Part 2
Tags: computerscience, javascript, beginners, codenewbie
Published: 2020-10-25 03:53:29

After doing some research on how to implement memoization in a function with multiple arguments I realized this is a pretty unusual situation that will rarely occur... 

In my [last post](https://dev.to/123jackcole/learning-memoization-1gp7) I went over implementing memoization in javascript using the fibonacci sequence as an example. However, in that example our function only utilized a single argument. But how do we memoize when a function needs to track multiple arguments?

## **Implementation**

In my example I'm going to use a nested map object. The map will have multiple dimensions and store the fibonacci data in the dimension that matches the specific method call. Remember, this is just an example displaying how we would go about doing this.

Also going on a short tangent, notice how I use map objects instead of a regular hash. Javascript has a map object, learn to use it! You can read more about that [here](https://dev.to/katkelly/advantages-of-a-javascript-map-cen).

![Memoization Multiple Functions](https://dev-to-uploads.s3.amazonaws.com/i/bq6nx9j97m9qxjh2hyze.png)

Thanks for reading! I know that this is a pretty niche situation but memoization is a good skill to know and could come in handy in the future! The code for this post and my last post can be found [here](https://github.com/123JackCole/Memoization).
Day 38 of #100DaysOfCode: Turn the Next.js Website to PWA with Workbox
Tags: react, nextjs, pwa, 100daysofcode
Published: 2020-10-25 03:52:53



## Introduction
We have introduced Next.js development [in a few topics](https://medium.com/a-layman/build-single-page-application-with-react-and-django-part-8-implement-a-static-rendering-website-3b85aa8cfc0f) before. Feel free to visit the following topics if you need.

This article introduces the following topics.
1. Add Web App Manifest in the Next.js application
2. Enable Caching/Offline Supports
3. Introduce the criteria for the APP installer banner

## Details
Please refer to my article. 
https://medium.com/a-layman/turn-the-next-js-website-to-pwa-with-workbox-part-1-web-app-manifest-and-caching-offline-support-e6d94330b8f2

## Articles
There are some of my articles. Feel free to check if you like! 
* My blog-posts for software developing: https://medium.com/a-layman
* My web resume: https://jenhsuan.github.io/ALayman/cover.html
* Facebook page: https://www.facebook.com/imalayman
how to remap broken keys with Xmodmap
Tags: xmodmap, linux, remapkeys
Published: 2020-10-25 03:51:40

---
title: how to remap broken keys with Xmodmap
published: true
description: how to remap broken keys with Xmodmap
tags: Xmodmap,linux,remapkeys
cover_image: https://images.unsplash.com/photo-1543966888-6e858b90d30d?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=2560&h=1440&fit=crop&ixid=eyJhcHBfaWQiOjF9
---

We can use `Xmodmap` instead of installing yet-another-tool for remapping keys, ie your `r` or `v` died and you want to use a spare `CapsLock + <key>` to trigger that dead key.

#### Create a file `~/.Xmodmap`

```bash
touch ~/.Xmodmap && vim &_
```

Here's my example how to remap keys:

```plaintext
! keycode 66 is caps lock
keycode 66 = Mode_switch
keysym h = h H Left
keysym l = l L Right
keysym k = k K Up
keysym j = j J Down
keysym q = q Q z
keysym w = w W x
keysym e = e E c
keysym r = r R v
keysym i = i I Insert
keysym g = g G Home
keysym b = b B End

! ^: asciicircum, |: bar
keysym f = f F asciicircum bar

! u: Page Up, d: Page Down
keysym u = u U Prior
keysym d = d D Next

keysym BackSpace = BackSpace BackSpace Delete
```

if you want to find a specific key like caps lock:

```bash
# press any key to get the key code
# after running this command:
xev
```

![xmodmap](https://dev-to-uploads.s3.amazonaws.com/i/mpuzzvkqm8x69zyxy7me.png) 

Then add these to `~/.zshrc` or `~/.bashrc` file:

```bash
#you may logout to see changes
xmodmap ~/.Xmodmap
```
Design suggestions
Tags: uiweekly, design, webdev, ux
Published: 2020-10-25 03:28:00

First and foremost, I would like to let anyone reading that I am realllllllllllllyyy new(and BAD) at Designing(never been my strong suit), but lately I've been thinking about hopefully making a **Portfolio** for myself, and yeah you guessed it, I need some decent inspirations for my small brain to get an idea of what to make. 
Though I am not completely relying on an inspiration and lazing around, I actually have already started experimenting some designs with my Portfolio, you can check it at [Link](https://www.figma.com/file/8WlFhLceVc2HAU8PGV5mPa/Website-Design?node-id=30%3A2).

> P.S., please keep in mind that I am not really looking for an excessively fancy Portfolio, I only want one that's worth the time looking at. 

*Thank you for reading!*
Pull requests 
Tags: hacktoberfest
Published: 2020-10-25 03:25:13

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->


### [Intro Heading]
<!-- If you are new to the DEV community, introduce yourself and share a bit about why you joined DEV and decided to participate in Hacktoberfest this year.  --> 
### Background

<!-- Are you brand new to open source? What about coding in general? Tell us about how you got here →

### Progress

<!-- Share a bit about where you’re at in your Hacktoberfest journey. What stage are you at? How has the process been?  -->

### Contributions

<!-- This is where you can list the contributions you made and explain why you chose the projects you did. Don’t forget to add links!  -->


### Reflections
<!-- Overall, how has your Hacktoberfest 2020 experience been? If you’re a first-timer, will you participate again? What have you learned? Have you made any interesting connections? What is your next step in open source?  -->
how to mount another drive and install updates
Tags: linux, mount
Published: 2020-10-25 02:59:08

---
title: how to mount another drive and install updates
published: true
description: how to mount another drive and install updates
tags: linux,mount
//cover_image: https://direct_url_to_image.jpg
---

Few months ago my 9-year-old motherboard died of natural cause, leaving my ssd drive (ubuntu 18) and the rest of parts working. How can I install updates to it?

#### 1. Check mount point of [external] drive

If you don't see a mount point of your external drive (e.g. /dev/sdc1)

```bash
# either check the mount points via
sudo lsblk -f

# or
sudo fdisk -l
```

![lsblk](https://dev-to-uploads.s3.amazonaws.com/i/tq8vtr2fhz2bvrcw5skj.png) 

Mine's showing `/dev/sdc1` so we'll use that as mount point example. Otherwise skip step 1

#### 2. Mount drive (sudoer user)

```bash
sudo mount /dev/sdc1 /mnt

# bind
sudo mount --bind /dev /mnt/dev
sudo mount --bind /sys /mnt/sys
sudo mount --bind /proc /mnt/proc
sudo mount --bind /run /mnt/run

sudo chroot /mnt
```

#### 3. Install updates

Add `-S` for reading standard input instead of `/dev/tty`

```bash
sudo -S apt update
```

![mount](https://dev-to-uploads.s3.amazonaws.com/i/p7j29fg10kpyf41fnb5x.png)
I must live in the open
Tags: mentalhealth, motivation, writing
Published: 2020-10-25 02:17:55

I can’t find a job right now 😑

It’s because I don’t have enough stuff in the open. I have worked on closed source software, and my freelance work consists of a highly specific app, my website, my wife’s, and uncompleted projects. It’s almost like I have been living in the dark for the past 5 years of my life.

I don’t blame people for not hiring me. I only have one year out of college so I am in this weird not a new grad and not a senior engineer spot.

_What really sucks is I live in the dark._ No one follows me on Twitter, no one sees what I am creating, and my tribe is extremely small. So even though my friends have been super helpful I am still in this rut.

## I am going to change that. To have an internet tribe I will be
* Posting thoughts and how-tos here on Medium and over on Dev.to
* Showcasing my work on Codepen.io for simple things and CodeSandbox.io for complex things
* Sharing my work on Twitter

If you made it this far. I am impressed. I bet this article sucks but my verbal communication is something else I am going to be working on. So hang tight brother.

## This week I will be making working on
* Creating an article about Vercel serverless functions
* Creating 3 Codepens (1 redesign, 1 Lottie animation, and 1 random)

Mark my words. I will be editing this article with what I create below.

For a better future,
Josh
p5.js Animated Water Texture
Tags: codepen
Published: 2020-10-25 01:51:36

<p>I created a subtle animated water texture that's reminiscent of Minecraft water while experimenting and tweaking the code that was used in the following video on creating procedural terrain generation using Perlin noise.</p>

<p><a href="https://www.youtube.com/watch?v=IKB1hWWedMk" target="_blank">https://www.youtube.com/watch?v=IKB1hWWedMk</a></p>

{% codepen https://codepen.io/croc/pen/PozWxeX %}
Enabling CORS for Node Express Backend
Tags: node, javascript, backend, cors
Published: 2020-10-25 01:18:40

Let us say you have a React frontend and trying to POST a form to your Node backend. After you hit that submit button, you will be hit with an error in the console.

You basically do not have access to that backend, so we will use CORS to enable it.

First thing is always to install the package
`npm install cors`

Then we would have to require 'cors' and allow our server to use it.
```javascript
const express = require('express')
const cors = require('cors')
const app = express()

app.use('cors')
```

Leaving it like this would allow anything to access your server. This is obviously not good since we do not want anything but our frontend to find access to our backend. 

A way to access a single endpoint would be 
```javascript
const express = require('express')
const cors = require('cors')
const app = express()

app.get('/products/:id', cors(), function(req, res, next)) {
    res.json({msg: 'CORS enabled for this endpoint'})
}

app.listen(80, function () {
  console.log('CORS-enabled web server listening on port 80')
})
```

If you wish to whitelist a website
```javascript
const express = require('express')
const cors = require('cors')
const app = express()

const whitelist = {
    origin: 'localhost:3000'
}

app.get('/products/:id', cors(corsOptions), function (req, res, next) {
  res.json({msg: 'This is CORS-enabled for only localhost:3000'})
})

```

[Link](https://expressjs.com/en/resources/middleware/cors.html)
 to cors documentation
RUP(Relational Process Unified)-simple Definition
Published: 2020-10-25 01:09:19

**The Rational Unified Process (RUP)** is a software development process spanning the entire development lifecycle, well defined and well documented.

 This methodology works on the principle of dividing the process flow into 4 distinct parts. These are mainly analysis and design, business modeling, deployment, implementation and testing.

 The **main difference** between Rational Unified Process and the others is that RUP provides its developers with tools such as templates, guidelines and step by step processes and examples for all stages of the software development process. This process also continuously monitors the quality of the software being created and controls changes.
Cleaner Code with JavaScript Destructuring
Tags: javascript, beginners
Published: 2020-10-25 00:19:12

Destructuring is a really useful way to get named variables out of an object in JavaScript and can make your code more readable.

Imagine we had a `data` object that looked like this:

```js
const data = {
  color: 'red',
  cost: 25,
  name: 'balloon'
}
```

Without destructuring, we could access the values like this: 

```js
// ...
console.log(`The cost of the ${data.color} ${data.name} is ${data.cost}`)
// => 'The cost is 25'
```

Even with short variables, that's already starting to feel cluttered.

Basic destructuring would look like this: 

```js
// ...
const { cost } = data
console.log(`The cost is ${cost}`)
// => 'The cost is 25'
```

...which is identical to this:

```js
// ...
const cost = data.cost
console.log(`The cost is ${cost}`)
// => 'The cost is 25'
```

The big win with destructuring is when you want to pull multiple values off an object:

```js
// ...
const { color, cost, name } = data
console.log(`The cost of the ${color} ${name} is ${cost}`)
// => 'The cost of the red balloon is 25'
```

...instead of this:

```js
// ...
const color = data.color
const cost = data.cost
const name = data.name
console.log(`The cost of the ${color} ${name} is ${cost}`)
// => 'The cost of the red balloon is 25'
```

What if you don't like the name of a key? You can just change it:

```js
const data = {
  color: 'red',
  cost: 25,
  name: 'balloon'
}

const { color, cost, name: itemName } = data
console.log(`The cost of the ${color} ${itemName} is ${cost}`)
// => 'The cost of the red balloon is 25'
```

What about nested objects? If you want to access the items from just one key, you can put the key on the right side of the equal sign:

```js
const data = {
  user: {
    name: 'Josh',
    email: 'josh@imjoshellis.com'
  }
}

const { name, email } = data.user
console.log(`The email of ${name} is ${email}`)
// => 'The email of Josh is josh@imjoshellis.com'
```

What if you want values from multiple levels? No problem:

```js
const data = {
  user: {
    name: 'Josh',
    email: 'josh@imjoshellis.com'
    activity: {
      status: 'inactive',
      lastLoggedIn: 'yesterday'
    }
  }
}

const { name, activity: { status, lastLoggedIn }} = data.user
console.log(`${name} logged in ${lastLoggedIn} and is currently ${status}`)
// => 'Josh logged in yesterday and is currently inactive'
```

What if the key doesn't have a value? You can set a default which will get assigned if the value of the key is undefined:

```js
const data1 = {}
const { undefinedKey = "default value" } = data1
console.log(undefinedKey)
// => "default value"

const data2 = { definedKey: "provided value" }
const { definedKey = "default value" } = data2
console.log(definedKey)
// => "provided value"
```

This was a quick intro into how destructuring works in JavaScript. I hope you were able to learn something!

This article (not written by me) goes into more depth if you're looking for even more examples and explanations: https://dmitripavlutin.com/javascript-object-destructuring/#2-extracting-a-property
Remote developers & electricity bills
Tags: developers, electricity
Published: 2020-10-25 00:18:12

Charges for electricity is one of the heaviest lines of charge for a tech company. Due to the pandemic period many companies have tested remote based workspaces environment 
 and it is almost sure that lot of them will go more and more remote. The fact is that a considerable part of the electricity bills will go to the employees homes electricity billing. How will they handle that?
Working to estimates the increase in electricity bills of people during this pandemic period. Want to know what was your electricity bills before and during the pandemic.
Can you help me?
Please help me estimates this and let's work to make remote dev financially advantageous for us.
I ask you just your $ bills of electricity before and during the pandemic period.
With this form

https://docs.google.com/forms/d/1F6BWA3hzj3IXR5R4JBIUTlL-hXWimlBZSvyN4Pi4UAE/prefill
Run Visual Studio Code on a Raspberry Pi
Tags: vscode, raspberrypi, iot, python
Published: 2020-10-26 15:56:14

---
title: Run Visual Studio Code on a Raspberry Pi
published: true
date: 2020-10-25 00:17:12 UTC
tags: vscode,raspberryPi,iot,python
canonical_url: https://www.jimbobbennett.io/run-visual-studio-code-on-a-raspberry-pi/
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/3nlw1guefq9um2our6do.png
---

It's finally here! An official supported version of VS Code that runs on a Raspberry Pi!

{% twitter 1315371339012739072 %}

This to me is great news. The [Raspberry Pi](https://raspberrypi.org) is a low-priced, small form factor computer that can run a full version of Linux. It's popular with hobbyists and kids - it was originally designed to be a cheap computer for kids to learn to code on. It has the same standard USB and HDMI ports that a PC or Mac would have, as well as GPIO (General Purpose Input Output) pins that can be used to work with a wide array of external electronic components, devices, sensors, machinery and robotics.

What this VS Code release means is kids who are using a Pi can now use the same IDE that their grown ups use at work - Mum codes C# in VS Code at work and daughter codes Python in VS Code on a $35 computer at home connected to the family TV.

Lets look at how to get it set up.

## Installing VS Code on a Raspberry Pi


**STOP THE PRESS**

VS Code has now been added to the Raspberry Pi apt repositories!!!!

To install it - launch your terminal and run the following:

```sh
sudo apt update
sudo apt install code -y
```

## Using VS Code

Once the installer has finished, you will see **Visual Studio Code** as an option in the programming folder in the Pi menu. Select it to launch VS Code.

![Run Visual Studio Code on a Raspberry Pi](https://www.jimbobbennett.io/content/images/2020/10/2020-10-24_17-09-54.png)

You can now install your favourite extensions and program away! Be aware that not all extensions will work fully!

![Run Visual Studio Code on a Raspberry Pi](https://www.jimbobbennett.io/content/images/2020/10/2020-10-24_17-16-14.png)