teleren/devto huggingface dataset:
Random Python Tutorials: Up and Running With virtualenv
Tags: virtualenv, python, virtualenvironment, dependencymanagement
Published: 2019-09-17 03:21:48

---
title: Random Python Tutorials: Up and Running With virtualenv
published: true
description: A short intro to how to install and set up a virtual environment using virtualenv
tags: virtualenv, python, virtual environment, dependency management
---
If you have ever managed multiple python projects on a single machine, you may have run into a problem where you have different projects using different versions of a particular package. You update the package for the latest project you are working on, you then switch back to an older project and BOOM, dependency errors, everyone's favorite.


In this article, I will be giving a brief intro to getting up and running with virtualenv on your system.

virtualenv is a tool used to create and manage multiple python environments, so that you don't have to worry about overlapping packages.

The tool works by creating a fresh python installation where you specify

## 1. Installing virtualenv ##

To install virtualenv via pip:
```
$ pip install virtualenv
```

Check your installation
```
$ virtualenv --version
```

## 2. Creating your first virtual environment with venv ##
Let's make a test_project/ folder to create our virtual environment in
```
$ mkdir test_project/
$ cd test_project/
$ virtualenv venv
```

The `virtualenv` command takes an argument, `DEST_DIR`, which is the directory in which your virtual environment will be created. We created our environment in `venv` if you do not specify a destination directory virtualenv will place the files in the current directory

to use the virtual environment it must be activated
```
$ source venv/bin/activate
```

if you used a name other than `venv` you should substitute it in the above command (ex: `source [folder_name]/bin/activate`).

you should see `(venv)` in front of your default shell.

now that we have activated our virtual environment let's install a package using pip
```
$ pip install requests
```

now run:
```
$ pip freeze
```

you should see the `requests` package is installed.

```
certifi==2019.9.11
chardet==3.0.4
idna==2.8
requests==2.22.0
urllib3==1.25.3
```

now let's deactivate the virtual environment and check the installed packages
```
$ deactivate
$ pip freeze
```

If you have not installed the `requests` package prior to this tutorial, you should not see it in the list of installed packages

What happened here is when you ran deactivate you are put back in the system's default Python Interpreter instead of the virtual environment's.

The `requests` package was installed in the virtual environment.


___
Thanks for taking the time to read! If you have any questions, comments, or concerns I would love to hear them!
Ruby Instant performance measurement
Tags: ruby, rails
Published: 2019-09-17 03:16:13

---
title: Ruby Instant performance measurement
tags: ruby, rails
---

## 🔗 Parent Note
{% link n350071/my-rails-note-47cj %}

## 🤔 Situation
Let's suppose that you have like this code and you want to compare the  performances of instance and session.

```ruby
def current_role
  return @current_role if @current_role
  # ommit..
  @current_role = session[CURRENT_ROLE].reload
end
```

## 🦄 Instant Solution
You can measure by this code. 

```ruby
def instant_performance(&target)
  start_time = Time.now
  yield
  Time.now - start_time
end
```

