teleren/devto huggingface dataset:
Auto Add Date to Git Commit Messages
Tags: git, hook, automation, vsc
Published: 2020-09-25 18:30:50

---
title: Auto Add Date to Git Commit Messages
published: true
date: 2020-05-05 00:00:00 UTC
tags: git, hook, automation, vsc
canonical_url: https://tech.serhatteker.com/post/2020-05/auto-add-date-git-commits/
---

In previous post — [Auto Add Git Commit Message], we saw how to add auto text into commit messages.

Now I want to use a concrete commit message template for all __Git__ `commits`. It will be like: `$yearnum/$weeknum/$daynum $unix_timestamp | version:`.

Yes, adding _date_ to a commit would be unnecessary since __Git__ already logging date and you can see them with `git log`.

However I am going to use this template for my __Journal__, therefore for lookups this template makes things easy and quick.

For _message_ I am going to use linux's default `date` —`/bin/date`. You can find below `$MESSAGE` that I will add to `commits`:

```bash
# Nums
YNUM=$(date +%y)
WNUM=$(date +%U -d "$DATE + 1 week")
DAYNUM=$(date +%w)
# Unix timestamp
UNIX_SEC=$(date +%s)

MESSAGE="Add y$YNUM:w$WNUM:d0$DAYNUM $UNIX_SEC | ver:"
```

To append this every commit message use below code:

```bash
COMMIT_MSG_FILE=$1

echo "$MESSAGE" >> $COMMIT_MSG_FILE
```

So when you `git commit` it appends our _message_ and it will be like: "_Add y20:w21:d02 1588701600 | ver:_"

In this approach there is one thing that I want to improve: Instead of _append_ I want _prepend_ _message_ so it will be on _first line_.

In order to prepend _message_ to commit we will use `sed` and `regex`:

```bash
sed -i "1s/^/$MESSAGE/" $COMMIT_MSG_FILE
```

In the end whole _solution_ can be found below:

`.git/hooks/prepare-commit-message`

```bash
#!/bin/sh
#
# A git hook script to prepare the commit log message.
#
# It adds below date message to commits:
# $yearnum/$weeknum/$daynum $unix_timestamp | version:
#
# To enable this hook, rename this file to "prepare-commit-msg".
# Add it below '.git/hooks/' and make it executable:
# chmod +x prepare-commit-msg


COMMIT_MSG_FILE=$1

# Nums
YNUM=$(date +%y)
WNUM=$(date +%U -d "$DATE + 1 week")
DAYNUM=$(date +%w)
# Unix time in milisecond
UNIX_SEC=$(date +%s)

MESSAGE="Add y$YNUM:w$WNUM:d0$DAYNUM $UNIX_SEC | ver:"


sed -i "1s/^/$MESSAGE/" $COMMIT_MSG_FILE
```

All done!



<!-- References -->
[Auto Add Git Commit Message]: https://tech.serhatteker.com/post/2020-04/auto-add-git-commit-message/
[Git Hooks]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
From Ops to Oops: Hear stories of our biggest serverless fails
Tags: serverless, events, meetups, virtual
Published: 2020-05-04 23:35:22

---
title: From Ops to Oops: Hear stories of our biggest serverless fails
published: true
description: Sometimes Serverless goes great sometimes... it doesn't
tags: serverless, events, meetups, virtual
---

