teleren/devto huggingface dataset:
When Now is not the time (in Go)
Tags: go
Published: 2020-07-21 22:10:29

---
title: When Now is not the time (in Go)
published: true
description: PSA: Use time.Equal() or be sad
tags: golang
//cover_image: https://direct_url_to_image.jpg
---

When testing two `time.Time` variables for equality in Go, you may find that there are (_ahem_) **times** when you get surprising results if you don't use `time.Equal()`:

```go
package main

import (
	"fmt"
	"time"
)

func main() {

	now := time.Now()
	nowUTC := now.UTC()

	fmt.Println("now:   ", now.Location(), now.Format("15:04"))
	fmt.Println("nowUTC:", nowUTC.Location(), " ", nowUTC.Format("15:04"))
	fmt.Println("-----")

	fmt.Printf("now == nowUTC:     %t\n", now == nowUTC)

	fmt.Printf("now.Equal(nowUTC): %t\n", now.Equal(nowUTC))

}

// Output:
// now:    Local 23:00
// nowUTC: UTC   23:00
// -----
// now == nowUTC:     false
// now.Equal(nowUTC): true
```
Run it in the [Go Playground](https://play.golang.org/p/7jF3XzWEmV4)!
How to invert the parameters of a method using Regular Expressions
Tags: regex, visualstudio
Published: 2021-10-26 10:18:17

---
title: How to invert the parameters of a method using Regular Expressions
published: true
date: 2020-07-21 22:07:00 UTC
tags: regex, visualstudio
canonical_url: https://davidsonsousa.net/blog/post/how-to-invert-the-parameters-of-a-method-using-regular-expressions
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mlbh7bzo6lxsvtyj69rh.jpg
---

Today I noticed that all `Assert.Equal()` in our unit tests had inverted parameters. Meaning that we had `Assert.Equal(actual, expected)` instead of having `Assert.Equal(expected, actual)`. The result does not change when the test passes, but it can lead to mistakes or misunderstandings when `Assert.Equal()` returns false.

Changing the order of the parameters is simple but it can be both annoying and time consuming if we have a lot of method calls.

What to do?

Since **Visual Studio allows Find/Replace using regular expressions** , we can do it easily. First, we will need to enable the regex mode in the Find/Replace:

![Selecting Regex on Find/Replace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hn7y4f73vlhsqd2bph22.png)

Then we prepare a regex like the one below and place it on _Find_:

`\((.*?)(, )(.*?)\);`

This regex finds everything what is between the first parentheses and the semicolon, which allows you to have some method calls as parameters like `expectedPerson.GetFullName()`, for example. Also, it separates the result in 3 groups - first parameter (`$1`), coma and space (`$2`), second parameter (`$3`) - which we will have in the _Replace_ like this:

`($3, $1);`

As mentioned previously, we had 3 groups. We could include the group `$2` but ut it's not necessary in this case as we can "hard code" the comma and space for better understanding.

Here is how the Find/Replace is going to look like with our regex and replacements:

![Find/Replace with Regex string](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cxbxogvu6zd1vyo80afl.png)

And here is how the selection looks in the code:

![Code with regex match](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdt87qhpjpim8aar4ndz.png)

**Important:** Don't forget to change the Find/Replace scope to Selection in case you want to invert the parameters of a method otherwise you will have unintended consequences.

![Choosing Selection on Find/Replace box](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qa1btpdcc7gsc3052cou.png)

You can check [this regex in the Regex101.com website](https://regex101.com/r/iGWMb2/2) if you want to play around before using it.
Running 32bit software and the Linux Journal Archive on 64bit Debian 10 Buster
Tags: linux, debian
Published: 2020-07-21 22:06:52

---
title: Running 32bit software and the Linux Journal Archive on 64bit Debian 10 Buster
published: true
description: Run the 
tags: linux, debian
//cover_image: https://direct_url_to_image.jpg
---
Recently I was trying to read the offline Linux Journal 2018 archive.
![Main archive page](https://dev-to-uploads.s3.amazonaws.com/i/ulzwlbopuaydbzoz6ug0.png)
This are a set of files and local webserver which are meant to run on your machine to search and read past issues of the magazine as a website.

This software is executed by running an autorun.sh script, however, when running this script the FlyingAnt webserver didn't execute. By researching this issue I discovered that this file was a 32bit binary and I needed to configure my Debian 10 system to run a 32bit executable.

![Check filetype with the file command](https://dev-to-uploads.s3.amazonaws.com/i/31o7yhrp5qckbr9tcsda.png)

This are the steps I executed to make this possible.

To run 32bit software on Debian 10 Buster Linux distribution you must first:
* Add the i386 architecture to package management.
* Install libc6-i386 package

These steps will allow you to run 32bit software on your Debian 10 64bit distribution.

## Steps
As superuser, add the i386 architecture to package management.
```bash
dpkg --add-architecture i386
```
As superuser, update the package list.
```bash
apt update
```

As superuser, install libc6-i386 package
```bash
apt install libc6-i386
```
## Success
Now I can run the LJ archive with the search feature.
![Search example](https://dev-to-uploads.s3.amazonaws.com/i/ri5rsidxjyokac8snn6k.png)
Day 179: No Room
Tags: hiphop, code, coding, lifelongdev
Published: 2020-07-21 21:46:23

_liner notes_:
- Professional : Pretty good day. Finished up writing the findings and feedback from the last 2 test runs with external developers of a tutorial I've been working on. Lot of really good feedback. Good news is that everyone has been able to get the project working on their first tries. Went over my presentation for later this week again. Made some minor changes. Had a group meeting. Spent the rest of the day finishing up the draft for my next blog post. Had to rework some things as far as how the Web Components will be published to NPM. To avoid any name conflicts, I'll have the readers use scoped public packages. Just have to get a couple of things worked out like where I should put the repo on GitHub. Should have everything wrapped up and submitted tomorrow.

- Personal : So, the side project I'm working on involves live streaming and I was thinking that I would have to use YouTube as a video player, but I found a player that can stream HLS files, which is good because I'm using OpenTok and it gives me an HLS stream. I'll still have the events stream to YouTube, but be able to have my own player on the site. Won't have to worry about embedding the YouTube player. Packed up all the clothes I won't be putting in the van into a moving box. I know there will be no room for everything. I'll be taking it to my parents' place later this week. Also looked into the parts I'll need for the van's inner framework.

![The Grand Canyon in Arizona under a sky full of clouds](https://dev-to-uploads.s3.amazonaws.com/i/gs1z427jdhssamdrrwol.png)

Going to pack up more stuff. Didn't get a chance to work on the window coverings. Hopefully tomorrow. Want to keep working on the parts list for the van. So many choices and ways to do things!!! haha.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube j8myN59qh34 %}
Hidden keys on django projects
Tags: django, python, security, beginners
Published: 2020-07-21 21:34:45

One best practices in software development is hide ours project keys, for example: database name, password database, etc.

To carry out this practice in our projects with Django we can use the following package:  [Python Decouple](https://pypi.org/project/python-decouple/) . 

First activate the project virtual enviroment:

source env/bin/activate

Install python-decouple

```python
pip install python-decouple
```

Create  the .env file  inside folder project:

![.env file location](https://storage.googleapis.com/carnet-pet-storage/Screenshot_20200721_135820.png)

Inside file .env, write the password , path to key .json, etc... data sensible of settings project file.

this is an example:

![.env example](https://storage.googleapis.com/carnet-pet-storage/Screenshot_20200721_154006.png)

And your settings file import your enviroment variables:

```python
from decouple import config
```
Use variables inside your file:

![python decouple use](https://storage.googleapis.com/carnet-pet-storage/Screenshot_20200721_154225.png)

Ready, your data sensible is hidden.

### Note: The enviroment variables could use in any file.
### Important: Not Upload .env file to repository

see you..
Cutting and merging PDF files from the command line
Tags: pdf, bash, linux
Published: 2020-07-21 21:22:11

---
title: Cutting and merging PDF files from the command line
published: true
description: You can easily cut pages from PDF files or merge multiple files with these simple Linux bash commands.
tags: pdf, bash, linux
---
![](https://dev-to-uploads.s3.amazonaws.com/i/gv5xbh4jesjm8fwisjmj.jpg)
<small><i>Photo by <a href="https://unsplash.com/@sharonmccutcheon?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Sharon McCutcheon</a> on <a href="https://unsplash.com/s/photos/documents?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></i><small>

I wanted to show you a few simple commands which saved me a lot of time while tidying up some PDF files.
You can cut them into pages, merge or split based on the page range. Here it is: 

* cut off the first page from `input.pdf` file and save result as `output.pdf`

```bash
pdftk input.pdf cat 2-end output output.pdf
```
* merge `file1.pdf` and `file2.pdf` into single `output.pdf`
```bash
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite \
-sOutputFile=output.pdf file1.pdf file2.pdf 
```

* split `input.pdf` into single-page pdf files starting from 2-nd and ending on 15-th page. It will create files: `output_2.pdf`, `output_3.pdf`, `output_4.pdf` and so on.. up to `output_15.pdf`

```bash
pdfseparate -f 2 -l 15 input.pdf out_%d.pdf
```

* convert image to pdf file

First, install img2pdf: 
```bash
sudo apt-get install img2pdf
```

Then convert `image.jpg` to `output.pdf`:

```bash
img2pdf image.jpg -o output.pdf
```

* convert multiple images to pdf file

You can do it with another very useful tool - [ImageMagic](https://imagemagick.org/index.php).

You can install it like that:
```bash
sudo apt update 
sudo apt-get install build-essential
```
Then let's say we want to create a pdf file from `image1.jpg`, `image2.jpg` and `image3.bmp` :
```
convert image1.jpg image2.png image3.bmp -quality 100 output.pdf
```

You may get error message like: 
```
convert-im6.q16: no images defined `output.pdf' @ error/convert.c/ConvertImageCommand/3258.
```

This means ImageMagic protects you from processing pdf files. To allow it you need to have root privilege and edit `/etc/ImageMagick-6/policy.xml` and comment out this line
```
 <!--policy domain="coder" rights="none" pattern="PDF" --/>
```
Ambient YouTube Browser Plugin
Tags: javascript, html
Published: 2020-07-21 21:16:19

Ambient YouTube is an extension for Google Chrome ([install here](https://chrome.google.com/webstore/detail/odjobhlljplfhckfpcllpiffgmcbojeh)), Microsoft Edge ([install here](https://microsoftedge.microsoft.com/addons/detail/gmkdnjjakjoblhgjojkiaaodmlemfdal)), and Mozilla Firefox ([install here](https://addons.mozilla.org/en-US/firefox/addon/ambient-youtube/)).

{% youtube _sK4kDyG2Wo %}

The plugin adds a new icon to your YouTube videos that lets you enable/disable the ambient color feature. It’s in the toolbar next to fullscreen and looks like color swatches.

![Enable Ambient YouTube mode](https://miro.medium.com/max/716/1*YdhtqJ9VSMQoTHwXq_fjbQ.png)

There are additional options in the popup panel that have some basic settings including the ability to Autoload the feature on each video, run at 60fps, and use more abrupt transitions.

**Autoload:** Initializes Ambient YouTube a video loads on YouTube.com

**Disable Easing:** Colors will not smoothly transition from previous color to newest color. Offers abrupt transitions.

**60 FPS:** Colors will be sampled and rendered at near 60fps during playback. Will start your CPU fan.
Image for post

![](https://miro.medium.com/max/1400/1*NclQ7_cVj7EKBt8eniE6Ig.jpeg)

Ambient YouTube is a free browser extension that does not collect personal data.

Test Video #1: https://www.youtube.com/watch?v=xppH6j7ddlE
Test Video #2: https://www.youtube.com/watch?v=qC0vDKVPCrw

This plugin was original developed as a test for home ambient lighting solutions on video sources such as televisions, computer monitors, and tablets.
#038 Kubernetes - Deployment
Tags: kubernetes, devops, tutorial
Published: 2020-07-21 21:15:33

# Introduction

this is part 38 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.
***

# Deployment

let's say we have in the registry (dockerhub) a container ,  we need to deploy it , In real world a big project contain many containers.
![cluster](https://dev-to-uploads.s3.amazonaws.com/i/rxivjtyl3m23pw5crr7u.png)
Now we have a replicaset with 2 nodes and 5 pods , so we have high availability and load balancing , and every thing work fine.  
Let's say we need to upgrade our containers to a newer version , the first solution that will came to mind is to delete the replicaset and create new one with the editing of the yml file. But this is risky move , why it is risky because in the time between deletion and creating the app will go offline and no one can access the app. You will say heeey hold on it's just minutes , maybe it's true for small apps , but what about big ones? it is a big problem. So there is tones of Algorithms to do roll-update to the app , what roll-update mean ? it mean update 1 at a time. 
![v2](https://dev-to-uploads.s3.amazonaws.com/i/n99i7qr486t8gtfg73zo.png)
update 1 at a time , it's mean he will take v1 and replace it with v2 , one by one in this time the other pods of v1 will still serving the app , so the app will be available at all the times , and he loop threw all the other pods to replace them with v2.
Let's say we find an error in v2 , or the app is not stable or the customer didn't like it or ... what we should do?
![hide](https://media.tenor.com/images/2fd2828ad6510356c42e12a28b491c8b/tenor.gif)
hide(best solution) or so I need a roll-back to the old version so he does the same thing , he loop on every pod replace it and go on.

In the next tutorials we will do the lab and explain how to do it using Kubernetes.
Self-awareness and personal telemetry
Tags: 100daystooffload
Published: 2020-07-21 21:06:47

*A note about this one: it's a bit weird and was written mainly to help me think through some things.*

A curious aspect of my mental state at the moment is the clear sense of self-awareness. Let's say that I wake up dreading the day ahead of me. On one hand I have that feeling and the emotion attached to it. On the other, I have the knowledge that it certainly won't be as bad as I think, and that despite my worst predictions, I know them to be irrational. It doesn't stop me feeling that way, but I think this reflection does help to lessen the anxiety that it leads to.

The term "mindfulness" has entered the mainstream to the point that it can find itself in catchy well-meaning phrases such as "Be safe and be mindful". As interesting a concept as it seems to be, and seeing its prevalence as a major subset of meditation, I wonder if it is overused or even misused. I am practising meditation daily now, but I don't think mindfulness has been mentioned once or actively thought about in the guided lessons I listen to. Instead, the best way I would describe much of my practice is "focus": on breathing, on sounds, on thoughts. It's all contributing to this ability to observe yourself, to see how you are *being* at any given moment. And maybe that is just being mindful; it seems to be more though. The engineer in me would maybe be more comfortable thinking of it as a form of instrumentation or telemetry, and I hope that monitoring that stream of data allows me to improve my abilities at coping with my irrational self.

*I'm publishing this as part of 100 Days To Offload. You can join in yourself by visiting [https://100daystooffload.com](https://100daystooffload.com).*
Which CSS libraries do you use with React? 🧐
Tags: discuss, react, css
Published: 2020-07-21 21:03:38

Hi folks,

I'm starting a new project on RoR / React and was wondering which CSS library to use.
I've worked with Material-UI before but would consider trying something else!

Which CSS libraries do you use for your React (or not) projects and why do you love them? 😍
EuroPython 2020 Conference Booklet
Tags: europython, news, conference
Published: 2020-07-21 21:00:46

Our designer Jessica has created a beautiful conference booklet for you to use during the conference and keep as a memory afterwards. It provides all details, schedule, keynotes, sponsor listings, etc. in a single PDF.

Online version of our conference booklet
Our conference booklet is available as PDF for viewing online, download or printing:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f73d0lp26ebn04shta3k.jpg)

#### 🔗 [EuroPython 2020 Conference Booklet](https://ep2020.europython.eu/media/filer_public/6d/7c/6d7c28d5-5168-4b23-b756-7cf1a39b1807/europython-2020-conference_booklet-web.pdf) (PDF, web version)

## Buy a ticket
If you are interested in attending EuroPython 2020 Online, please head over to our [registration page](https://ep2020.europython.eu/registration/buy-tickets/) to get a ticket.
Building an Animal Crossing Turnip Timer! [video]
Tags: azure, tutorial, techtalks, codenewbie
Published: 2020-07-21 20:53:47

Have you started playing Animal Crossing New Horizons on your Nintendo Switch? Do you keep forgetting to buy turnips every Sunday? Looking for a fun & easy project that will help remind you when to start searching for Daisy Mae? 🤔💰📈

No problem! We made a Courier + Azure Function problem to solve that!

![](https://media.giphy.com/media/h8ISB2nUVITEWjVgGo/giphy.gif)

On this episode of Show & Tell, [Aydrian Howard](https://dev.to/aydrian) (Developer Advocate at [Courier](https://bit.ly/3iQR5Pe), and friend of Chloe irl *and* in Animal Crossing) joins me to talk all about our latest collab- an Animal Crossing Turnip Timer! 🏝 Using the power of Azure Functions & Courier- we talk through the high highs (_"yay!! it's working!!"_) and the low lows (_"noooo- not timezone/UTC math!?!"_) of building a project to help us remember when to purchase our turnips on Sundays.

👉 You can learn how to work with Azure Functions in this free and easy MSLearn tutorial here! 🌈  [Execute an Azure Function with triggers](https://docs.microsoft.com/en-us/learn/modules/execute-azure-function-with-triggers/?WT.mc_id=showandtell-devto-chcondon)

{% youtube uo-vuXurouI %}

Wanna try out Courier to help simplify designing and sending notifications? 💌📱📫 Check them out at https://bit.ly/3iQR5Pe

Want more Animal Crossing content? You're in luck! Check out our previous episode with Brendon North of the [Nintendo Nerds](https://www.youtube.com/c/thenintendonerds) to see his Animal Crossing Game Show Set here! 🎨🕹🏝👉[Brendon North Shows Chloe An Animal Crossing Game Show Set!](https://youtu.be/QVTEXIpLmsk)
How to Make Kubectl Exec Run a Command Against Multiple Pods
Tags: todayisearched, kubernetes
Published: 2020-07-21 18:05:21

I was really surprised to discover the other day that `kubectl` [does not support](https://github.com/kubernetes/kubernetes/issues/8876) running the same command against multiple `Pods` out of the box.
I get why that wouldn't be supported for interactive terminals, but seems like non-interactive commands should be fine.

Oh well. We can still do what we want thanks to UNIX tools like [xargs](https://en.wikipedia.org/wiki/Xargs).

```console
kubectl get pods -o name | xargs -I{} kubectl exec {} -- <command goes here>
```

Just replace the `<command goes here>` bit with what you want to do.

## Example: Setting Log Level to Debug for All Istio IngressGateway Envoys
Here's a real world example of when and how you might want to do this. The other day I was troubleshooting our Istio installation on a dev cluster and needed to set the log level of all of our ingress Envoy proxies to `debug`. One way to do this is to configure it through a `POST` request to each Envoy's admin `/logging` endpoint (on Istio this is on port `15000` by default). 

We had five Envoys and I was feeling lazy, so I cooked up the following:

```console
kubectl -n istio-system get pods -l app=istio-ingressgateway -o name | xargs -I{} kubectl -n istio-system exec {} -- curl -s localhost:15000/logging?level=debug -X POST
```

I'm sure there are other UNIX incantations that could do the same, but this got the job done for me and I'm proud of it. 😊👍
CUSTOM REACT STATIC SITE GENERATOR (Live Coding) [Part 2] | JavaScript | NodeJS | ReactJS
Tags: javascript, node, react
Published: 2020-07-21 20:49:28

---
title: CUSTOM REACT STATIC SITE GENERATOR (Live Coding) [Part 2] | JavaScript | NodeJS | ReactJS
published: true
description: 
tags: JavaScript, NodeJS, React
---

Watch as I live code a Custom Static Site Generator using ReactJS.

The audio after (52:10) went to sh*t. Sorry about that.

I have a basic HTML template, which I use as the foundation to create my React Application. From this template I create all the React Components I need to render the gallery. After the components have been created I use renderToStaticMarkup to render then to a file.

If you missed Part 1: https://www.youtube.com/watch?v=inAWGWfpkHs

0:32 launch.json (for debugging)
0:53 package.json (babel / build scripts)
1:38 first build / console (hello world)
1:56 Hello React
4:35 index.html (the template)
12:30 config.yml (importing the data into the template)
29:10 first raw render of HTML
32:00 import images into gallery
45:30 gallery starting to look like a gallery
52:10 Audio goes to sh*t
52:28 Surprise Kitty!!!
59:10 Final render of Gallery (Ooof)
1:00:45 Deploy Live!
1:02:45 Epilogue

To follow along:
```
git checkout https://github.com/joelnet/mojo-gallery.git
cd mojo-gallery
git checkout youtube-video-part-2
```

More Minute JavaScript Videos: 

[![Screenshot of YouTube Channel](https://dev-to-uploads.s3.amazonaws.com/i/ql8225baay311dte4eib.png)](https://www.youtube.com/playlist?list=PL59tadyXaIqVBUhq1PlZQvUSSzQzM62AF
)
What are some ways to stand out to employers on your LinkedIn?
Tags: watercooler, career, discuss
Published: 2020-07-21 20:41:36

What is something unique you out on your LinkedIn to have your profile stand out to future employers/recruiters? Recruiters, feel free to put in your advice or stories that have gotten someone an interview or hired immediately.

One way I feel is important is using buzzwords for about me, bio, etc. When a recruiter/manager type in "React", "Dev-ops", or anything relating to your targeted career path, you want to be the first 5 people that they see with that search term. 

![Shawn Humphreys profile](https://dev-to-uploads.s3.amazonaws.com/i/duagud1nggbb90axymoj.jpg)

Another thing I feel is important is the featured tab. A good featured post about your projects or achievements could get you a phone call/email alone!
Simple Layout Challenge #1
Tags: challenge, html, css
Published: 2020-07-21 20:33:13

## About

From time to time I practice HTML & CSS layout and would like to invite you to join me 👋 I take a small UI element (soon there'll be modals because I implement [modal libraries](https://github.com/Alexandrshy/keukenhof) and write about it) and just implement it 🙂

## Task

![Simple Layout Challenge #1](https://dev-to-uploads.s3.amazonaws.com/i/72cps12yf5q4jyytqbi4.gif)

___

![Simple Layout Challenge #1](https://dev-to-uploads.s3.amazonaws.com/i/iz5kw0khx1d25u9zqbcv.jpg)
___

Implement such a modal window. As a library, you can use my solution, or any other library, or implement everything in pure HTML & CSS, the choice is yours 

Share your results in the comments, I'll also attach my solution 👾