## 👍 Usage & examples 
```
> instant_performance{ puts 'hello' }
hello
=> 3.9e-05

> instant_performance{ puts 'hello' }.class
hello
=> Float

> instant_performance{ @user }
=> 2.0e-06

> instant_performance{ @current_role }
=> 3.0e-06

> instant_performance{ user_session[CURRENT_ROLE] } / instant_performance{ @current_role }
=> 41.0

> instant_performance{ user_session[CURRENT_ROLE] } / instant_performance{ @current_role }
=> Infinity

> instant_performance{ user_session[CURRENT_ROLE] } / instant_performance{ @current_role }
=> 44.0

> instant_performance{ user_session[CURRENT_ROLE] } / instant_performance{ @current_role }
=> 42.0

> instant_performance{ user_session[CURRENT_ROLE] } / instant_performance{ @current_role }
=> 29.0

> instant_performance{ user_session[CURRENT_ROLE] } / instant_performance{ @current_role }
=> 56.0

> instant_performance{ user_session[CURRENT_ROLE] } / instant_performance{ @current_role }

=> Infinity
> instant_performance{ user_session[CURRENT_ROLE] } / instant_performance{ @current_role }
=> 50.00000000000001
``
Help With This Software Architecture
Tags: help, architecture
Published: 2019-09-17 02:24:52

I had a question and wanted to get some software architecture ideas to see how others would go about designing this system out.

The basic idea/flow of the system is as followed: 
* User uploads a file to a server, which will store it on some cloud storage, like AWS S3.
* Once file has been transferred to S3 it needs to get processed by a specific on premise server. If that server is currently busy processing another file it needs to wait in a queue.
* The on premise server doing the processing needs to read the files from the queue and process them.
* Once a file is finished processing the results need to be uploaded back to the storage, and we need to notify the user that everything is done.
* Throughout all of this some status updates to the user would be nice to see. For example: "Waiting to be processed..." "File is being processed..." "Results Ready."

I guess some general notes: The on premise machine doing the processing would be a Linux box.

I'm just looking for some general ideas on what some others would be looking at. Any ideas are great. Thanks!
Use VIM macros to move quickly through a file
Tags: vim, linux
Published: 2019-09-17 01:58:51

---
title: Use VIM macros to move quickly through a file
published: true
description: Macros are really easy to record in VIM.  Use them to quickly repeat actions multiple times.
tags: vim, linux 
---

So let's review some movement commands in VIM. 

- `hjkl` for left up down right
- `wbe` for jumping between words in a sentence. 

Now let's say you have a huge paragraph you're jumping through.  The whole thing is on one line, but it's like 200 words long.  You want to edit word number 155, but you don't necessarily know it's word #155, you just know it's pretty far along in the paragraph.

How do you get there?

Well, if you're like me, you'll probably start hammering on `w`, jumping word by word.  But then you'll realize "damn, this is going to take a long time" (155 presses, but you're not aware of that).

What's next?  Well, you can jump by 10 words, by typing `10w`.  And you can repeat that by typing `10w10w10w10w10w10w` but that also takes a really long time.

So what's the solution?

**Macros!!**

Macros can be named with any single letter.  So first, let's pick a macro name.  We'll choose `a`. 

1. Start recording the macro by typing `q`, then the macro name `a`
2. Type your macro
3. End the recording by typing `q`

For the case we just had, where we want to repeat `10w`, we would type `qa10wq`. 

Then, to use the macro, we type `@a`.

And finally, the best part, we can type `@@` to repeat the previous macro. 

Of course, this can be used for any action you want to repeat. 

---

Hopefully this tip was helpful.  Follow me on here or on [twitter](https://twitter.com/connorbode) for more quick tips as they come up.
Learn to look around corners
Tags: change, decisions, technicaldecisions
Published: 2019-10-01 01:59:34

---
title: Learn to look around corners
published: true
tags: change,decisions,technical decisions
canonical_url: https://letterstoanewdeveloper.com/2019/09/16/learn-to-look-around-corners/
---

Dear new developer,

Sometimes you want to play out things two and three steps deep. Kinda like chess players, who think about many moves ahead, if you can consider the ramifications of your decisions, you’ll be well served.

I remember talking to someone about a software position at his company and he referred to the “original sin” of choosing a particular NoSQL database. This had ripple effects throughout the life of the company. Some were good, some were bad.

These kind of downstream effects are worth thinking about. The biggest ones are things like fundamental platform choices (Rails or Django, Java or golang, mysql or postgresql). But even smaller things can have ripple effects. I can’t count the times when I’ve said “I’ll just upgrade this **one** thing” and then the change just keeps cascading out.

Or if you are working on a feature definition, think through the ramifications. “We want to allow people to change their email address.” But if email address is the primary key of a table, or a primary means of connecting data across accounts, or some other invariant, what will the ripples in your system be.

And these are just the functional repercussions. There are also performance repercussions to changes, some of which are hard to test unless you are in production.

I’m not saying don’t accept changes. That way lies madness (and Fortran). Just be aware of how changes in complicated systems like web applications have a way of rippling out beyond their intended scope, and consider how to test, mitigate or handle such ripples.

Sincerely,

Dan

Originally published at:  https://letterstoanewdeveloper.com/2019/09/16/learn-to-look-around-corners/
JSON Web Tokens (JWT) vs. SessionID 🔐 ? explained in 2 mins
Tags: webdev, beginners, javascript, security
Published: 2019-09-17 01:34:53

Just like any other 'tokens', JSON Web Tokens (JWT) is a form of secret that's used for authentication (who you are) and authorization (what you can do). Similarly, a SessionID can also be used for authentication and authorization.

# What's the Difference?

The key difference is JWTs are **self-contained**, while SessionIDs are not.

A JWT contains three parts: `<header, payload, signature>`. I won't go into details but basically `payload` contains who the user is and what s/he can do, and `signature` verifies the token is valid. So when server receives a JWT, it can already retrieve all the information directly from the token, i.e., self-contained.

In contrast, a SessionID is merely a long, unique, random string. By itself there is no user information. When server receives a SessionID, it needs to do extra work to find out which user it belongs to, and then what s/he can do. This extra work often requires a database lookup.

Another way to look at it, is JWT is a driver's license (proves who a user is, and what s/he can do, drive a car), while SessionID is a credit card (simply a random number that links to a bank account, that each transaction requires a card reader to talk to bank).

# Why JWT?

The internet has been doing just fine with SessionIDs for many years. Even today, the majority of websites still use SessionIDs. However, in back-end systems that need to handle extremely high volume of http requests, the need to do a database lookup for every single SessionID included in each request can be expensive as it increases latency and reduces throughput.

This is not an issue for JWT as it's all self-contained. The server can simply read the JSON payload from the JWT, without making any database lookups.

# Nice! Why not JWT Everything then?

First of all, JWT requires you to properly store and distribute private / public keys that are used for signing and verifying JWTs. And key management is hard to be done right, especially in a large-scale distributed system.

Secondly, since JWTs are self-contained, there is no way to revoke a JWT token. Unlike a SessionID that you can simply delete from the database and thus remove its link to a user, JWTs are not stored in database so once it's created it's valid until expired. It's like credit cards are easy to be replaced, but driver licenses, once issued, are valid anywhere.

Last but not least, because JWTs cannot be revoked, we tend to give them shorter expiration time, which requires users to re-fetch a new JWT more often. There is an option to use refresh tokens but that adds more complexity on the client side, comparing to SessionIDs where the client only needs to store a simple string.

# So should I use JWT for my next project?

Probably not. SessionIDs should work just fine :)
Round 1 of 100DaysOfCode
Tags: 100daysofcode
Published: 2019-09-17 01:26:20

---
title: Round 1 of 100DaysOfCode
published: true
canonical_url: https://karinarobledo.me/historias/2019/09/15/R1.html
description: I finished Round 1 of #100DaysOfCode.
tags: [100daysOfCode] 
cover_image: https://repository-images.githubusercontent.com/170969189/d3a9ef00-62db-11e9-8425-38ee02fdaaab
---

I finished Round 1 of #100DaysOfCode.
I'm Karina and I'm a leukemia survivor. I knew how to code because I studied Computer Science in Mexico City. My native language is Spanish. I spent 2018 in hospital. I was diagnosed in February and I left the hospital after my transplant in December. I hadn't code anything for a year. 

I decided to start #100DaysOfCode to practice and since I can not leave my house, the challenge made me feel better and helped me with depression. In July I started to work from home like Backend Developer in my country. It was so hard, but I'm doing fine, but this means that I have less time to code for fun.

In August, I had leukemia in the skin again, so I'm getting maintenance chemotherapy and full-body radiation. I don't know if there are cancer patients that want to learn to code. But if you have health problems, you are not alone. Maybe it will take time, but you can code.

I will list the projects that I did. 

{% twitter 1173055238338748416 %}

{% twitter 1171938361667457024 %}

{% twitter 1170508370891169792 %}

{% twitter 1163282961992695808 %}

{% twitter 1162532593692286976 %} 

{% twitter 1160384619050651648 %}

{% twitter 1160318083275395078 %}

{% twitter 1157541229778866176 %}

{% twitter 1155580352603316226 %}

{% twitter 1153846826006487042 %}

{% twitter 1153524646056214528 %}

{% twitter 1152023740001050624 %} 

{% twitter 1150093243511713792 %}

{% twitter 1148405044678668288 %}

Before you finish reading. For me, the more important thing is to be happy and enjoy life. I'm 300 days post-transplant and I defeated cancer. Well, this is the beginning of my life as a developer. I hope to create more projects that help people and I want to be a successful developer in my company.

Believe in you, you can do it.
Windows 10 VPN 설정 시 네트워크 트래픽 범위 제어
Tags: korean, windows, vpn, powershell
Published: 2019-09-17 01:22:57

왠만한 VPN 클라이언트라면 이런 옵션이 있다.

> 모든 네트워크 트래픽 보내기 (Route all traffic through VPN)

윈도우는 이게 바로 안보여서 조금 고생했지만, 윈도우도 엄연히 옵션이 있다.
(아마 윈도우 7에도 있을 거다 확신이 없으니 찾아보고 보고해달라.)

> 원격 네트워크에 기본 게이트웨이 사용 (use default gateway for remote networks)

근데 찾기가 좀 어렵다. VPN 속성에 들어가서 네트워크 탭 > 인터넷 프로토콜 버전 4 더블클릭 > 고급 버튼에 들어가야 있다.

어쨌든 이렇게 있으니 참고하면 되고,
가뜩이나 윈도우 10은 이게 들어가거 더 힘들다. 2가지 옵션이 있는데,

설정 > 네트워크 및 인터넷 > 어댑터 옵션 변경

이렇게 힘들게 들어가면 레거시 네트워크 어댑터 설정 창이 뜨는데 거기 오른쪽 마우스 클릭해서 속성으로 들어가면 되고,

`win+R` > `rasphone`

시작 > 실행에서 위 실행 파일을 치고 들어가면 "전화 연결" 이라는 조그만 창이 뜨는데, 원래 전화 연결(옛날 ADSL 및 진짜 모뎀을 통한 전화 연결 등)을 취급했던 프로그램이다. 이건 오히려 윈도우 10에서도 있다는게 이상할 정도로 옛날 프로그램이다. 윈도우는 VPN도 전화 연결로 취급하므로 여기서도 VPN 설정을 추가하고 편집할 수 있다. 물론 속성에 들어가면 같은 속성 창이 뜬다.

만약 텍스트 편집이 편하다면, 이런 개고생할 필요도 없이, 편집기로 아래 파일을 열어서,

`%appdata%\Microsoft\Network\Connections\Pbk\rasphone.pbk`

대괄호로 감싼 VPN 연결명 아래 `IpPrioritizeRemote` 문구를 찾아 `=1` 로 되어 있으면 `=0` 으로 바꿔주면 된다.

아니면, Powershell 로도 한 방에 가능하다.

```powershell
# $True 로 하면 비활성화, $False 로 하면 활성화. 기본값은 당연히 $False
Set-VpnConnection -Name "VPN 연결명" -SplitTunneling $True
```

다른 VPN 클라이언트는 경우에 따라 기본 비활성화하거나 활성화할 수도 있으므로 VPN 클라이언트에 "모든 네트워크 트래픽" 문구의 체크박스나 선택 란을 꼭 확인하여 네트워크 범위를 조절할 수 있도록 하자. 모바일의 경우 대부분 모든 네트워크 트래픽은 비활성화이다.

끗.
Finding your tribe - RESOURCES / LINKS (Reactor Sydney)
Tags: community, sydney
Published: 2019-09-17 01:18:40

Thanks to everyone who joined my session.

My talk "Finding your tribe - It all begins with community" mentioned a bunch of great dev community groups who are doing awesome things. Here is a list of all the communities and people that I referenced:

These are the groups I mentioned that are really popular:
[Sydney Python MeetUp] (https://www.meetup.com/en-AU/sydneypython/)
[Data Science Melbourne] (https://www.meetup.com/en-AU/Data-Science-Melbourne/)
[PyData Sydney] (https://www.meetup.com/en-AU/PyData-Sydney/)
[Fishburners Meetup] (https://www.meetup.com/en-AU/Fishburners-Meetup/)
[Sydney-Data-Science-Breakfast]
(https://www.meetup.com/en-AU/The-Sydney-Data-Science-Breakfast-Meetup-Group/),    


These are the community groups that are innovating and shaking things up:
[Women Who Code Melbourne] (https://www.womenwhocode.com/melbourne)
[HackUp Melbourne] (https://www.meetup.com/en-AU/hackup-melbourne/)
[Power BI Sydney]  (https://www.meetup.com/en-AU/Sydney-Power-BI-User-Group/events/past/)
[Men Championing Change Sydney] (https://www.meetup.com/en-AU/Men-Championing-Change-Meetup/) 

Some people to check out live coding on Twitch:
[Kym Phillpotts]  (https://www.twitch.tv/kymphillpotts)
[Noopkat] (https://www.twitch.tv/noopkat)
[Jim Bennett] (https://www.twitch.tv/jimbobbennett)

A great online initiative:
[HacktoberFest]  (https://hacktoberfest.digitalocean.com/)

Hackathons:
[Hackathons Australia] (https://www.hackathonsaustralia.com/)
[She Hacks 2019 Sydney]  (https://www.meetup.com/en-AU/Girl-Geek-Sydney/events/261586661/)
[Microsoft Global Hack] (https://news.microsoft.com/transform/at-the-microsoft-global-hackathon-customers-break-something-to-make-something/)



Champion/Ambassador Programs: 
[Microsoft MVP] (https://mvp.microsoft.com/)
[Docker Captains] (https://www.docker.com/community/captains)
[AWS Community Heroes] (https://aws.amazon.com/developer/community/heroes/?community-heroes-all.sort-by=item.additionalFields.sortPosition&community-heroes-all.sort-order=asc)
[Cloud Native Computing Foundation (CNCF) Ambassadors] (https://www.cncf.io/people/ambassadors/)
[Google Developer Experts] (https://developers.google.com/community/experts/)
[Java Champions] (https://community.oracle.com/community/groundbreakers/java/java-champions)

Some Upcoming community events are:
[DDD Sydney] (https://next.dddsydney.com.au/)
[NDC Sydney] (https://ndcsydney.com/)
[.Net DownUnder Community Day] (https://ti.to/net-down-under-tour-sydney/net-down-under-community-day-2019/en)
[GopherCon] (https://gophercon.com.au/)
[Laracon]  (https://laracon.com.au/)
[All Day DevOps] (https://www.alldaydevops.com/)
[Kubernetes Forum Sydney] (https://events.linuxfoundation.org/events/kubernetes-forum-sydney-2019/)

Thank you
Trusted Web Activity + Android App Bundle
Tags: android, web, playstore, app
Published: 2019-09-17 00:22:10


Golden tip when publishing your TWA at PlayStore.

If you didn't see the previous article, about TWA [take a look here.](https://dev.to/kimuradev/trusted-web-activities-54lc) 

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/kwgxxogen53ycavvpcxy.png)


Today I'm going to talk about a problem that some of you may encounter when publishing an App to the store using the **Android App Bundle format.**

For those who do not know, this is the new [official](https://developer.android.com/platform/technology/app-bundle) model of publishing an application on the Play Store. Through this new format, Google promises **better efficiency** in builds and releases, as well as **increasing compression** and **reducing the size** of your application.

If you want to know more, I will leave the link below:
[https://developer.android.com/guide/app-bundle/](https://developer.android.com/guide/app-bundle/)

 
#That said, where do I want to go?

Well, with this new way of publishing, we have a very interesting option to select your [app signing](https://support.google.com/googleplay/android-developer/answer/7384423) through the Google store itself. And if you did, you need to **replace** your key generated via Android Studio with the key that was generated on the Play Store, otherwise authentication between your app and your site **will fail**, and the URL bar will be appearing in your app, similar to the one in the image below:

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/1woyddo8nkm30z7gb6zj.png)

To prevent this from happening, and your TWA looks like a native App, just enter your app's **settings** on the PlayStore, and in the left side menu look for the **Release Management** option and select the **App Signing** option.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/sv8haij2m2l4vo6pa9un.PNG)


On the right side, you should open a screen like the one below, informing you which is the **SHA-256 Certified Fingerprint**, which you should replace in your **assetlinks.json** file.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/14bc3xths7j8kdhzqmg0.PNG)

That done, just **upload** your json file to your website, and your TWA will be working properly!

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/pajyjhs5rp1fwun1zis2.png)

Well, today was just a quick tip that can help anyone who is experiencing this little problem!

If you have some question you can find me on twitter [@kimuradev](http://twitter.com/kimuradev).

See u guys!
🎉 Announcing Gatsby Post Manager
Tags: gatsby, tools, opensource
Published: 2019-09-17 00:00:00

---
title: 🎉 Announcing Gatsby Post Manager
description: Gatsby Post Manager is a command line tool that helps you keep track of your posts and their status.
tags: gatsby, tools, opensource
published: true
canonical_url: https://stevenmercatante.com/announcing-gatsby-post-manager
---

I use Gatsby for blogging and like to write a bunch of articles at once so I can release them over time. But, since I use flat files instead of a CMS, keeping track of my articles and their status (published, pending, unpublished) can get tricky - especially as the number of them grows. So, I built a tool to help manage them.

🎉**Introducing [Gatsby Post Manager](https://github.com/steven-mercatante/gatsby-post-manager)**🎉

Gatsby Post Manager (`gpm` for short) is a command line tool written in Node.js that makes it easy to track how many posts you have, as well as their status. It's meant to be installed as a global package so you can use it for any of your Gatsby sites.

```bash
$ npm install -g gatsby-post-manager
```

Currently, it has two commands: `posts` and `post-stats`. The project's [`README`](https://github.com/steven-mercatante/gatsby-post-manager/blob/master/README.md) shows more detailed usage, but the gist is...

**You can show all posts:**

![gpm-all-posts](https://thepracticaldev.s3.amazonaws.com/i/fqmsc2jgakdwtl6aby3g.png)

**Filter posts by a specific status:**

![gpm-pending-posts](https://thepracticaldev.s3.amazonaws.com/i/zlcbj2i3ofdgh6r920u0.png)

**Show a quick summary of post stats:**

![gpm-post-stats](https://thepracticaldev.s3.amazonaws.com/i/14p69zdml21c17rjzr8v.png)

`gpm` works by finding all of your markdown (including MDX) posts, parsing their frontmatter and determining their status, before rendering data to your terminal. The concepts behind `gpm` are pretty simple, and should be applicable to other static site generators.

If you've ever found keeping track of your Gatsby posts tricky, I hope you'll give [Gatsby Post Manager](https://github.com/steven-mercatante/gatsby-post-manager) a try.

👋 **Enjoyed this post?**

Join my [newsletter](https://stevemerc.com/newsletter/?r=dev) and follow me on Twitter [@mercatante](https://twitter.com/mercatante) for more content like this.