[I'm hosting a meetup next week!](https://t.co/usGFLmeWyT?amp=1)

### May 14 @ 3:00 PM PST

What happens when keeping it real on serverless goes really wrong?

We’ve all had that “oh no” moment. You just pushed an api call with “localhost” in the URL. The sinking realization that a runaway Lambda function has driven up your AWS bill or you forgot to adjust default timeout limits or a third-party service keeps failing—the list of horrors goes on and on.

There’s something cathartic (and useful) about discussing and learning from our serverless failures. 

Talks by:
[Sheen Brisals](https://twitter.com/sheenbrisals?lang=en), LEGO
[Jeremy Daly](https://www.jeremydaly.com/), ServerlessChats
[Erica Windisch](https://twitter.com/ewindisch), New Relic

[Join us for an evening of serverless failures from your favorite developers. Registration is free!](https://t.co/usGFLmeWyT?amp=1)
Stack overflow  - python folium
Tags: python, datascience
Published: 2020-05-04 23:27:48


I just published two post on medium.

https://medium.com/bili%C5%9Fim-hareketi/starbucks-ma%C4%9Faza-konumlar%C4%B1n%C4%B1-harita-%C3%BCzerinde-g%C3%B6rselle%C5%9Ftirelim-1a7c389bad3c?sk=992a643e01dde2a2718a9013f0d4311c

https://medium.com/bili%C5%9Fim-hareketi/stack-overflowu-takip-etmek-ead6a0e00e29

https://medium.com/@blalyasar
My First Blog! 
Tags: javascript, ES6, blog, gatsby
Published: 2020-05-04 23:24:53

Took a while, but we're here! I was more focused on the Front End of my portfolio that I completely left out publishing blogs of everyday things that happened while developing the infrastructure of my portfolio.

Some of those include learning and implementing GraphQL while using Gatsby.js, creating and rendering both Markdown files and HTML files while using Gatsby Node, and using cookies to make sure animations don't overlap while on this site.

First up, I would like to provide some Javascript tools I've been using lately that has helped me code neat, efficient code.

<div style="text-align:center;">
  <h3>Shorthand - using Sets with&nbsp;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set" target="_blank">ES6</a>
  </h3>
</div>

![Removing duplicates from array](https://dev-to-uploads.s3.amazonaws.com/i/k2ijxiw7551wgna78cdy.png)
<div style="text-align:center;">
  <h3>In a function object</h3>
</div>

![Removing duplicates from array, function object](https://dev-to-uploads.s3.amazonaws.com/i/9mxmd6apbfqgcpzvamst.png)

<div class="signature">
  <p>
    -Cesar C.
  </p>
</div>
First full-stack side-project online
Tags: webdev, showdev
Published: 2020-05-04 23:11:17

---
title: First full-stack side-project online
published: true
description: I pushed to production my first side-project
tags: webdev, showdev
cover_image: "https://dev-to-uploads.s3.amazonaws.com/i/zkw8akg16xbpbnfeb4e8.png"
---

Hello everyone, I published my first side-project which you can see here
[Devcamper](https://devcamper.eduardoedi.com/)

The back-end part was made in the course hosted by Brad Traversy(Traversy Media).
[Node.js API Masterclass With Express & MongoDB](https://www.udemy.com/course/nodejs-api-masterclass/) - course link for any of you interested.

I've added some new features, the front-end was made by me.

It was made with MEAN stack, also using AWS S3, Socket.IO, nodemailer, mapquest. It is deployed on heroku.

For now I consider it v1.0, I have a lot ideas yet to implement.

The app is about coding bootcamps, the main gist is that you can find a bootcamp, and use the email to contact them for enrollment(might implement user<->owner communication), and after you complete the bootcamp, or you already completed the bootcamp, you can post a review.

The app has two main user roles 
1.Publisher - person who owns a bootcamp
2.User - person who is looking to enroll in a bootcamp.

Hope you like it.
Don't declare your Variables at the top
Tags: refactoring, cleancode, csharp, dotnet
Published: 2020-05-06 07:11:52

---
title: Don't declare your Variables at the top
published: true
date: 2020-05-04 23:00:00 UTC
tags: refactoring, cleancode, csharp, dotnet
canonical_url: https://gsferreira.com/archive/2020/05/dont-declare-your-variables-at-the-top/
---

When I start learning to code, I was taught to declare variables at the top of the code. I followed it for a long time before start questioning that absolute truth.

We are writing code for others to read. So, we shouldn't present our characters too early in the story. [Our working memory handle a strict number of things at a given time](https://www.livescience.com/2493-mind-limit-4.html).

![Working memory overflow](https://gsferreira.com/images/dont-declare-your-variables-at-the-top-memory-overflow.png)

Keeping related concepts closer, we are reducing the cognitive load. This will lead us to clean and simple code.

You can find evidence of that, in Design Principles. By using the [Proximity principle](https://www.interaction-design.org/literature/article/laws-of-proximity-uniform-connectedness-and-continuation-gestalt-principles-2), we form groups by keeping things closer.

This is one of the reasons why **I run away from global variables.**

Besides the cognitive load reduction, there's a positive side effect from following this. **I use this as a warning sign to extract a function. Whenever you can't keep the variables close to where they are used and to the top, extract it.**


So, instead of doing this:

![Example 1](https://gsferreira.com/images/dont-declare-your-variables-at-the-top-example1.png)


You can do this:

![Example 2](https://gsferreira.com/images/dont-declare-your-variables-at-the-top-example2.png)


And then refactor to this:

![Example 3](https://gsferreira.com/images/dont-declare-your-variables-at-the-top-example3.png)
The internet is wrong about JWT
Tags: discuss
Published: 2020-05-04 22:41:33

---
title: The internet is wrong about JWT
published: true
description: 
tags: #discuss
---

It's the bit where you use localStorage to store it. It's vulnerable to XSS yet there are a lot of articles out there again and again using localStorage. 

The problem is, not just articles, but packages like django-rest-simplejwt and solutions like saleor are using it this way (for the record, Saleor has this as a high priority issue for the next release). It's not only these, the default behavior for almost every framework out there is the same.

Shouldn't the default behavior be an Http-only cookie returned rather than a json object containing the access and refresh token? Because if it's not secure, why do I even need it as plain text?

What do you think?
Rebasing a PR train does not have to be a pain
Tags: git
Published: 2020-05-04 22:37:20

This one will probably be obvious for most of the readers, but I got this lightbulb 💡 moment only just a week ago.

**A Pull Request (PR) train** is when you create a PR that is dependent on another PR, that is dependent on another PR ... and so on. Therefore first "carriage" of the PR train points to `master`, second carriage points to first carriage, third points to second, etc.

This method of chopping work into smaller pieces has a great benefit that the _diff_ of each _Pull Request_ can be very small and therefore should be easy to review.

The problem of this approach is that if you need to change one of the earlier carriages (for example because of a feedback on your PR), then **all** the later carriages might have a _merge conflict_. Similar can happen if you just need to _rebase_ your whole _PR train_ on the latest `master`.

## The aha! moment

Until last week I was struggling with this because during the rebase of each individual carriage I had to resolve it's own conflicts _and_ the conflicts of _all_ the carriages before.

The problem was that I was simply doing a normal rebase, which takes all the commits from the current carriage and all the carriages before. So I needed to resolve the same conflicts over and over again:

![PR train with merge conflict](https://dev-to-uploads.s3.amazonaws.com/i/m6z8jno5a3b328u400of.png)

One of the methods of how one can improve the rebasing situation is to realise that: "each carriage cars only about it's own commits". Not the commits of the carriage(s) before. Those are not important and can be **dropped**.

This can be done via an **interactive rebase**:

![Where to find interactive rebase in Fork](https://dev-to-uploads.s3.amazonaws.com/i/5d64p8os6ces8jxy8rdj.png)

And simply by selecting `drop` for the commits that are not relevant:

![Dropping commits in interactive rebase](https://dev-to-uploads.s3.amazonaws.com/i/leheavgnfvyw2be2i0sz.png)

And that's it.

## Conclusion

By dropping the commits during a rebase that are not relevant in our current PR, we are making our life easier by making sure that the same merge conflicts have to be resolved only **once**.

-----

Photo by [Jack Anstey](https://unsplash.com/@jack_anstey?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on Unsplash
Does a same-origin cookie work in a subdomain
Published: 2020-05-04 22:33:20

---
title: Does a same-origin cookie work in a subdomain 
published: true
description: 
tags: 
---

Let's say the front-end is hosted in Netlify with domain.com and the backend in a VPS with api.domain.com. 
For example: Django session authentication, can I get this to work like this?
Fixing "groot must be grub root device" on ibmcloud
Tags: ibm, grub, ibmcloud, reboot
Published: 2020-05-04 22:19:43

Some images on ibmcloud have an issue when installing new kernels (and thus rebuilding the initramfs and grub config files).


```bash
# apt-get upgrade
...
Processing triggers for initramfs-tools (0.130ubuntu3.9) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-42-generic
I: The initramfs will attempt to resume from /dev/vdc
I: (UUID=083a8bfd-95a8-4808-bd75-ed3c1be04dd4)
I: Set the RESUME variable to override this.
Setting up ubuntu-server (1.417.4) ...
Processing triggers for linux-image-4.15.0-99-generic (4.15.0-99.100) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.15.0-99-generic
I: The initramfs will attempt to resume from /dev/vdc
I: (UUID=083a8bfd-95a8-4808-bd75-ed3c1be04dd4)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.d/x-grub-legacy-ec2:
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
uuid not supported. update 'groot' in /boot/grub/menu.lst

groot must be grub root device (ie '(hd0)'). not 'LABEL=cloudimg-rootfs'

run-parts: /etc/kernel/postinst.d/x-grub-legacy-ec2 exited with return code 1
dpkg: error processing package linux-image-4.15.0-99-generic (--configure):
 installed linux-image-4.15.0-99-generic package post-installation script subprocess returned error exit status 1
Processing triggers for ureadahead (0.100.0-21) ...
Errors were encountered while processing:
 linux-image-4.15.0-99-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
```

Ooof. Very annoying.

Until we get a fix everywhere, you can fix this very easily yourself. 

Edit: `/boot/grub/menu.lst`

Find this section:
```
...
## default grub root device
## e.g. groot=LABEL=cloudimg-rootfs
# groot=LABEL=cloudimg-rootfs

...
```

Change `# groot=LABEL=cloudimg-rootfs` to `# groot=(hd0)` (leaving the comment)

Then have the package manager try again

```
# apt-get install -f
```

This should succeed without issue. Then you can reboot to test the change

```
# reboot
```
Day 130 : Power
Tags: hiphop, code, coding, lifelongdev
Published: 2020-05-04 22:12:38

_liner notes_:
- Saturday : Had a special guest on this week's radio show. My co-host made his return. Went pretty well. Had a great time. The recording is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of Big Boi from OutKast retweeting my tweet about the 26th Anniversary of their debut album Southernplayalisticadillacmuzik ](https://dev-to-uploads.s3.amazonaws.com/i/nqse5issicy9vy9s04yh.jpg)

- Sunday : Was pretty productive. Did my post radio show work like setting up the email blast and doing some social media posts. Paid all my bills for the month. Went to my folks place to look for my old mic and webcam to use a backup for a presentation I have coming up. Did some design and coding work for a side project. Then I watched the new episodes of "Killing Eve" and "Rick and Morty".

- Professional : Woke up not feeling well. Had a meeting with my manager and he said to make sure to get some rest and feel better. So yeah, basically stayed in bed and didn't do as much as I wanted. Just worked a little on my slides.

- Personal : Like 30 minutes after I was done with my work day, my power went out. Looks like it was my whole neighborhood. Got a text message from the Power company saying that the power outage impacts like 1800 people and estimates the power to return in like 3 hours! Awesome. Found out that the generator I bought can run my modem and router, so that was good. That's how I'm able to post this blog.

![The plains of Thorp, Washington State with a single tree](https://dev-to-uploads.s3.amazonaws.com/i/3mz7zsq7w89j4y436xiu.png)

So we'll see how long the power outage goes for. Hopefully not too long. Going to see if the generator can power my microwave so I can warm up some dinner.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube X3cjN5LnV2s %}
CodeStream 7 -- in-editor Code Reviews
Tags: codereview, vscode, jetbrains
Published: 2020-05-04 22:02:08

---
title: CodeStream 7 -- in-editor Code Reviews
published: true
description: CodeStream 7 allows you to request feedback and review code without leaving your IDE
tags: code review, vscode, jetbrains
---

I've been an engineer for 30+ years, and an entrepreneur for the last 25. The one thing I've always wanted was more communication among the developers on a team, so we founded CodeStream to try to fix that. Our mission is to make it easier for developers to talk about code, and CodeStream 7 is probably our biggest release to date:

1. With one command, request feedback on a snapshot of your repo, including uncommitted & unpushed code, allowing you to verify that your work-in-progress is on the right track. (You can also do it the old-fashioned way by committing & pushing at the end of your dev sprint, of course)
2. Review teammates’ code in your IDE, with full source tree context, your favorite keybindings, jump-to-definition, etc.
3. Comments on reviews are visible in your IDE as source code annotations after merging, creating a historical record of discussions and decisions.
4. Live View allows you to (optionally) see your teammates’ local changes at-a-glance, and highlights potential merge conflicts pre-commit.

These features are available today for VS Code and JetBrains editors, with more editor support to come. Companies like Zoom, Okta, Intuit and Salesforce are on board.

It's free to try, free for open source projects, and free for educational use. I'd love to hear any feedback you all may have. Thanks!

https://codestream.com/
csh - simple helper for urxvt
Tags: urxvt, linux
Published: 2020-05-04 21:54:00

---
title: csh - simple helper for urxvt
published: true
description: Change terminal background color and transparency during SSH connection
tags: urxvt, linux
conver_image: https://dev-to-uploads.s3.amazonaws.com/i/i8jbil2gxyvsvpqqvzl7.png
---

This shell script provides quick SSH shortcuts, and displays a configurable terminal background color while connected.

`!/bin/csh`
```bash
#!/bin/bash
#
# cssh: Color SSH helper
#
# Author: Mitch Jackson <mitch@mitchjacksontech.com
# Copyright: 
#
# Set the terminal background color and transparency before
# making an SSH connection, then resets them when the connection closes
#
# Allows for configuring different background colors per host,
# along with connetion aliases

# background color and opacity value to use during the session
CONN_BGCOLOR="#330000"
CONN_OPACITY=85

# background color and opacity to return to after the session ends
EXIT_BGCOLOR="#000000"
EXIT_OPACITY=70

# Connection Definitions:
#
# Define a shortname for each connection below
case $1 in
  box1)
    SSH_HOST="box1.lion.land"
    ;;
  box2)
    SSH_HOST="10.0.0.2"
    CONN_BGCOLOR="#002200"
    ;;

  *) # Catch-all
    SSH_HOST="$1"
    CONN_BGCOLOR="#000333"
    ;;
esac

printf '\33]11;%s\007' "[$CONN_OPACITY]$CONN_BGCOLOR"
command ssh $SSH_HOST $2 $3 $4
printf '\33]11;%s\007' "[$EXIT_OPACITY]$EXIT_BGCOLOR"

```

Also, a simple script to set the terminal background color and opacity at any time

`!/bin/tglow`
```bash
#!/bin/bash
#
# tglow: Set terminal background and opacity
#
# Author: Mitch Jackson <mitch@mitchjacksontech.com
# Copyright: Nope

function usage() {
  echo
  echo "tglow: set terminal background and opacity"
  echo
  echo "    usage: tglow 30 green"
  echo "           tglow 95 \"#333000\""
  echo
  exit 1
}

if [[ -z "$1" ]] || [[ -z "${2+x}" ]]; then
  usage
fi

printf '\33]11;%s\007' "[$1]$2"

```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rd0qy5cdznevm1xm3mlg.png)
Docker Compose Explained with 3 Microservices(Angular, Spring Boot, PostgreSQL)
Tags: dockercompose, microservices, springboot
Published: 2020-05-04 21:00:35

I want to share the video that we have made to explain about how Docker Compose works and how it will simplify the deployment of 100s of microservices with one command. You can learn complete architecture of Docker Compose in this video.

Please check the link: https://www.youtube.com/watch?v=ZZ2Llh4NhaY

{%youtube ZZ2Llh4NhaY %}
What’s your alternative solution? Challenge #34
Tags: challenge, javascript, codenewbie, learntocode
Published: 2020-05-04 20:54:34

# About this series

This is series of daily JavaScript coding challenges... for both beginners and advanced users.

Each day I’m gone present you a very simple coding challenge, together with the solution. The solution is intentionally written in a didactic way using classic JavaScript syntax in order to be accessible to coders of all levels.

Solutions are designed with increase level of complexity.

## Today’s coding challenge

```
Create a function that will add two positive numbers of indefinite size. The numbers are received as strings and the result should be also provided as string.

```

(scroll down for solution)

## Code newbies

If you are a code newbie, try to work on the solution on your own. After you finish it, or if you need help, please consult the provided solution.

## Advanced developers

Please provide alternative solutions in the comments below. 

You can solve it using functional concepts or solve it using a different algorithm... or just solve it using the latest ES innovations.

By providing a new solution you can show code newbies different ways to solve the same problem.

## Solution

```javascript
// Solution for challenge30b

var n1 = "2909034221912398942349";
var n2 = "1290923909029309499";
var sum = add(n1, n2);

println(n1);
println(n2);
println(sum);

function add(sNumber1, sNumber2)
{
    var maxSize = Math.max(sNumber1.length, sNumber2.length);
    
    var s1 = sNumber1.padStart(maxSize, "0");
    var s2 = sNumber2.padStart(maxSize, "0");

    var s = "";
    var carry = 0;
    
    for(var i = maxSize - 1; i >= 0; i--)
    {
        var digit1 = parseInt(s1[i]);
        var digit2 = parseInt(s2[i]);
        
        var sum = digit1 + digit2 + carry;
        var digitSum = sum % 10;
        carry = sum >= 10 ? 1 : 0;
        
        s = digitSum.toString() + s;
    }
    
    if (carry > 0)
        s = carry + s;
    
    return s;
}

```


To quickly verify this solution, copy the code above in this coding [editor](https://codeguppy.com/code.html) and press "Run".

> Note: The solution was originally designed for [codeguppy.com](https://codeguppy.com) environment, and therefore is making use of `println`. This is the almost equivalent of `console.log` in other environments. Please feel free to use your preferred coding playground / environment when implementing your solution.