teleren/devto huggingface dataset:
Dotfiles - Global Git Ignore
Tags: git, dotfiles, gitignore, ignore
Published: 2020-09-06 11:39:14

> Global git ignore content for `~/.gitignore` - a user-wide git ignore file applied to all repos

See my full [.gitignore](https://github.com/MichaelCurrin/dotfiles/blob/master/.gitignore.sh) file.


## Configure git

First, configure your git config to be aware of a `~/gitignore` file. You can name it anything you want.

```toml
[core]
	excludesfile = "~/.gitignore"
```
Here's a quick to set that. Note that this won't add the double quotes but it will still expand correctly.

```sh
$ git config --global core.excludesfile '~/.gitignore'
```

## Create ignore file

Now setup the actual file. This follows the same format as a repo-specific file but it is not tied to a repo.

```sh
$ touch ~/.gitignore
```

Then open it in your IDE. Use `code` instead `touch` above to open in VS Code.

The rest of this post covers the content you can add to that file.

## Temporary metadata files

Sometimes files you don't want to version get left off of a repo's ignore file. For example it is only created using a certain OS or IDE and so it doesn't cross your mind to ignore it.

Here's a way to ignore files without having to add them to all your repos and this is especially useful if you are working on someone else's repo and you use a different OS or IDE to them.

```sh
# Linux folder attributes (Dolphin) and PyCharm metadata.
.idea/

.directory/

# macOS folder attributes. 
.DS_Store

# Vim swap file.
.swp
```

The vim temporary file is a rare case - it is created when editing a file including when using vimdiff. It is easiest just to ignore it globally.

## Ignore local notes

The content of my global git ignore file means I can have these in a repo without having to ignore them in a project ignore file.

```sh
TODO
_TODO

NOTES
_NOTES

# Avoid just 'TEST' as sometimes 'test' is a valid directory in some projects.
_TEST
_TESTS
```

For example, I can text files in a directory (I don't both with `.txt` extension).

- `TODO`
- `foo/TODO`

Or add a directory of notes or work-in-progress.

- `_NOTES/foo.txt`
- `_NOTES/bar.py`
How to generate a heat map from your google location data
Tags: python, datascience
Published: 2020-09-06 11:29:26

# Introduction
It is known that Google tracks a lot of your data but many people don't know that you can actually download your data.

You can download your data here: https://takeout.google.com/

When I downloaded my location history I had a JSON file with about 14,000,000 lines and over 1,050,000 data points dating back to 2014.

Why not use this data?

# The Script
So I wrote a Python script that generates a heat map from this data. 

GitHub repo: [github.com/luka1199/geo-heatmap](https://github.com/luka1199/geo-heatmap)

The results look like this:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/k8s153ykv1rtqyl7o9bv.png)

To generate the heat map I used the Python library [Folium](https://python-visualization.github.io/folium/), which internally uses [Leaflet.js](https://leafletjs.com/).

Instructions on how to use the script are in the [README](https://github.com/luka1199/geo-heatmap/blob/master/README.md) file of the repo or below.

## Instructions

### 1. Install Python 3+

If you don't already have Python 3+ installed, grab it from <https://www.python.org/downloads/>. You'll want to download install the latest version of **Python 3.x**. As of 2019-11-22, that is Version 3.8.

### 2. Get Your Location Data

Here you can find out how to download your Google data: <https://support.google.com/accounts/answer/3024190?hl=en></br>
Here you can download all of the data that Google has stored on you: <https://takeout.google.com/>

To use this script, you only need to select and download your "Location History", which Google will provide to you as a JSON file by default.  KML is also an output option and is accepted for this program.

You can also import [GPS Exchange Format (GPX)](https://en.wikipedia.org/wiki/GPS_Exchange_Format) files,
e.g. from a GPS tracker.

### 3. Clone The Repository

On <https://github.com/luka1199/geo-heatmap>, click the green "Clone or Download" button at the top right of the page. If you want to get started with this script more quickly, click the "Download ZIP" button, and extract the ZIP somewhere on your computer.

### 4. Install Dependencies

In a [command prompt or Terminal window](https://tutorial.djangogirls.org/en/intro_to_command_line/#what-is-the-command-line), [navigate to the directory](https://tutorial.djangogirls.org/en/intro_to_command_line/#change-current-directory) containing this repository's files. Then, type the following, and press enter:

```shell
pip install -r requirements.txt
```

### 5. Run The Script

In the same command prompt or Terminal window, type the following, and press enter:

```shell
python geo_heatmap.py <file> [<file> ...]
```

Replace the string `<file>` from above with the path to any of the following files:

- The `Location History.json` JSON file from Google Takeout
- The `Location History.kml` KML file from Google Takeout
- The `takeout-*.zip` raw download from Google Takeout that contains either of the above files
- A [GPS Exchange Format (GPX)](https://en.wikipedia.org/wiki/GPS_Exchange_Format) file
Dotfiles - Shell Aliases
Tags: alias, aliases, dotfiles, productivity
Published: 2020-09-06 11:02:47

> Shell aliases for Bash or ZSH

See my full [.aliases](https://github.com/MichaelCurrin/dotfiles/blob/master/.aliases.sh) on GitHub.

## Storing aliases

Aliases can be set directly in the shell config.but I prefer to keep them in a separate file called `~/.aliases`. And then use it like this:

```sh
if [ -f ~/.aliases ]; then
  source ~/.aliases
fi
```

Here are some aliases.

## List

```sh
# List file and dir names vertically.
alias l1='ls -1 -F'
```
e.g.
```sh
$ cd ~
$ l1
Desktop/
Documents/
Downloads/
Dropbox/
Music/
Pictures/
Public/
Temp/
Templates/
Videos/
npm/
public_repos/
repos/
```

## Zipping

Here is how I handle zipping:

```sh
# Zip
alias tarz='tar czvf'
# Unzip
alias taru='tar xzvf'
```
e.g.
```sh
$ tarz foo.tar.gz fizz.txt buzz.py
$ taru foo.tar.gz
```

## Add confirmation when losing files

Force file operations to be _interactive_, which means I get a confirmation message to accept before I copy or move that would _overwrite_ a file, an whenever I delete a file.

```sh
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
```
e.g.

```sh
$ touch foo.txt
$ rm foo.txt
rm: remove regular empty file 'foo.txt'? y
$
```

## Jekyll

For Jekyll commands running through [bundler](https://bundler.io).

```sh
alias jek='bundle exec jekyll'
```
e.g. 
```sh
$ jek serve
```

## Python packages

I don't like installing packages in my global Python environment, especially by accident. So I set this up in my shell config. This flag is standard for Python.

```sh
export PIP_REQUIRE_VIRTUALENV=false
```

Then if I run this, I can an error to protect me.

```sh
$ pip3 install requests
ERROR: Could not find an activated virtualenv (required).
```
So then I activate my virtual environment. Or I override with `PIP_REQUIRE_VIRTUALENV=true` using my alias:

```sh
alias pip-user='PIP_REQUIRE_VIRTUALENV=false python3 -m pip'
```

```sh
$ pip-user requests
...
```


## Instant web server

I also find myself often starting a Python server in a directory.

So with this: 
```sh
alias pserver='python3 -m http.server'
```

I can just run:

```sh
$ pserver
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ..

```

## View aliases

To see all the aliases that are setup, run this:

```sh
$ alias
alias ag='alias | grep'
alias apt-i='sudo apt install'
...
alias jek='bundle exec jekyll'
alias l='ls -C -F'
alias l1='ls -1 -F'
...
```

That is a standard feature of `alias`, if not given any arguments.

I added my own feature like this for viewing all my **git aliases**. See that in my next post on Git Configs - [Part 4](https://dev.to/michaelcurrin/dotfiles-git-config-348o).

If you have any aliases to share or need help with your syntax, comment here.
Dotfiles - Shell Config
Tags: dotfiles, productivity, npm, bash
Published: 2020-09-06 10:54:40

> Content for Bash config `~/.bashrc` or ZSH config `~/.zshrc`

See my full [Shell config file](https://github.com/MichaelCurrin/dotfiles/blob/master/.shellrc.sh) on GitHub.

## OS flags

For any values in configs or aliases which are OS-specific, I found it useful to determine the OS with logic once-off and then reuse the flags.

```sh
IS_MAC=false
IS_LINUX=false

case "$(uname -s)" in
  Darwin*)
    IS_MAC=true
    ;;
  Linux*)
    IS_LINUX=true
    ;;
esac
```

That lets me then use the variable to perform OS-specific behavior. Here I add a Brew-installed Ruby gems path to the `PATH` value, just for macOS.

```sh
if [[ "$IS_MAC" == 'true' ]]; then
  export PATH="/usr/local/opt/ruby/bin:$PATH"
fi
```

## Setting PATH the smart way

Part of the standard setup of packages like Ruby, Go and Node is to  add a directory to your shell `PATH` variable so that executables can be found.

If I want to check the directory exists first, I could do this:

```sh
if [ -d '/usr/local/opt/ruby/bin' ];
  export PATH="/usr/local/opt/ruby/bin:$PATH"
fi
```

But I got tired of having that long syntax. So I made a function to do that, which I call like this:

```sh
prepend_path() {
  if [ -d "$1" ]; then
    export PATH="$1:$PATH"
  fi
}
```

Usage:

```sh
# Ruby gems
prepend_path /usr/local/opt/ruby/bin

# Go packages.
# Traditional path is '/usr/local/go/bin' or '/usr/bin'.
# I created ~/.local to use that rather.
prepend_path ~/.local/go/bin
```

## Executing local packages

When working on Node projects, you normally have to run a script like this in the shell:

```sh
$ ./node_modules/.bin/eslint
```

I'd rather just run this:

```sh
$ eslint
```

To get that behavior, I decided to add `./node_modules/.bin` to my `PATH` variable.

```sh
prepend_path_always() {
  export PATH="$1:$PATH"
}

prepend_path_always './node_modules/.bin'
```

Note that the values in `PATH` are read from left to right, so you must make sure your local packages are read before any global packages. In case you have say `eslint` installed locally and globally.


## View the `PATH`

Here is what my `PATH` value looks like.

```
$ split_path
/home/michael/.local/go/bin
/home/michael/.deno/bin
./node_modules/.bin
/home/michael/.local/bin
...
```

Note that the `PATH` value normally looks like this with colon separators, making it hard to read.

```sh
/home/michael/.local/go/bin:/home/michael/.deno/bin:...
```

So I created an alias called `split_path` which makes that more human-readable.

More about aliases in the next post in this series...
Use your lock screen as a business card - Weekend project
Tags: html, javascript, canvas, networking
Published: 2020-09-06 10:46:52

---
title: Use your lock screen as a business card - Weekend project
published: true
description: Wallpaper business card generator
tags: html, javascript, canvas, networking
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/55si0h4ohm5ppqkdrwkf.png
---

## Information

This is an old weekend project I made a few years ago in PHP, Today I rewrite the code to generate the wallpaper using only javascript.

In the fist version I was using PHP-GD to generate the background and Google Chart API to generate the QR code image, now I'm using javascript-canvas to generate the full image and qrious a javascript library to generate the QR via javascript.

I hope you find it useful for networking in your upcoming events.

## Demo

[https://vivirenremoto.github.io/idwallpaper/](https://vivirenremoto.github.io/idwallpaper/)

## Features

- Help the environment, you don't waste paper    
- Quick access, just turn on the phone
- It's an image, compatible with any phone
- You don't have to install any app

## Tecnologies

- javascript
- canvas
- qrious javascript library

## Source code

[https://github.com/vivirenremoto/idwallpaper](https://github.com/vivirenremoto/idwallpaper)

## Options

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9o0xeyxuj4p62nvg8dy6.png)
My First Github Workflow
Tags: actionshackathon
Published: 2020-09-06 10:30:37

### Greet and Stats!
My new github action follows a simple workflow: Whenever a user opens a pull request to the repository with the configured workflow, a comment is made on the PR with a greeting to the user and another comment with the statistics about the repository and PR are posted.
Used the github-scripts (https://github.com/actions/github-script) action to get the API and context to write my own script in the workflow.
It was a very fun exercise for me. Thankyou Dev Team for this cool contest!



### Submission Category: 
Maintainer Must-Haves


### Yaml File or Link to Code
https://github.com/KiranAkadas/WebTechnologies_PasswordSecurity/blob/master/.github/workflows/new.yml


### Additional Resources / Info
A sample of this can be found on this repo for any PR
https://github.com/KiranAkadas/WebTechnologies_PasswordSecurity

PS: I've started writing my own Github Action on my repository using JS, facing a few challenges and due to lack of docs, it's going slowly, but will publish it soon :)
Building online portfolio and profiles for personal brand
Tags: webdev, github, frontend, portfolio
Published: 2020-09-06 10:24:28

I was thinking a lot about what platform to use to write about tech related themes. After Codepen decided to move blogs to dev.to I decided to finally try it:)

I would like to focus one of my first posts on show examples of online portfolios/profiles. I will start with small list:

1. [Github readme](https://lnkd.in/eUup6B3)
2. [Github pages site](https://rebrand.ly/iigrekov-site)
2. [Stack overflow](https://lnkd.in/ejb72yc)
3. [Dev.to](https://lnkd.in/enbezww)
4. [Twitter](https://lnkd.in/eHnAfqQ)
5. [Codesandboxes](https://lnkd.in/e_Djim5)
6. [Codepen](https://lnkd.in/e_DtM54)
7. [LinkedIn](https://rebrand.ly/iigrekov)


It is most common platforms, which I encountered for the last couple of years. If you would like to share any platforms - feel free to add it in comments:)
Today I Learned: BST Traversal
Tags: python, algorithms, webdev, beginners
Published: 2020-09-06 09:54:48

# Problem Statement
Write three functions (in-order, pre-order, and post-order traversal) that takes in a Binary Search Tree (BST) and an empty array, traverse the BST add the node's value to the input array and return the array. 

# Sample Input

```
tree =        10
           /       \
         5          15
      /    \           \
    2       5           22
  /
1
```

# Sample Result

```
in_order = [1, 2, 5, 5, 10, 15, 22]
pre_order = [10, 5, 2, 1, 5, 15, 22]
post_order = [1, 2, 5, 5, 22, 15, 10]
```

# Code

```python
def in_order_traversal(tree, array):
    if tree is not None: 
        in_order_traversal(tree.left, array)
        array.append(tree.value)
        in_order_traversal(tree.right, array)
    return array


def pre_order_traversal(tree, array):
    if tree is not None: 
        array.append(tree.value)
        pre_order_traversal(tree.left, array)
        pre_order_traversal(tree.right, array)
    return array


def post_order_traversal(tree, array):
    if tree is not None: 
        post_order_traversal(tree.left, array)
        post_order_traversal(tree.right, array)
        array.append(tree.value)
    return array
```

# Notes
* N/A

# Credits
* Algoexpert for the problem statement
* XKCD for the cover image
how to push a array element in a single array object in react.js ? Help Plz
Tags: react
Published: 2020-09-06 09:45:44

```
let {postDetail} = useParams();
    const url = `https://jsonplaceholder.typicode.com/posts/${postDetail}`;
    const [details, setDetails] = useState([]);
    useEffect(()=>{
        fetch(url)
        .then(res => res.json())
        .then(data => {
            setDetails(data => [...data, {"image":`${data.id}`}]);
        })
        
    },[]);

```
Create cell【CakePHP】
Tags: php, cakephp
Published: 2020-09-06 09:22:29

#Introduction
Please watch over gently🙇‍♀️
I will write about cakePHP "cell"!

#How to use

- Create 'class' and 'template'  

[src/View/Cell/InboxCell.php]
```PHP
<?php
namespace App\View\Cell;

use Cake\View\Cell;

class InboxCell extends Cell
{

    public function display()
    {
      $hello = "hello!!!(*´ω｀*)";
      $this->set('sample', $hello);
    }

}

```

[templates/cell/Inbox/display.php]
```PHP
<div>
    message✨ <?= $sample ?> 
</div>
```

#use
On the "/templates/????/index.php"

The following description

`<?=$this->cell('Inbox::display');?>`


#display
http://〇〇/????
![スクリーンショット 2020-09-06 17.44.56](https://dev-to-uploads.s3.amazonaws.com/i/prftcjhwsqx24qbmqtck.png)

#A little more
Show what you get in the model

Assumption: You have a created model.This time 'tags'

[src/View/Cell/InboxCell.php]

```PHP
<?php
namespace App\View\Cell;

use Cake\View\Cell;

class InboxCell extends Cell
{

    public function display()
    {
      $this->loadModel('Tags');
      $tags = $this->Tags->find();
      $this->set('tags', $tags);
    }

}
```

[templates/cell/Inbox/display.php]
```PHP
<table>
  <?php foreach ($tags as $tag): ?>
    <tr>
      <td><?= $tag->title ?></td>
    </tr>
  <?php endforeach; ?>
</table>
```
 
Where you want to use↓

`<?=$this->cell('Inbox::display');?>`

display

![スクリーンショット 2020-09-06 18.15.20](https://dev-to-uploads.s3.amazonaws.com/i/qtcin4o7emefi0mr7qz8.png)

#Overall picture
![スクリーンショット 2020-09-06 18.31.39](https://dev-to-uploads.s3.amazonaws.com/i/913yvqrxewebww3y3vuz.png)


#Don't forget the escape
I forgot,
So I will not forget
↓
[templates/cell/Inbox/display.php]
```PHP
h($tag->title)
```
 

[reference](https://book.cakephp.org/4/ja/views/cells.html)
P3 - Personal Porting Project - Update
Tags: personal, project, docker, productivity
Published: 2020-09-06 09:17:08

So little follow up on my Personal Project.

##Progress

I've added two more Languages: Ballerina and Rust. Both of them presented unique challenges but very satisfying to finally get something working.

**Ballerina**, always stood out to me as an 'modern' language. Previous studies using Java allowed me to get a good start on Porting over the program but only got me so far. 

Dealing with  `@tainted` and `@untainted` annotations stumped me when dealing with the Error handling, so I feel my port doesn't truly represent how Ballerina _should_ be written. 

With that, I didn't use the `@docker` annotation - which I feel that's where Ballerina excels as a language - but that's just to be able to build and run with Docker Compose.

**Rust**. This was a whole new level of learning for me. I started off wrong and ended up taking a lot longer to Port compared to the other Languages - so far. 

I restarted probably about 5 or 6 times just with the basics of opening a File, reading lines, etc. Not realising some examples of how to do such linear actions had been deprecated as Rust has evolved.

But it did then present me with an issue, I presented my Tasks for the Program in a abstract manner that's not easily implemented in Code. I updated these into smaller, more manageable Tasks and that allowed finish porting into Rust.

Once, I finished and complied the Rust code into the single Binary and saw how small the entire application and Docker Image could be, I was amazed.

## Future Plans

Definitely aiming to add in Ruby soon. With possibility of Swift and see what if I can deal with another 2 more, to get a total of 9 different Languages.

Still need to refactor, add tests and HTML & CSS.

{% link tomowatt/p3-personal-porting-project-12ba %}

{% github tomowatt/P3 no-readme %}
In case of doubt, ask for clarification
Tags: humour, communication, softskills
Published: 2020-09-06 09:16:16

---
title: In case of doubt, ask for clarification
published: true
canonical_url: https://danlebrero.com/2020/04/15/on-the-importance-of-clear-communication-in-devops/
tags: Humour,Communication,softskills
description: Your yearly reminder of why to use a clear and precise language and to ask to clarification when your teammates do not.
feature-image: /images/blog/importance-of-clear-communication.jpg
cover_image: https://danlebrero.com/images/blog/importance-of-communication/horse-talking.jpg
---

As an example of what not to do, here I am earlier this year with a teammate, doing some Ops work ([Unilog](https://github.com/akvo/akvo-unified-log) is a backend service, [akvoflow-87](https://github.com/akvo/akvo-flow/) is a tenant of another backend service that depends on the Unilog):

![Not so clear communication](https://danlebrero.com/images/blog/importance-of-communication/importance-of-clear-communication.jpg "Not so clear communication")

I hope it is not obvious to you, as it was not for me, but what my teammate was actually asking was:
> Can I completely decommission Unilog forever?

But what I understood was:
> Can I stop Unilog for a minute?

Result: a massive slowdown of the whole system for a few hours.

We have been talking about decommissioning that Unilog service the whole week, so it even crossed my mind that maybe it was related to it, I thought *he surely cannot be asking about decommissioning it*.

Silly me for not asking.
Create a new repo from your command line
Tags: github, tutorial, beginners
Published: 2020-09-06 09:09:20

## Assumptions
- You have the Github CLI installed
- You've set up your Github username, password, SSH keys etc on your machine

## Command
```
curl -u USERNAME:PASSWORD https://api.github.com/user/repos -d '{"name":"REPO NAME"}'
```

That's it! You can create a new repository in your command line this way. Then, perform `git remote add origin git@github.com:USERNAME/REPONAME.git` like you always do, and push your work. :)
Messaging
Tags: 100daystooffload
Published: 2020-09-06 08:57:43

Language is a key part of my work. Junior engineers can often get frustrated at how we need to make minute changes to their writing. English is a language that seems to have many ways of saying the same thing, but sometimes the difference between similar words is crucial.

I was reminded of this when reading the news about the arguments made by "unnamed government sources" wanting companies to repopulate their offices so that those workers can go back to saving the economy. By saving the economy they presumably mean spending money on commuting and buying lunch in city centres (i.e. London), because the counter-argument is that many people have been working equally as hard (if not harder) from home and the benefits that can be gained by being in the same place are largely eroded by the needs to avoid being confined in small spaces with other people. As it was put it in a more succinct and brutal way by [Marina Hyde in the Guardian](https://www.theguardian.com/commentisfree/2020/aug/28/boris-johnson-home-nhs-government-office-commute), rather than "Stay at home, protect the NHS, save lives" [^1], they would like us to "Leave home. Forget the NHS. Save Pret."

Anyway, what I noticed in particular is that the term used to advertise that workplaces or restaurants or gyms are suitable for people to return to is not that they are "safe", but that they are "COVID secure". This raises two questions:

1. What does "secure" mean against a virus?
2. Why not say "safe"?

*I'm publishing this as part of 100 Days To Offload. You can join in yourself by visiting [https://100daystooffload.com.](https://100daystooffload.com)*

[^1]: Let's not even mention the problems with "Stay alert, control the virus, save lives" that replaced it, or the patronising tone that three-part slogans in general imparts on the public.