teleren/devto huggingface dataset:
How to implement a signal handler in Go
Tags: go
Published: 2018-02-27 12:10:48

---
title: How to implement a signal handler in Go
published: true
description: How to implement a signal handler in Go
tags: go
---

This article explain "How to implement a signal handler in Go".  
Also, I introduce a small library I made.

## Introduction

This implement is assumed as follows.

- Subscriber in PubSub
- Show shutdown message
- etc...

If knowing how to implement signal handlers, you can create programs with diversity in Go.

## How to implement

The main points are as follows for implement.

- Catch signal
- Wait for caught signal

### Catch signal

First, let's write program for catch signal.  
Use "chan" for catch signal.

```go
package main

import (
    "os"
    "os/signal"
)

func main() {
    signalCh := make(chan os.Signal, 1)
    signal.Notify(signalCh, os.Interrupt)
    <-signalCh
}
```

This program is so simple.  
Create os.Signal channel, and Receive os.Interrupt(= syscall.SIGINT) notify used signalCh.
As a side note, `<-signalCh` is wait for signalCh receive interrupt signal.

### Wait for caught signal in goroutine

Since you can not do anything until you receive a signal, improve this program so that you can receive a signal with goroutine.

```go
package main

import (
    "os"
    "os/signal"
)

func main() {
    doneCh := make(chan struct{})

    signalCh := make(chan os.Signal, 1)
    signal.Notify(signalCh, os.Interrupt)

    go receive(signalCh, doneCh)

    <-doneCh
}

func receive(signalCh chan os.Signal, doneCh chan struct{}) {
    for {
        select {
        // Example. Process to receive a message
        // case msg := <-receiveMessage():
        case <-signalCh:
            doneCh <- struct{}{}
        }
    }
}
```

Execute the receive function using goroutine.  
The receive function uses for and select and continues to move until you catch the signal.  
When catching a signal, it sends an empty structure to doneCh and tells you that you caught the signal.

As an example, in the case of PubSub, we write a process to catch the message with the receive function.

# Investigation

I investigated whether there is a library that can easily implement signal processing.

I found this library.

https://github.com/vrecan/death

However, in this library, it was troublesome to generate structure objects and create fixed structure methods.

# Create

Therefore, I made a library called Tebata（手旗）.

https://github.com/syossan27/tebata

Tebata can easily and flexibly create signal handler.

```go
func main() {
    doneCh := make(chan struct{})

    t := tebata.New(os.Interrupt)
    t.Receive(func(ch chan struct{}){
        fmt.Println("Catch signal!")
        ch <- struct{}{}
    }, doneCh)

    <-doneCh
}
```

Specify the signal you want to catch in the argument of New function.  
Then, specify the function and argument you want to execute as the argument of the Receive function.  
Only this.

If you want to implement a signal handler please try this library.
TIL: How to debug cron jobs
Tags: todayilearned
Published: 2018-02-27 16:58:09

---
title: "TIL: How to debug cron jobs"
published: true
tags: todayilearned
canonical_url: http://ariera.github.io/2018/02/27/til-how-to-debug-cron-jobs.html
---

