teleren/devto huggingface dataset:
Conhecendo um pouco sobre Flux!
Tags: flux, arquiteturadeinforma
Published: 2023-09-08 14:41:51

---
title: Conhecendo um pouco sobre Flux!
published: true
date: 2018-02-24 13:55:40 UTC
tags: flux,arquiteturadeinforma
canonical_url: 
---

Flux é um padrão de projetos criado pelos engenheiros do facebook, onde se tem por padrão o fluxo unidirecional dos dados (single direction data flow). Padrão esse popularmente usado no front-end das aplicações.

![](https://cdn-images-1.medium.com/max/1000/0*FObL5i4rHn_J0xCs.jpg)

A _view_ envia ações que descrevem o que aconteceu. A _store_ recebe essas _actions_ e determina quais mudanças de estado devem ocorrer. Após o estado ser atualizado, o novo estado é enviado para a _view_.

Todos os dados fluem através do _dispatcher_, que é como um hub central. As ações são fornecidas ao _dispatcher_ em um método criador de ação e, na maioria das vezes, são originadas pelas interações do usuário com as _views_.

O _dispatcher_ então invoca as devoluções de chamada que as _store_ registraram, enviando ações para todas as _stores_. Dentro das devoluções de retorno registradas, as _stores_respondem a qualquer ação relevante para o estado que eles mantêm. As _stores_ emitem um evento de alteração para alertar as _views_ do controlador de que ocorreu uma alteração na camada de dados. _Controller-views_ escutam esses eventos e recuperam dados das _stores_em um manipulador de eventos. As c_ontroller-views_ chamam seu próprio método setState (), causando uma re-renderização de si mesmos e todos os seus descendentes na árvore do componente.

### Características

- Fluxo único de dados;
- Não sofre alterações em cascata;
- Previsível;
- Ações descritivas;
- Lógica contida em um único ponto (store);
- Flexível para ser usada em pequenas e grandes aplicações.

Estou me aventurando nesse novo design pattern, é um conceito novo pra mim, utilizando a implementação desse padrão para Vue, o Vuex. É bastante diferente do que eu usava de arquitetura web e vem se mostrando bem interessante, quem não conhece, recomendo ficar por dentro do assunto e entender. Abraços!

Fonte: [http://facebook.github.io/flux/index.html](http://facebook.github.io/flux/index.html)
Linux Syslog Server And Log Management
Tags: linux, logs, security
Published: 2018-02-24 12:47:22

---
title: Linux Syslog Server And Log Management
published: true
description: 
tags: #linux #logs #security
---

1 The Logging Service
2 Rsyslog Daemon
3 Configuring Rsyslog
4 Rsyslog Port
5 Rsyslog Facilities
6 Rsyslog Levels (Priorities)
7 Rsyslog actions
8 Combining Rsyslog Selectors
9 Rsyslog Filters
10 Systemd-journald Service
11 Syslog-ng
11.1 Syslog-ng Source Statements
11.2 Syslog-ng Destination Statements
11.3 Syslog-ng Filters Statements
11.4 Syslog-ng Log Statements
12 Logging syslog-ng Messages in SQL Database
13 Log Files Locations
14 Using Logrotate

https://likegeeks.com/linux-syslog-server-log-management/

Hope you like it.

Regards,
Efficient way to cache Google Fonts with Service Worker?
Tags: help, performance, webdev, discuss
Published: 2018-02-24 04:10:49

---
title: Efficient way to cache Google Fonts with Service Worker?
published: true
description: 
tags: help, performance, webdev, discuss
---

For as much as I know about PWAs and listened to talks about Service Workers, I haven't actually used them much (at all) beyond reading lots of documentation.

But with Google Fonts, they update the font all the time, and you could save anything from `fonts.gstatic.com` but that seems a little wasteful. Is there a better way?
Goでコマンドラインオプションを処理する
Tags: go, commandline
Published: 2018-02-24 03:58:25

---
title: "Goでコマンドラインオプションを処理する"
published: true
tags: golang,command-line
canonical_url: https://blog.web-apps.tech/go-cmdline-option-jessevdk-go-flags/
---

_this post originally appears on [blog.web-apps.tech](https://blog.web-apps.tech/)_

## TL;DR

- `github.com/jessevdk/go-flags`が便利

## flagパッケージ
 ![Goでコマンドラインオプションを処理する](https://blog.web-apps.tech/content/images/2018/02/gopher.png)

コマンドライン・ツールを作ろうと考えたとき、避けては通れないのがコマンドラインオプションを如何に処理するか、ということです。

Go言語では、標準パッケージに`flag`というパッケージが存在し、これを用いることでコマンドラインオプションをパースすることが出来ます。  
しかし、`flag`パッケージでは、ロングオプションとショートオプションを一度に定義することが出来ず、また、ロングオプションであろうとショートオプションであろうと`-XXX`という、ハイフンが一つつく形式のオプションとなります。  
これはあまり一般的ではなく<sup><a href="#fn1" id="fnref1">[1]</a></sup>、便利とも言いにくいでしょう。

そこで便利なのが、[`jessevdk/go-flags`](https://github.com/jessevdk/go-flags)パッケージです。

## go-flagsパッケージ

[`jessevdk/go-flags`](https://github.com/jessevdk/go-flags)パッケージは、その名の通り、コマンドラインオプションを取り扱うパッケージです。  
ショートオプション、ロングオプションはもちろんのこと、ショートオプションをまとめて指定する、同じオプションを違う引数で複数回指定する、環境変数からの読み込み、デフォルト値の指定などに対応していて、一般的なオプションの処理に幅広く対応出来ます。  
オプションは構造体として定義出来るため、パースした後の処理で取り回すのも簡単です。

簡単な例を見てみましょう。

```
type options struct {
    Name string `short:"n" long:"name" description: "listen address"`
}

func main() {
    var opts options
    if _, err := flags.Parse(&opts); err != nil {
        // some error handling
        return
    }
    fmt.Printf("Hello, %s\n", opts.name)
}
```

パッケージ宣言やインポートの節は省略していますが、上記をmain.goとして実行すると、以下の様に出力されます。

```
$ go run main.go -h
Usage:
  main [OPTIONS]

Application Options:
  -n, --name= listen address

Help Options:
  -h, --help Show this help message

$ go run main.go -n Foo
Hello, Foo
```

## フィールドの設定

`jessevdk/go-flags`パッケージでは、オプションを定義するために構造体を作ります。  
構造体の各フィールドがオプション一つ一つに当たります。  
そのため、細かい設定はタグで行うことになります。  
以下で、このパッケージで使用できる、主なタグを紹介します。

- `short`
  - ショートオプションの名前を決定します。ショートオプションですので、一文字をしていします。
- `long`
  - ロングオプションを指定します。
- `description`
  - ヘルプで表示される、オプションの説明文を指定します。
- `no-flag`
  - フィールドをオプションとして扱わないときに指定します。値は空値以外とします。
- `env`
  - 読み込む環境変数を指定します。環境変数から読み込まれた値は、オプションの規定値となります。(オプションで指定されたものが優先されます)
- `env-delim`
  - sliceやmapのオプションに環境変数から値を読み込む場合、このタグで指定した値で分割されます。
- `default`
  - 規定値を設定します。mapやsliceの値の場合は複数回指定することもできます。
- `default-mask`
  - ヘルプで規定値の欄に表示される値を指定します。指定しなかった場合は`default`の値が表示されますが、このタグを指定すると表示を上書きできます。`-`を指定すると、規定値を表示しない設定となります。
- `choice`
  - オプションに指定可能な値を定義できます。複数の選択肢を定義する場合は複数回指定します。
- `required`
  - オプションが必須な場合に指定します。値は空値以外とします。このタグが指定されたオプションが実行時に与えられなかった場合、ErrRequiredを返します。
- `positional-args`
  - 構造体に対してこのタグを指定することで、位置引数を定義できます。

このほか、オプショングループ、オプションの名前空間、サブコマンドの定義などに対応しています。

* * *
<section>
<ol>
<li id="fn1">
<p>javaのオプションなど、全く見ないわけではありませんが <a href="#fnref1">↩︎</a></p>
</li>
</ol>
</section>
Dynamically updating Matplotlib figures in Jupyter notebooks
Tags: python, jupyter, matplotlib
Published: 2019-07-06 00:18:18

---
title: Dynamically updating Matplotlib figures in Jupyter notebooks
published: true
tags: python, jupyter, matplotlib
canonical_url: https://sean.lane.sh/posts/2018/02/Dynamically-updating-Matplotlib-figures-in-Jupyter-notebooks/
---

Updating matplotlib figures dynamically seems to be a bit of a hassle, but the code below seems to do the trick. This is an example that outputs a figure with multiple subplots, each with multiple plots. Oddly enough, at the time of writing the image will be smaller than the figure until the Jupyter cells stops running, but this can be fixed but generating the figure in one cell, and then updating the image in a subsequent cell <sup id="fnref:1"><a href="#fn:1">1</a></sup>.

This code is run with the assumption that the following data file can be found in the working directory named `data.txt`:

[Sample TCL data](https://sean.lane.sh/files/2018/sample-tcl-data.txt)

```python
import numpy as np
import time
import matplotlib.pyplot as plt

%matplotlib notebook

def load_data():
    data = np.genfromtxt('data.txt', delimiter=',', skip_header=1)
    tm = data[:, 0]
    Q1 = data[:, 1]
    Q2 = data[:, 2]
    T1 = data[:, 3]
    T2 = data[:, 4]
    return (tm, Q1, Q2, T1, T2) 

(m_time, Q1s, Q2s, T1s, T2s) = load_data()

n = len(m_time)

labels = [
    [r'$T_1$ measured', r'$T_2$ measured'],
    # [r'$T_1 set point$', r'$T_2 set point$'],
    [r'$Q_1$', r'$Q_2$']
]

colors = [
    ['r:', 'b-'],
    ['r:', 'bx']
]

def plot_init(num_subplots=1, x_labels=None, y_labels=None):
    if not x_labels:
        x_labels = [None] * num_subplots
    if not y_labels:
        y_labels = [None] * num_subplots
    fig = plt.figure(figsize=(12,6), dpi=80)
    fig.subplots_adjust(hspace=.5)
    axes = []
    for i in range(1, num_subplots + 1):
        ax = plt.subplot(num_subplots, 1, i)
        ax.grid()
        if x_labels[i-1]:
            ax.set_xlabel(x_labels[i-1]) 
        if y_labels[i-1]:
            ax.set_ylabel(y_labels[i-1]) 
        axes.append(ax)
    return fig, axes

def plot_update(fig, axes, xs, ys, colors, labels):
    for i in range(len(axes)):
        for j in range(len(ys[i])):
            axes[i].plot(xs, ys[i][j], colors[i][j])
        axes[i].legend(labels=labels[i])
    fig.canvas.draw()

fig, axes = plot_init(
    num_subplots=2, 
    x_labels=[None, 'Time (sec)'],
    y_labels=['Temps (C)', 'Heaters']
)

for i in range(1, n):
    try:
        ys = [
            [T1s[:i], T2s[:i]],
            [Q1s[:i], Q2s[:i]]
        ]
        plot_update(fig, axes, m_time[:i], ys, colors, labels)
        time.sleep(0.2)
    except KeyboardInterrupt:
        break
```

* * *

1. [Stack Overflow: Jupyter notebook matplotlib figures show up small until cell is completed](https://stackoverflow.com/questions/45384072/jupyter-notebook-matplotlib-figures-show-up-small-until-cell-is-completed)<sup>[return]</sup>
Switchable graphics versus D3D11 adapters
Tags: directx, direct3d, d3d11, dx11
Published: 2018-02-23 23:39:44

---
title: "Switchable graphics versus D3D11 adapters"
published: true
tags: directx,direct3d,d3d11,dx11
canonical_url: http://asawicki.info/news_1675_switchable_graphics_versus_d3d11_adapters.html
---

When you have a laptop with so called "switchable graphics" (like I do in my Lenovo IdeaPad G50-80), you effectively have two GPUs. In my case, these are: Intel i7-5500U and AMD Radeon R5 M330. While programming in DirectX 11, you can enumerate these two adapters and choose any of them while creating a `ID3D11Device` object. For quite some time I was wondering how various settings of this "switchable graphics" affect my app? Today I finally figured it out. Long story short: They just change order of these adapters as visible to my program, so that the appropriate one is visible as adapter 0. Here is the full story:

It look like the base setting is the one that can be found in Windows Settings \> Power options \> edit your power plan \> Switchable Dynamic Graphics. (Not to confuse with "AMD Graphics Power Settings"!) When you set it to "Optimize power savings" or "Optimize performance", application sees Intel GPU as first adapter:

![](http://asawicki.info/files/SwitchableGraphics/Power%20Options%20Optimize%20power%20savings.png)

![](http://asawicki.info/files/SwitchableGraphics/SynTechVis%200Intel%20Sel0.png)

When you choose "Maximize performance", application sees AMD GPU as first adapter:

![](http://asawicki.info/files/SwitchableGraphics/Power%20Options%20Maximize%20performance.png)

![](http://asawicki.info/files/SwitchableGraphics/SynTechVis%200AMD%20Sel0.png)

I also found that Radeon Settings (the app that comes with AMD graphics driver) overrides this system setting. If you go to System \> Switchable Graphics and make configuration for your specific executable, then again: choosing "Power Saving" makes your app see Intel GPU as first adapter, while choosing "High Performance" makes AMD graphics first.

[![](http://asawicki.info/files/SwitchableGraphics/Radeon%20Settings%20Power%20Saving_480.jpg)](http://asawicki.info/files/SwitchableGraphics/Radeon%20Settings%20Power%20Saving.png)

It's as simple as that. Basically if you always use the first adapter you find, then you follow recommended settings of the system. You are still free to use the other adapter while creating your D3D11 device. I checked that - it works and it really uses that one.

![](http://asawicki.info/files/SwitchableGraphics/SynTechVis%200AMD%20Sel1.png)

It's especially important [if you meet a strange bug where your app hangs on one of these GPUs](http://asawicki.info/news_1673_when_integrated_graphics_works_better.html).
Easily Change Windows CMD,WSL Transparency
Tags: windows, cmd, terminal, keyboard
Published: 2018-02-23 21:11:00

---
title: "Easily Change Windows CMD,WSL Transparency"
published: true
description: tip to change windows terminal transparency
tags: windows,cmd,terminal,keyboard
---
![Window alternating transparency level through a Windows shortcut](https://thepracticaldev.s3.amazonaws.com/i/pkuekh5hs5sfk8w19762.gif)

Smart tip: when using Windows 10 command-line tools such as WSL, Ubuntu, Powershell or even CMD, you can:

**CTRL + Shift + Scroll Up/Down = change window transparency level**
A beginning
Tags: career, beginners
Published: 2018-02-23 20:47:37

---
title: A beginning
published: true
description: 
tags: #career #beginners
---

I’d spent a large amount of the last 10 years regretting the fact that I’d wasted my opportunity of a university education in the most stereotypical fashion - I’d joined a band and abandoned my studies, spending two years of tuition getting nowhere except dingy pubs in England. Since, I’d resigned myself to careers in the unskilled sector - working in the service industry, managing in retail - jobs I enjoyed but was never fully happy in.

Recently I had been managing a team in a national supermarket, a position that enabled me to find my strengths and play to them. It was during this time that I realised that I enjoyed using IT and tech to make life easier. Although this was contained largely to spreadsheets, I was able to help streamline and automate local processes that otherwise would have been left as manual.

Although I obviously enjoyed it, I ruled out a career in tech because of my lack of a degree, and that was that - right?

I had worked behind a bar previously and one of my former colleagues had recently got a job as a developer. But he had no degree! How did he do it? It occurred to me - if he can do it, why can’t I? Seeing as we were both at one point bar-monkeys, surely I could follow in his footsteps?

As it turns out, I could. He attended a <a href="https://maydenacademy.co.uk/" target="_blanl">course</a> run by local tech firm <a href="https://mayden.co.uk/" target="_blank"> Mayden</a>- they set about training up local coding-wannabees to help solve a local workforce supply issue. Also, as it turns out, I am just the sort of person that would pass their requirements tests and be accepted onto their Full-Stack web developer course.

I spent the last few weeks of supermarket work incredibly anxious of what it would be like: it had to be super intense and focussed at a screen 8 hours a day. There was no chance I was going to be able to keep up, and I was about to make a big mistake - putting my family in financial trouble and wasting the last 2 years of getting to a decent position at work. As such, I spent a good deal of my at-home time learning as much about the languages we were going to use as my head could fit.

I turned up 2 Monday’s ago and it was….relaxed. The pace has been realistic and, although I have found it incredibly helpful doing all that extra work in advance, I probably could have (just-about) survived without.

Now, 2 weeks in, I can start to see where my career as a developer might be. It may, of course, be nowhere - only by working hard and paying attention over the next 14 weeks will I be able to influence that, but at least I find myself on the right path. 

What’s been good: Building with HTML & CSS, playing with Lego
What’s been painful: Nothing. Yet….
Looking forward to: Having OOP explained to me.
How to remove temporal untagged Docker images
Tags: docker, onliner
Published: 2018-02-23 20:06:20

---
title: How to remove temporal untagged Docker images
published: true
description: On line command to remove temporary images that Docker creates while building an image.
tags: docker, onliner
---

*Update, thanks to [champkeh](https://dev.to/champkeh)

The correct way to remove unused docker images is using:

`docker image prune [OPTIONS]`

For more information you can go to:


[https://docs.docker.com/engine/reference/commandline/image_prune/](https://docs.docker.com/engine/reference/commandline/image_prune/)


---

If you have some experience with Docker you will know that mistakes are made while building your own images. At the beginning I didn't cared to delete one untagged image from time to time by using the `docker rmi ######` command, however, when I had to work on a project to migrate a legacy application to Docker, I realized that there are a LOT of images just hanging out in the ether like "we are here just chillin".

![chillin](https://thepracticaldev.s3.amazonaws.com/i/in5wq65fd5bvl6bibkzg.png "Chillin")


So, I started doing some cleanup one by one, until, you know, who wants to paste the image id or the name to delete it? Right. Then I came up with the following one-liner:

`docker images | awk '{if(match($1,"<none>")){print "docker rmi " $3 ";" | "/bin/sh"}}'`

You can then add the line to a shell script or whatever.The good thing is that if by some reason an image has a dependen child (container associated to it) it won't delete it unless you force it (-f).
Transitioning from traditional PC apps to Web Development
Tags: discuss
Published: 2018-02-23 19:21:07

---
title: Transitioning from traditional PC apps to Web Development
published: true
tags: discuss
---

I have 6 years of professional experience with C#/.NET type work. (I've learned more than just that, but for the purposes of this discussion I am focusing on that) 

After a brief stint at teaching, I am looking for work as a Software Developer again. The local job market has dried up, and it has become obvious that I must do one of two things: move, or work remotely. 

Moving somewhere else is not an option for me, so I am trying to venture into remote work. Things I've learned so far: it is very difficult, if not impossible to find work doing what I have professional experience in. I need to embrace web development. 

So I am digging in. It is a little humbling to have to try to find entry level positions when I have the years of experience I do, and entry-level remote positions are pretty rare themselves. 

I have also learned I need to build a GitHub portfolio. So far, my career has been working on others software, and I am not 100% sure on what I should even do for a project portfolio. I assume tutorials are not enough, as it isn't my own work. 

I know HTML/CSS and some JavaScript, but knowing this is not enough. I need x years of experience in the various popular technologies that are out there (React, Ruby-On-Rails, Node.js seem to pop up alot) for my resume to even reach HR before it is filtered by Applicant Tracking Software. 

Anyway, this is a long rant. If you read this far, thanks! I would enjoy reading your experiences making a big jump in your career as well as any advice you have.
This Week I Learned
Tags: discuss, learning
Published: 2018-02-23 18:29:17

---
title: "This Week I Learned"
description: 
tags: #discuss, #learning
published: true
---

Would love to see what cool things you guys learned. These can be ideas, tips and tricks, or anything really.

I'll start:

At a conference this morning, A talk on security mentioned monitoring the package dependencies people were adding to your project.

It's a great habit that I'd never even considered. We tend to give packages that our projects depend on a pass on security.
Installing Ruby 2.5.0
Tags: setup, ruby, macos
Published: 2018-02-23 18:06:29

---
title: Installing Ruby 2.5.0
published: true
description: How smoothly will it go?
tags: setup, ruby, macos
---

I just installed [Ruby 2.5.0](https://www.ruby-lang.org/en/news/2017/12/25/ruby-2-5-0-released/), which was released this past Christmas (Dec 25 2017). All in all, it took about 13 minutes with no bumps in the road. Pretty great!

![computer kid thumbs up meme](https://media.giphy.com/media/111ebonMs90YLu/giphy.gif)

I only need it for the work repo, but I'm happy to have it, too. I also wasn't too sure how to go about it, and said, "Well here goes."

```bash
git pull upstream master
# pulled from repo with new Ruby version set
rbenv install 2.5.0
#=> ruby-build: definition not found: 2.5.0
#
# The following versions contain `2.5.0' in the name:
#  2.5.0-dev
#  rbx-2.5.0
#
# See all available versions with `rbenv install --list'.
#
# If the version you need is missing, try upgrading ruby-build:
#
# brew update && brew upgrade ruby-build
brew update && brew upgrade ruby-build
#=> completed with no errors
rbenv install 2.5.0
#=> Installed ruby-2.5.0
rbenv global 2.5.0
# set Ruby version for the whole machine
ruby -v
#=> ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
bundle install
#=> rbenv: bundle install: command not found

# The `bundle install' command exists in these Ruby versions:
#  2.3.4
gem install bundler
# 1 gem installed
bundle
# install all gems to new Ruby version needed for repo
```

And that was it! Well, just for good measure, I migrated:
```bash
bin/rails db:migrate
```

Hope it's as easy for you!
A Normal Day        
Tags: embarrassing, happy, story, overcoming
Published: 2018-02-23 16:17:34

---
title: A Normal Day        
published: true
description: I would like that my days was an adventure, but didn't be
tags: #embarrassing #happy #story #overcoming
---

![overcoming](https://sokodirectory.com/wp-content/uploads/2016/05/overcoming-failure.jpg)
I'm depressed, truly is the first time to feel bad, I know this media is for talk about different things but is my unique form to express my feelings(sorry)

Always I want to be a social person, popular, funny, you know?, a person that like get out to all places, drink a beer or just watch a movie with my friends, this is life.

In these days I feel alone, not everything has been bad, I had been time for me, walk for the park, do my favorites hobbies as programming (a friki jejej), my state doesn't affect my professional life neither a health is the most important, but I know I'm missing something. I think that is for her, She showed me that the true love doesn't exist like the movies, (other sad story jaja), but it's true, I was missing myself this happened I month ago and my friends said me with the time all will fix.

after all sad story, I'm going to have an incredible journey to demonstrated me that She lose an only opportunity to be happy.

Thanks for all.
Sorry for embarrassing text 
See you later
Karmann Ghia Desktop
Tags: desktop, karmannghia, windows, slideshow
Published: 2018-02-23 14:55:34

---
title: "Karmann Ghia Desktop"
published: true
description: This is my desktop it's a slideshow of my favorite ride, I <3 VW Karmann Ghia!
tags: desktop, karmann ghia, windows, slideshow
---
![Karmann Ghia Desktop](https://thepracticaldev.s3.amazonaws.com/i/5mswl4i1w09yk5cn0v51.jpg)