teleren/devto huggingface dataset:
Besides VC, what else do you use GitHub for?
Tags: github, discuss, productivity
Published: 2020-12-27 22:37:23

---
title: Besides VC, what else do you use GitHub for?
published: true
description: 
tags: github, discuss, productivity
cover_image: https://docs.microsoft.com/en-us/azure/architecture/solution-ideas/media/devsecops-in-github-vulnerability-management-data-flow.png
---
Most devs love GitHub (or GitLab, Bitbucket, etc) purely for code version control, tho there might be more use cases than that.

For example, I use it to backup articles from [Hashnode](https://hashnode.com) and sketches from [diagrams.net](https://app.diagrams.net/) (ex draw.io). What else do you use GitHub for?
Christmas wrecks me.
Tags: watercooler
Published: 2020-12-27 22:32:22

I have not coded a single line in maybe 2 weeks... Bliss, absolutely feeling nothing but ... Sheer panic actually, I have to go back to work soon and how do I type again?! umm err 😫

I'm sure I'm not alone ✊ solidarity of the lazy brains and fingers people.
Version Control - A Central Tenet In Software Development (Part 2)
Tags: git, github, gitk
Published: 2020-12-27 22:27:10

---
title: Version Control - A Central Tenet In Software Development (Part 2)
published: true
description: A Git tutorial with some Tenet references
tags: git, github, gitk
//cover_image: https://direct_url_to_image.jpg
---
# Part 2
This is part 2 of my series of blogs on git. Here's a link to part 1: [Version Control - A Central Tenet In Software Development (Part 1)](https://dev.to/szam/version-control-a-central-tenet-in-software-development-part-1-2hgk). In this installment I'll be going over some of the simpler aspects of git. 
# Branches
Branches are the bread and butter of git. They allow developers to experiment with new features without directly changing the main branch of production! And they are quite easy to work with. The only commands we need are `git branch` and `git switch`. `git branch` will list all the branches of a repo. It can also create a new branch if we add a word as an argument like this: `git branch experiment`. I'm sure you've guessed from context that `git switch experiment` will take you to the experiment branch. Upon the creation of a new branch, all files are identical to the original main branch. Changes will be reflected in all branches until they are committed in a specific branch.
# Merging
Once we have made changes on a new branch, and they are ready to be merged into our main branch, we will run the command `git merge experiment`. This will merge our experiment branch with our main branch. Hopefully there are no merge conflicts because who wants that? But if there are conflicts we can manage with the tools git has given us. `git diff` will show us the differences between our two branches we've attempted to merge. Now we'll try our luck at conflict resolution by editing the files that git complained about. If we open the conflicting file we will be shown where the conflicts are(aka where the files are different). Once we have changed the file to our liking, we will now add them and commit them. Boom! Our new feature is now in our main branch! 
# Delete A Branch
You can easily delete a branch once you are finished merging with the d option `git branch -d experimental`. 
# Forward
With this new knowledge we can easily add new features in a reliable way. We can create new branches, merge them into our main branches, and delete them. Next week we'll go over how to collaborate with others.
# Bonus Tool!
gitk is a very useful program that allows us to visually see our git trees: changes in our commits, merge conflicts, branches, etc. It's super useful and I highly recommend it! Here's a screenshot of my real-recipes application! Notice how I cleaned up those messy nested authorization if statements. ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lm6mk8o487k6w8p6sk65.png)
qutebrowser loading browser session from command line
Tags: automation, qutebrowser, cli
Published: 2020-12-27 22:23:33

---
title: qutebrowser loading browser session from command line 
published: true
tags: automation, qutebrowser, cli
---

This will be a shot one. In qutebrowser you have the possibility to save browser sessions. This will save all your current open tabs.
You can obviously loading this session files, and all the tabs will be restored.

In my case it comes handy, in support weeks when I have to monitor different pages.

And to have a more direct access, I wrote a two liner and combine rofi with that. 