Today I learned how to properly debug cron jobs, thanks to [https://serverfault.com/a/85906](https://serverfault.com/a/85906).

They key is to recreate the correct environment in which your scripts get executed. I’m going to do this for `root` but you can do this with every user.

First: edit your crontab and add one line

```
crontab -e
* * * * * /usr/bin/env > /root/cron-env
```

Once it has had the chance to execute once you can remove it.

Second: let’s create a new script called `run-as-cron` that will run your scripts with the correct environment cron is running.

```
cd /root
touch run-as-cron
chmod +x run-as-cron
vim run-as-cron
#!/bin/bash
/usr/bin/env -i $(cat /root/cron-env) "$@"
```

Finally, debug your problematic script like this:

```
/root/run-as-cron /the/problematic/script --with arguments --and parameters
```
Web Dev attempting Photography - Any Advice?
Tags: photography, discuss, offtopic
Published: 2018-02-27 01:03:05

---
title: Web Dev attempting Photography - Any Advice?
published: true
description: I have interest in photography and have the means to get a few beginner gadgets to start. I'm currently full time employed as a frontend web dev. However wishes to take on photography as part time.
tags: photography, discuss, offtopic
---

I have always had an interest in photography. Now, I have the means to get a few beginner gadgets to start. I'm currently full time employed as a frontend web developer. However, I wish to take on photography as part time.

Any tips on what I should keep in mind?

Perhaps, someday, the photography endeavor might become my full time job, however until then, what steps can I take?
Perl6 in production: MyJudo.net
Tags: perl, perl6
Published: 2018-08-21 09:14:12

---
title: Perl6 in production: MyJudo.net
published: true
tags: perl,perl6
canonical_url: https://lancewicks.com/2018/02/26/perl6-in-production-myjudo-net/#utm_source=rss&utm_medium=rss
---

Recently there was a thread online asking who was using the new Perl6 Programming Language in production; so I thought I would share a few thoughts as I do actually use Perl6 on a live, in production website: [MyJudo.net](http://myjudo.net?utm_source=rss&utm_medium=rss).

The site is a online training tracker for the Olympic Sport of Judo. Imagine it as a Strava  or FitBit for Judo.

I, outside of Perl, am a Judo coach; so I started the project for my own desire to record what I teach in the sessions I teach.  
I started the site as an excuse to learn Perl6 more deeply than the “Hello World” type experiments I had done previously. I do not consider myself a Perl6 developer (yet), I think I write Perl6 with a strong Perl5 accent. Meaning I do tend to write it in much the same way I write my Perl5 and occasionally use more Perl6 syntax.

This on the whole is a workable way of developing; with only the odd occasion where Perl6 really object to my style. It’s flexible that way. I have to say that knowing Perl5 may well be a impediment not a advantage to learning Perl6. Although they are related languages Perl6 is not an update of Perl5; it is a new language.

Perl6 is a multi-faceted beast; it combines programming styles and features from it’s long development cycle; and that makes it both amazing and hard to learn.

 

MyJudo is built on the Bailador web framework for the Perl6 programming language. Bailador is a route based framework; similar to Dancer in Perl5. It works pretty well and I have no complaints; except maybe that like many things in a young language like Perl6 there are some missing parts. It can be frustrating sometimes to work with Perl6. That said one of the rewards is the community is small and often you end up in direct contact with key developers. And of course it’s new and it’s nice to be on the cutting edge sometimes!

 

 

I have found Perl6 and Bailador easy to be productive in as a developer working on a “side project”. It is simple and the error messages when I mess up are helpful and generally clear.  
The supporting modules from [modules.perl6.org](https://modules.perl6.org?utm_source=rss&utm_medium=rss) are… limited. There simply is not the depth of Perl5’s CPAN  or NodeJS’ NPM.

 

I am maintaining MyJudo and growing the features slowly. I admit I may also reimplement it in Elixir as I’d like to learn that language. My gut says it is easier for me to write Perl6/Bailador rather than say NodeJS/Express. Perl5/Dancer2 would I am sure be fastest for me; but I want to explore new things and MyJudo has and is allowing me to do that with Perl6.
Self-Deprecation Needs to Stop 🛑
Tags: discuss, career
Published: 2018-02-26 22:41:09

---
title:  Self-Deprecation Needs to Stop 🛑
published: true
description: My thoughts on self-deprecation in tech. 
tags: #discuss #career
---

It's common for someone in the tech community to preface themselves or their accomplishments with self-deprecating remarks. For example, Stephanie Hurlburt was trying to give visibility to women who were junior coders by retweeting their technical blog posts. 
{% twitter 936530247092133890%}

Later she noticed:
{% twitter 936783454854823936%}
    


I very much agree with this. This kind of self-deprecating behavior is ingrained in our industry. Honestly, I think it's almost encouraged because many articles downright romanticize [Imposter Syndrome](https://en.wikipedia.org/wiki/Impostor_syndrome) and the [Dunning–Kruger Effect](https://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect).  

Self-deprecation is very damaging especially if you are part of an [underrepresented](https://www.google.com/search?q=underrepresented&rlz=1C1GCEA_enUS775US775&oq=underrepresented&aqs=chrome..69i57j0l5.1109j0j7&sourceid=chrome&ie=UTF-8) and [marginalized](https://www.google.com/search?q=marginalized&rlz=1C1GCEA_enUS775US775&oq=marginalized&aqs=chrome..69i57j0l5.1085j0j9&sourceid=chrome&ie=UTF-8) community. When you're  part of an underrepresented and marginalized community a lot of times you are already being undervalued by others when you walk in the room. Your voice isn't viewed as that important. It's sad but it's true. So if you self-depreciate yourself it further weakens your voice.

##Some Advice

#### 1. Stop saying these words when describing yourself or your accomplishments. **These words are now under BAN 👇**

{% twitter 936787995738365952%}

#### 2. Really think about the value you bring, then let everybody know.

Whether you're new to tech or experienced, have a CS degree or not, in a career change or no, **YOU bring value to the table**. Our unique perspectives alone are very valuable. 

It's up to you to think about what other value you bring. But once you figure it out, let people know and they will believe you!  **You're not bragging, You're marketing yourself.**

#### 3. Be Proud of Yourself!

Being in the tech industry isn't easy. It took hard work and determination to reach the point that you are at now. Be proud of that! 

You submitted a Pull Request, learned a new language/framework, fixed a bug, simplified some documentation, gave a tech talk, wrote a blog post or something else fantastic. Be proud of that!

Proudly tell others what you did! Tell everyone here on dev.to about any of your accomplishments, we will love to hear it and to cheer you on. 

## Need Some More Advice?
I really enjoyed the following article:
{% link https://dev.to/ice_lenor/one-useful-advice-to-fight-the-impostor-syndrome-3p8 %}

**EDIT** Another great post on this topic:
{% link https://dev.to/kathryngrayson/overcoming-impostor-syndrome-apg %}

**EDIT** I really appreciated the advice in this comment:
{% devcomment 3ahk %}

### What are your thoughts on self-deprecation in tech?
The first two weeks at Mayden Academy
Tags: beginners, career
Published: 2018-02-26 21:13:39

---
title: The first two weeks at Mayden Academy
published: true
description: Emotions & experiences from the first Mayden fortnight
tags: #beginners #career
---

I've <a href="https://dev.to/martycrane/the-start-of-a-new-journey--khl" target="_none">previously alluded</a> to the fact that I caused myself a lot more grey hairs in the weeks leading up to my time with the <a href="https://maydenacademy.co.uk/">Mayden Academy</a> than I really needed to; in fact the first 2 weeks have been (reasonably) relaxed. Sure, there's been a lot of content to cram in but Charlie and <a href="https://dev.to/mporam">Mike</a> (the two chaps who are running it) have let us learn at our own pace, leaving us plenty of time to ask questions & put into practice what we've been soaking up.

We covered the basics of HTML & CSS in week 1, including mimicking two web-pages (one being responsive) to apply those skills. Week 2 was all about Developer Essentials -think git, IDE's and more. What was really exciting was that this included Scrum Master training, an Agile framework that many workplaces in the industry work to. It was refreshing to see a new way of working and, while my last position gave us a fair amount of autonomy, I can't wait to work in a team using Scrum. We are now all Certified Scrum Masters - meaning that we can take this new skill into a workplace and help lead them to implement Scrum. Also we played with Lego, and you can't compete with that. 

<img src="https://thepracticaldev.s3.amazonaws.com/i/yrhpjvc3kr6apeoxc6ae.jpg" height="250" width="250">

The upcoming week has us looking at building our first full website from beginning to end - a portfolio site designed to show off all of our progress and future builds. I am 100% concerned that I won't be able to design anything beyond a basic frame, but the guys have been pretty clear that we aren't expected to be designers (this is, after all, a course teaching us how to code, not design). I still can't help but feel a little useless when looking at others portfolio's.

I <em>am</em> a little worried about the upcoming weeks. I was hoping to be able to fit in some extra work most evenings just to recap the days content (luckily so far I haven't really needed to, but I expect that to change) but I have family commitments and a long commute: I have barely managed a minute of extra-curricular work. I've got my fingers crossed that I can find some solution. Also, american-isms like "gray", "math" and "color" keep slipping into use outside of the academy...that can't be healthy.

At least by the end of this week I will have something of my own that I have built from nothing - which, even if it is entirely rubbish, will be pretty cool and something that I could not have achieved before a fortnight ago.
Webpack 4.0 Release: What's New?
Tags: javascript, webpack, webdev
Published: 2018-02-26 17:54:52

---
title: "Webpack 4.0 Release: What's New?"
published: true
description: Webpack 4.0 has officially been released. What's new? What improvements were made? Learn how to build faster web applications with this new release.
tags: #javascript #webpack #webdev
canonical_url: https://auth0.com/blog/webpack-4-release-what-is-new/
---

On Sunday, February 25, 2018, Webpack 4.0, was released to the public. Legato (Weboack 4.0’s codename) is a major release to the JavaScript module bundler. It has taken about eight months since the release of 3.0.

In this article, we’ll cover the new features in Webpack 4.0 and several other changes and deprecations.

[Read on ✊](https://auth0.com/blog/webpack-4-release-what-is-new/?utm_source=dev&utm_medium=sc&utm_campaign=webpack4_new)

![Webpack 4.0 Release: What's New?](https://thepracticaldev.s3.amazonaws.com/i/o2cp6sind950in2itnfa.png)
phoenix
Published: 2018-03-08 07:42:30

---
title: phoenix
published: true
tags: 
canonical_url: https://tilde.team/~ben/blog/phoenix.html
---

inspired by [oodsnet](http://oods.net), (and my pull request to add [darkmode](https://github.com/exezin/oodsnet/pull/5)), i started to create my own tilde.team fork (now [forum.tilde.team](https://forum.tilde.team/)).

the first step was to switch out the css to the [tilde.team standard](https://tilde.team/css/) and update the classes for bootstrap. once i got it going and integrated with the tilde.team linux auth service, i asked other tildeans for input and suggestions.

[~micaiah](/~micaiah/) was interested in helping, but also wanted to learn a new language and/or framework, so we decided to start over, recreating the entire forum with [elixir/phoenix](http://phoenixframework.org). we'd discussed elixir previously, but never had a convincing use case to force us to learn it.

the project is live, with the source code on [github](https://github.com/tilde-team/forum).

the thing that i'm most impressed with is the speed of the erlang runtime :D

check out these response times. sub-millisecond!?!?!

![](https://tilde.zone/photos/phx.png)

give it a look, and [join the tilde.team](https://tilde.team/signup) if you want to come hang out!

Tags: [internet](tag_internet.html), [dev](tag_dev.html)

<!-- text end -->

[Comments? Tweet](http://twitter.com/intent/tweet?url=https://tilde.team/~ben/blog/phoenix.html&text=<Type%20your%20comment%20here%20but%20please%20leave%20the%20URL%20so%20that%20other%20people%20can%20follow%20the%20comments>&via=nebsirrah)
Git is one of the most brilliant pieces of software ever written...And other opinions on git
Tags: git
Published: 2018-02-26 16:01:25

---
title: Git is one of the most brilliant pieces of software ever written...And other opinions on git
published: true
description: Reflecting on a discussion that left me with a higher appreciation of git. 
tags: git
---

A little while ago I started this discussion on the topic of git:

{% link https://dev.to/ben/is-git-the-be-all-and-end-all-of-version-control-4lp %}

I was curious about whether git truly was the winner across all use cases. My thought was that some features of git act as unnecessary complexity for different cases. I wasn't overly opinionated, but I thought it would be a useful conversation to have.

Some of the responses to the thread addressed the question head on, but many of them were simply an opportunity to express the history and brilliance of git. It was a great read and I want to share some of it.

{% devcomment 12ch %}

{% devcomment 12af %}

And in follow-up to Joshua's comment:

{% devcomment 12d6 %}

{% devcomment 12dn %}

This comment thread addressed the question more directly:

{% devcomment 128k %}

{% devcomment 128p %}

{% devcomment 14lb %}

{% devcomment 12ca %}

It's worth questioning whether we can improve on any bit of software, but it's also exciting to marvel in the power and stability of some of the tools we work with. This discussion left me with a higher appreciation of git and I hope you enjoyed reading about it.
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2018-02-26 13:03:30

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/xsr1z6iqv0pd7p3s6ns3.png
---

#1. Stage One - The Proposal

As the title indicates, optional chaining may be coming to JavaScript. This post explains the what, why, and how about optional chaining and how to start using it, even if the Ecma committee hasn't accepted it yet.  

{% link https://dev.to/sammyisa/optional-chaining-may-be-coming-to-javascript--4ff0 %}

#2. Cold Turkey 🦃

From distraction-blocking apps to changelog generators. Marina curates a helpful list of software productivity tools, including management and focusing tools.

{% link https://dev.to/marina_pilip/keep-calm-and-code-on-productivity-tools-for-developers-10o4 %}

#3. Promise me you'll try

Tips on how to improve your relationship with promises. 

{% link https://dev.to/kepta/promising-promise-tips--c8f %}

#4. Esthetics, Technology, Ergonomy, Value

An exploration of what web design means in today, and how the meaning has evolved in the few years. 

{% link https://dev.to/bitersen/web-design-in-2018--456f %}

#5. _Not_ a fad

>"You're given three doors, one with treasure and two with goats. You select one door, but before that door is revealed, the host opens a different door that has a goat. You now have a choice: stick with the unopened door you chose, or switch to the other unopened door." 

Max uses the Monty Hall Dilemmma as a sniff test project for trying out new frameworks. React won with flying colors and in this post, he explains why the framework did so well. 

{% link https://dev.to/maxwell_dev/react-is-the-treasure-i-found-among-the-goats-pce %}

#6. There is no such thing as security

Understanding the wider context surrounding security will guide you to make better decisions. In this post, we learn about four security principles that will can help you start. 

{% link https://dev.to/robdwaller/four-security-principles-that-software-developers-should-follow-24gi %}

#7. Get Unstuck

Detailed instructions on 15 of the most common ReactJS problems that new developers deal with. From component naming conventions to assumptions with importing and exporting. 

{% link https://dev.to/samerbuna/reactjs-frequently-facedproblems--l5g %}
CookieCutter based project generator on the web
Tags: django, python, cookiecutter, scaffolding
Published: 2018-02-26 11:44:42

---
title: CookieCutter based project generator on the web
published: true
description: I couldn't sleep and made cookiecutter based project generator available as a web form
tags: django, python, cookiecutter, scaffolding
---

I have recently started a few Django projects, mostly to play around with some new tech and automate some of my workflows.

Then I thought, that there is [cookiecutter](https://github.com/audreyr/cookiecutter) project that should automate most part of project creation.

While this is a great and very useful tool, I don't like to answer questions line by line in terminal to generate a project.

I wanted a web interface for that.

In several hours I came up with a solution and it resides here: [Generator.KPavlovsky.pro](https://generator.kpavlovsky.pro/)

Python and Python-Django projects are included in available templates. After feeling form with questions (taken from templates' cookiecutter.json) and clicking `Generate`, you get ZIP archive with your new project.

Wish it will be useful for at least somebody. 

Feedback is welcome.

Contact me here or on twitter to provide feedback and/or feature requests.

@all, have a great day!
WooCommerce Quick View Plugin
Tags: woocommercequickview
Published: 2018-02-26 11:44:25

---
title: WooCommerce Quick View Plugin
published: true
description: WooCommerce quick view plugin allows you to help customers in quickly view the products details on shop and catalog page. 
tags: WooCommerce quick view
---
<img src="https://thepracticaldev.s3.amazonaws.com/i/97ym6r02n84hsxtsar64.png">
WooCommerce quick view plugin allows you to help customers in quickly view the products details on shop and catalog page. It displays the all the necessary information regarding products in a popup window like product name, description, images, ratings etc. <b><a href="https://codecanyon.net/item/woocommerce-product-quick-view-plugin/21393946">WooCommerce quick view plugin</a></b> also enables you to choose the product information which you want to display in a quick view popup. This extension helps to save the time of customers and enhance the user experience of your e-store. It cost you only $25 and comes with a money back guaranty and free support as well.

<b>Screenshots:</b>

<img src="https://thepracticaldev.s3.amazonaws.com/i/6v734mt0v5hig14ytoxd.png">

<img src="https://thepracticaldev.s3.amazonaws.com/i/0ldpgau5mttl4o16wcli.png">