![qutebrowser-session-selector.png](https://www.dropbox.com/s/v14bgc3twjhk1h9/qutebrowser-session-selector.png?raw=1)


```bash
#!/bin/bash

sessions=$(ls -1 $HOME/.local/share/qutebrowser/sessions | rofi -dmenu -theme ~/dotfiles/i3/rofi.rasi)
if [ "$sessions" != "" ]; then
    qutebrowser ":session-load ${sessions/\.yml/}"
fi
```
PWA Caching Strategies
Tags: pwa, javascript, typescript, react
Published: 2020-12-27 21:54:56

Caching strategies determine how a PWA behaves when the app makes a network request and how it deals with network failures. Workbox is a commonly used library for creating PWA; `workbox-strategies` provides the following caching strategies.

## Stale-While-Revalidate

The service worker will serve the cached assets first, and update the cache with the latest version afterwards. On cache-hit, it responds to the request as quickly as possible. On cache-miss, the request falls back to network request. The response from network request is then used to update the cache. This strategy is useful in situation where receiving a response has higher priority over having most up-to-date results.

## Cache First

The service worker will serve the cached assets and will only query the network if the cache is not available. On cache-hit, it will not update the cache in background; the network will not be used at all. On cache-miss, the request will be sent over the network and the response will be cached. The next request will then be served from the cache. This strategy is useful for requests for static assets, which do not change frequently.

**If no caching strategy is defined, Workbox will use Cache First as default.**

## Network First

The service worker will by default try to fetch the response over the network. If the network request fails, it will serve the response from the cache. On successful response over the network, it will cache the response for future use. This strategy can be useful in requests that update frequently. 

## Network Only

The service worker will always query the network for response. This can be useful if you require to query the network strictly.

## Cache only

The service worker will always query the cache for response. You need to make sure that you pre-cache resources before requesting. This strategy is less used in practice.


# Example Usage

On your `service-worker.ts`, add a custom strategy for a fetch event.
Note: You could also define custom events for different fetch requests by filtering depending on URL origin or path.
  
```
import { StaleWhileRevalidate } from "workbox-strategies";

...

//! Stale-While-Revalidate for all fetch events
self.addEventListener("fetch", (event) => {
    const { request } = event;

    event.respondWith(new StaleWhileRevalidate().handle({ event, request }));
});
```


Workbox also allows you to define custom strategies. All of these strategies also allow you to configure name of cache, cache expiration and an array of additional workbox plugins.

Happy Hacking!
python keyword arguments
Tags: tutorial, python, devops
Published: 2020-12-27 21:36:19

## How to check if a string is a valid keyword in Python?
#### What is keyword?
A keyword is a “reserved word” by the language which convey a special meaning to the interpreter. It may be a command or a parameter. it is a word that cannot be used as a variable name, function names, or any other identifiers in the program .
#### what are python keywords?
Python keywords are some words that convey special meaning. Examples of keywords registered by python are as follow:

`continue`, `import`, `while`, `def`, `in`, `with`,
`del`, `is`, `yield`, `False`, `elif`, `lambda`,
`None`, `else`, `nonlocal`, `True`, `except`, `not`,
`and`, `finally`, `or`,`as`, `for`, `pass`, `assert`,
`from`, `raise`, `break`, `global`, `return`,
`class`, `if`, `try.`

#### How do we check if a string is keyword?
in python there is an inbuilt module `keyword` which handles certain operations related to keywords. there is a function too `iskeyword()` which is used to check if a string is keyword or not. Returns true if a string is keyword, else returns false.
let's try to write a code that tell us if our string is a keyword or not.
### Example
```python
# we need to import "keyword" for keyword operations 
import keyword  
# state the list of all string we want to test
str_test = ["in", "while", "loop", "break", "evening", 
"elif", "assert", "maxwizard", "lambda", "else", "map"] 

for i in range(len(str_test)): 
     # checking which are keywords 
    if keyword.iskeyword(str_test[i]): 
        print(str_test[i] + " is python keyword") 
    else: # if it is false then write
        print(str_test[i] + " is not a python keyword") 
```
OUTPUT:
```
in is python keyword
while is python keyword
loop is not a python keyword
break is python keyword
evening is not a python keyword
elif is python keyword
assert is python keyword
maxwizard is not a python keyword
lambda is python keyword
else is python keyword
map is not a python keyword
```
But what if you are working how will you make sure you don't use all this keywords as variable? well it might be a difficult task to remember all while assigning variable names. Hence a function `kwlist()` is provided in “keyword” module which prints all the 33 python keywords for you here is how to print it below.
Example2
```python
#Python code on how iskeyword() works
  
# importing "keyword" for keyword operations 
import keyword 
# printing all keywords at once using "kwlist()" 
print ("The list of keywords is below : ") 
print (keyword.kwlist) 
```
Output:
```
The list of keywords is : 
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 
'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 
'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 
'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 
'try', 'while', 'with', 'yield']
```
 Notice that `kwlist` will return the list of all 33 keywords in python.
Count and say 1️⃣2️⃣3️⃣...
Tags: algorithms, javascript
Published: 2020-12-27 17:32:54

This problem asks to write a program that translates a number between 1 and 30 to `count and say`. This means that starting with 1, we need to find the next number which is the count of any consecutive duplicate integers and the number itself. So we use the last number to find the next. Let me try to explain it more visually:

 1.     1
 2.     11
 3.     21
 4.     1211
 5.     111221 
 6.     312211
 7.     13112221
 8.     1113213211
 9.     31131211131221
 10.    13211311123113112211

Since 4 is `1211`, 5 is `111221` so digit by digit:

* `1` -> 11 (one ones)
* `2` -> 12 (one twos) so far: 1112
* `11` -> 21 (two ones) final: 111221

## Code

Taking a look at the algorithm:

```javascript
let countAndSay = (n) => {
    
    let result = '1'
    
    for(let i = 1; i < n ; i++){

        let consecutiveDigits = ''
        let substringResult = ''

        for(let j = 0; j < result.length; j++){

            consecutiveDigits += result[j]

                if(result[j] !== result[j+1]){

                    substringResult += `${sameDigits.length}${sameDigits[0]}`
                    consecutiveDigits = ''
                }
        }
        result = substringResult
    }
    return result
};
```

We start the count at 1 as a string (`let result = '1'`), then set an empty string that will track the consecutive digits (`let consecutiveDigits = ''`) and if there are duplicates we add them (`consecutiveDigits += result[j]`). 

When the next number is different (`if(result[j] !== result[j+1])`) we count the current duplicates (`consecutiveDigits.length`) and add the current number (`consecutiveDigits[0]`). 

Both values are added as substrings in the inner loop (`substringResult`) and this is set to `result` on the outer loop. 

After the inner loop iteration is finished we set the result variable to the substrings we have collected.

The outer loop goes on until we reach the desired number to translate to `count and say` and stores the previous number. While the inner loop goes analyses the previous `count and say` number to generate the next number.

Feel more than welcome to [reach out](https://twitter.com/santispavajeau) or [connect](https://www.linkedin.com/in/santiago-salazar-pavajeau/)!
[Road to Job] #1 Electrical to Software Eng
Tags: java, webdev, career, beginners
Published: 2020-12-27 21:02:12

Hello...I am new to doing stuff like this but I figured that I would document my journey to help others that may be in a similar situation.

Let me start by setting the scene. I'm in my last year of Electrical Eng, Eng Management and Entrepreneurship degree and have worked internships in the electromechanical industry and power/telecom construction. However, much of my degree and my work experience left me feeling unfulfilled. 

I grew up never knowing what I liked and felt lost as to where I wanted to go with my career until I did a hackathon with some friends and found my love for coding!

So here I am, in my last year, middle of a pandemic and looking to follow my passion and get into backend or software dev by the time I graduate in the summer.

Relevant work experience: None...unless Access Databases count lol
Coding Languages and Technologies: C...that I had a course in and have done some Arduino projects with
Determination: Through the roof!

If you are interested, my next post will lay out my plan of action and I would love to get your feedback.

NOTE: I have already started as of writing this so this isn't Day 1. Also, I work part time and am in full time school so I will be doing my best to keep up with my goal and try to keep 2-3 hours a day at minimum.
Wow, I just joined an awesome community!
Tags: beginners, firstyearincode, firstpost
Published: 2020-12-27 20:59:02

**I am not exactly sure how I stumbled upon this gem of a platform.** For my first month of coding there has been countless searches and so much seeking for quality content. While looking for answers to simple questions like; **"what is python?".** Or "what are good projects to start a portfolio with?". 

>Stumbling into dev.to was like finding that missing semicolon after looking at the same lines of code for a half hour. 

####Hello world. 

##Finally a place where the people are actively growing and actually helping others do the same. 

Beginners documenting their journey. Experienced programmers, developers, & engineers sharing gold nuggets of wisdom. _Then there are the comments._ Actual well spoken, appreciative comments, giving insight into what was gleaned from someones passionate article. 

#**_I ❤️ DEV.TO_**

I have only been lurking for about 2 weeks and bookmarking a couple articles here and there but I have to say. **This place is a GOLD MINE!**  

_Maybe it's just the honeymoon phase but this may be the social network that I actually keep up with._  


**Thank you everyone here for inspiring me to write an article.**

>Also

**A huge bravo, and thank you to the dev.to team for putting together this amazing platform.** 

#Happy Holidays and Happy New Year to everyone :)
Apple website remake
Tags: html, css, javascript, webdev
Published: 2020-12-27 20:50:03

![apple-app](https://dev-to-uploads.s3.amazonaws.com/i/yu08cmlq5tai58o35zs5.jpg)
During the Christmas break, I decided to re-design the apple website and share it with you guys. I have attached the source code on my Github <a href="https://github.com/casulemarc/appleclone">Here</a>
Faking google cloud storage in Python
Tags: django, python, googlecloud, gcs
Published: 2021-05-27 10:28:03

---
title: Faking google cloud storage in Python
published: true
date: 2020-12-27 20:49:11 UTC
tags: django,python,googlecloud,gcs
canonical_url: 
---

I had a problem where I couldn’t register to google cloud and use the google cloud storage service. Tried searching online and found this repository: [https://github.com/fsouza/fake-gcs-server](https://github.com/fsouza/fake-gcs-server)

It has great documentation and you can also run it if you have docker installed:

```
$ docker run -d --name fake-gcs-server -p 4443:4443 fsouza/fake-gcs-server
```

I had a task to upload files to google cloud storage but I wasn’t given access to the bucket. We were using docker and I was able to easily add it to our `docker-compose.yml` file:

```yaml
version: '2'
services:
  mygooglecloudstorage:
    container_name: mygooglecloudstorage
    image: fsouza/fake-gcs-server
    ports:
      - "4443:4443"
    volumes:
      - ./gcs/data:/data # This just prepopulates data
```

And since I wanted to use it locally first, I created a file called `fake_gcs.py` with the following content:

```python
def get_fake_client():
    import requests
    import urllib3
    from google.api_core.client_options import ClientOptions
    from google.auth.credentials import AnonymousCredentials
    from google.cloud import storage
    my_http = requests.Session()
    my_http.verify = False # disable SSL validation
    urllib3.disable_warnings(
        urllib3.exceptions.InsecureRequestWarning
    ) # disable https warnings for https insecure certs

    client = storage.Client(
        credentials=AnonymousCredentials(),
        project="test",
        _http=my_http,
        client_options=ClientOptions(api_endpoint='https://127.0.0.1:4443'),
    )
    return client
```

I did this so that I could easily replace `client = storage.Client()` with `client = get_fake_client()` later when I push my code.

`storage.Client()` package uses the `GOOGLE_APPLICATION_CREDENTIALS` environment variable so there wasn’t much of a problem switching between the original and the fake client.

Now, you can perform regular operations in your fake server like you normally would in the original server.

```python
from fake_gcs import get_fake_client

client = get_fake_client()
bucket = client.bucket('sample-bucket')
blob = bucket.get_blob('test_file.txt')
```
One-click Portfolio/Personal blog generator from dev.to API
Tags: dohackathon, sapper, portfolio, jamstack
Published: 2020-12-27 20:45:11

## What I built


Simple Sapper Personal site that also fetches your articles from DEV using the API and you only need to supply just four environment variables during digital ocean app deploy.

Not just that it also updates the site when you write a new article at dev, how cool is that?


### Category Submission: 
Personal Site/Portfolio

### App Link:

https://dev-to-sapper-zfnzi.ondigitalocean.app/ also at https://blog.shriji.xyz/ which was easy to configure via DigitalOcean's app dashboard

### Screenshots

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kbe1v4p31xx9vvtghbg8.jpeg)
<figcaption>Home page</figcaption>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/o2sweir5eb6z7sv008lv.jpeg)
<figcaption>Posts page fetches 10 articles (Can be tweaked via .env)</figcaption>


### Description
 
Sapper is the companion framework of svelte, like how Next/Nuxt is for React/Vue. You have the benefits of svelte and all the SEO powerhouse and Server Side Rendering. You can read more about sapper [here](https://svelte.dev/blog/sapper-towards-the-ideal-web-app-framework).

Options as of now that can be supplied via `.env` fork/clone for local development. The same variables need to be supplied at DigitalOcean. The template is below.

```
DEV_USERNAME = username
DEV_API_KEY = supersecretkey #obtained via https://dev.to/settings/account
PER_PAGE = 10 #if you like pagination
COMMENTS = true #if you want comments in each post
SITE = https://yoursite/ #SEO/Social Share

```

### Link to Source Code 

https://github.com/peopledrivemecrazy/dev-to-sapper

Go to the repo hit the **Deploy to DigitalOcean** button;

Raise issues in GitHub if something went wrong, PRs are always welcome :)


### Permissive License

https://github.com/peopledrivemecrazy/dev-to-sapper/blob/main/LICENSE

## Background

There aren't many examples showcasing the ease and joy of creating Sapper apps, I always wanted to consume DEV API to do something and this hackathon was the perfect motivator for building this app. Also, the one-click deploy fun.

### How I built it 

I have been working with Svelte and Sapper and I have written most of my articles about them and my previous app with Sapper which I had a lot of fun building [Trello JAMstack](https://dev.to/shriji/sapper-jamstack-trello-as-a-blog-backend-part-1-424n) and showcasing on one of the [talks](https://www.youtube.com/watch?v=z3mEVrvLWuc) and this one-click app is a perfect example of how a personal portfolio/blog can be generated with Sapper.

This project uses [Luke Edwards's httpie](https://github.com/lukeed/httpie), A lightweight alternative to node-fetch which gets the job done.

In general, Svelte steers users in the direction of using lightweight libraries.

### Additional Resources/Info

[Svelte](https://svelte.dev/)
[Sapper](https://sapper.svelte.dev/)
[Repo](https://github.com/peopledrivemecrazy/dev-to-sapper)
What are your favorite articles from 2020? #bestofdev
Tags: discuss, bestofdev, gratitude, writing
Published: 2020-12-27 20:34:00

Dear reader, it's this time of the year to look back with gratitude the good things that happened in parallel with the shitshow that 2020 was overall :)

Want to try a little gratitude exercise with me?

- Go to https://dev.to/readinglist
- Pick a prime number like 2, 3, 5, 7 
- Select your favorite articles from the year
- Add a comment here, formatted like that:

```
Here are my $PRIME_NUMBER favorite articles for this year:

1. I enjoyed this article from @author1 because....
{% post http://dev.to/example1 %}

2. This article from @author2 was especially helpful to me because....
{% post http://dev.to/example2 %}

3. Last but not least @author3 made me laugh because...
{% post http://dev.to/example1 %}

```
100 Days of Code ~ Day 4
Tags: 100daysofcode, javascript, webdev, challenge
Published: 2020-12-27 20:21:45

Today started with activity 5 from [JavaScript30](https://javascript30.com) which included practicing CSS flex box and changing them with vanilla JavaScript. Wasn't super excited about this one as CSS and flex box are most certainly NOT my friend, but it did make me realize that they are simply skills I need more practice on so will be looking to do so in the near future, any recommendations on good sources for such are most definitely welcome! 

Finished up by completing more of Udemy course I'm also working on [React Testing with Jest and Enzyme](https://www.udemy.com/share/101ZdQA0oddV9QR3Q=/) where we moved into setting up Redux for the app were making by configuring the store, setting up reducers, including the root reducer, setting up the actions and tests for all of the above. The course actually also offers a path of making the app with React hooks instead of Redux and I'm planning on doing it both ways as while I'm very familiar with Redux, I haven't taken much time to familiarize myself with React hooks and look forward to doing so!