teleren/devto huggingface dataset:
generate GitHub ssh key and upload it.
Tags: git
Published: 2019-09-25 17:05:20

---
title: generate GitHub ssh key and upload it.
tags: git
published: true
---

## Generate public, private key pair
```
$ cd ~/.ssh
$ ssh-keygenn -t rsa     (continue 'Enter' if you will be asked)
$ ls
id_rsa		id_rsa.pub
```

## Upload the pub key

### 1. copy it to clipboard
```
# if you're mac user
$ cat id_rsa.pub | pbcopy
```

### 2. access to https://github.com/settings/keys

### 3. Wite title

### 4. paste text of the id_rsa.pub to Key textarea.
You already copy it at 1.

## ✅ Test ssh connenctionn
```
$ ssh -T git@github.com
Hi n350071! You've successfully authenticated, but GitHub does not provide shell access.
```


## 🔗 Parent Note
{% link n350071/my-git-note-5259 %}
my peco note
Tags: shell, peco
Published: 2019-09-25 17:00:25

---
title: my peco note
tags: shell, peco
published: true
---


```
$ cat .bash_profile
alias cdp='cd $(ls -al | grep ^d | tr -s " " | cut -d" " -f9 | peco); pwd;'
```


```
cat ~/.gitconfig
[user]
	name = 
	email = 

[alias]
  check = !git checkout $(git branch | sed 's/*//g' | sed 's/ //g' | peco)
  bcp  = !git branch | peco | sed 's/*//g' | sed 's/ //g' | tr -d '\n'  | pbcopy
[log]
	date = iso-local
[core]
	quotepath = false
[commit]
	template = /Users/naoki/.git_commit_template
[filter "lfs"]
	clean = git-lfs clean -- %f
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
	required = true
[init]
	defaultBranch = master
```
The 1 hour challenge, can you survive it?
Tags: discuss, challenge, internet
Published: 2019-09-25 16:54:53

---
title: The 1 hour challenge, can you survive it?
published: true
description: Turn off your internet for 1 hours and see if you survive
tags: discuss, challenge, internet
---

So I'm in the middle of moving, and my new place won't have internet until tomorrow. 

I was up late working, trying to make up time for work due to life situations. 

I quickly realized just how important having internet it. I managed to struggle through but I eventually had to resort to my hotspot on my phone.

So I challenge you! Can you work locally on your station, with the internet turned off? 

No google, no package resources, no online references... so much we put on the web, and without it, can we even functions in our daily lives as developers? 

Pick a challenge and report back with your findings.

## Challenges

- 5 minutes
- 15 minutes
- 30 minutes
- 1 hour

Tell us which challenge you did, if you survived it, did you have to cheat? How many times did you do something, and realized it required having a connection? What was it? Did you find an alternative solution? Did it help you be a better developer?

I'll start off, by posting a comment with mine. 

### Template

```
** hour challenge**
**Survived**:
**Cheated**:
**Cheat method**:
**Access denied (no net) count**:
**Access Denied List**:
- 

**Better Dev from experience**:
**Reason for being better**:
**Thoughts/Comments**:
```


---

Varymade LLC.

Current projects are https://charactergenerator4000.com and https://coder.exchange. Please check them out and let us know your thoughts.
GraphQL Contributor Days -- November 1st, 2019
Tags: javascript, graphql, frontend
Published: 2019-09-25 16:32:36

**GraphQL Contributor Days is back and in-person!** We’re excited to host a special GraphQL Contributor Days after GraphQL Summit on November 1st, 2019 from 10am - 3pm PST in San Francisco, CA.

In partnership with [Hasura](https://hasura.io), this event welcomes any and all interested in GraphQL to join the conversation! 

The purpose of the event is for the GraphQL community to come together and discuss some key topics in the GraphQL ecosystem, and facilitate cross collaboration within the community.

Our featured guests are: 
Tracy Lee - _Founder, This Dot & RxJS Core Team_
Rajoshi Ghosh - _Co-Founder, Hasura_
Tanmai Gopal - _Founder, Hasura_
Ivan Goncharov - _GraphQL consultant, APIs.guru_
Dan Schafer - _Software Engineer, Facebook_
Sasha Solomon - _Sr. Software Engineer, Twitter_
Eve Porcello - _Co-Owner, Moon Highway_
Alex Banks - _Instructor, Moon Highway_
Tim Griesser - _Senior Software Engineer, Cypress_
Shruti Kapoor - _Software Engineer, Paypal_
Jim Gust - _Sr. Technical Product Manager, Expedia_
Dan Boerner - _Distinguished Program Manager, Expedia Group_
Patrick Arminio - _Senior Software Engineer, Verve_
Zhifan Li - _Senior Software Engineer, Intuit_
Christian Nwamba - _Senior Cloud Developer Advocate, Microsoft_

![Pictures of guests](https://thepracticaldev.s3.amazonaws.com/i/rx7b8li3nsqq7itfrtfa.png)

& more to be announced!

If you’re interested in attending, sign up for an invitation [here](https://www.thisdot.co/events/graphql-contributor-days-november-2019). 

Have a topic you’d like us to talk about? Leave us a comment below, and let us know! 

_Don’t forget to follow us on Twitter for updates on all the action [@ThisDotMedia](https://twitter.com/ThisDotMedia)!_
static security analysis for Rails app by using Breakman
Tags: rails, gem
Published: 2019-09-25 16:29:51

---
title: static security analysis for Rails app by using Breakman
tags: rails, gem
published: true
---

## 🔗 Parent Note
{% link n350071/my-rails-note-47cj %}

## How to use
### Run the brakeman
According to [Brakeman repository](https://github.com/presidentbeef/brakeman), run following command on the root directory of the app.

```shell
bundle exec brakeman
```

- 📚 [Brakeman: Options](https://brakemanscanner.org/docs/options/)

### Result
You might get the result like this. Sometimes, the result is so long, so that you can search the new alert by using `"new": [ ` keyword.

```sh
{
  "new": [
    {
      "warning_type": "File Access",
      "warning_code": 16,
      "fingerprint": "xxx",
      "check_name": "SendFile",
      "message": "Parameter value used in file name",
      "file": "app/controllers/download_controller.rb",
      "line": xx,
      "link": "https://brakemanscanner.org/docs/warning_types/file_access/",
      "code": "send_file(params[:file_name])",
      "render_path": null,
      "location": {
        "type": "method",
        "class": "DownloadController",
        "method": "file_download"
      },
      "user_input": "params[:file_name]",
      "confidence": "Weak"
    },
```

### specific files
```
bundle exec brakeman --only-files path/to/file/,path/to2/ --compare ./brakeman-result.json | grep '"new": ' -A25
```

### Run on CI server
```sh
bundle exec brakeman -z ./
```

- `-z`: return 0 as the exit code. Breakman returns non-0 code as default if it detects any security warnings. This option helps CI.



### Compare with last one
```sh
bundle exec brakeman ./ --compare ./ci/brakeman-scan-result.json
```


## In the Case of FalsePositive
Write it to ignore file.  

```
bundle exec brakeman -I ./
```

Breakman will ask you if it detects any warning, then I think the option `n` is good. n means `Add warning to ignore list and add note`. Note is a comment.

- `-I`: `--interactive-ignore`. (explain at the FalsePositive)

📚 [Brakeman: Ignoring False Positives](https://brakemanscanner.org/docs/ignoring_false_positives/)
Introducing HTTP Mock
Tags: showdev, http, opensource, testing
Published: 2019-09-25 16:20:45

---
title: Introducing HTTP Mock
published: true
description: Introducing HTTP Mock: Intercept, debug and mock HTTP(S) with zero setup 
tags: showdev, http, opensource, testing
---

Hi Dev.to!

I'm super excited to show you my latest HTTP Toolkit release: [HTTP Mock](https://httptoolkit.tech/mock/).

It's an HTTP debugging, testing & development tool, similar to others like Fiddler & Charles, but cross-platform, 100% open-source, and dramatically modernized.

The best bit of magic: one click setup. Click a button, and open a Chrome or Firefox window, or a command line, and start seeing all HTTP or HTTPS sent by that specific window. Open pages in your browser, run CLI tools, start up your Node.js server, Python script or Ruby app, and you'll immediately see all the HTTP & HTTPS they're sending.

Super useful for complex microservice debugging, but also if you're just trying to understand how some simple communication in your codebase actually works. I've added inline docs from the Mozilla Developer Network too for all standard methods, statuses and headers, which helps make everything easier to understand.

![HTTP Mock, showing some intercepted traffic](https://thepracticaldev.s3.amazonaws.com/i/lju30o9lxxv8ki7uheje.png)

From there, there's a new 'Mock' tab, which lets you mock & rewrite HTTP.

You can match requests & breakpoint them to take a closer look, and edit the request or response, or provide your own response directly. You can match requests and provide automated responses, to mock endpoints or entire servers, or inject error responses, timeouts & connection resets to test your error handling.

Even forward traffic from one host to another, to replace your production database with a local one, or anything else you can imagine. 

Like so:

![HTTP Mock, showing some rewrite rules](https://thepracticaldev.s3.amazonaws.com/i/qjksth4i9qv3sm2dxnh4.png)

Sound good? It's a free download from [httptoolkit.tech/mock](https://httptoolkit.tech/mock). Try it out, let me know what you think!
organize the authorizations of the banken/pundit gem with define_method
Tags: rails, gem
Published: 2019-09-25 16:07:54

---
title: organize the authorizations of the banken/pundit gem with define_method
tags: rails, gem
published: true
---

## 🔗 Parent Note
{% link n350071/my-rails-note-47cj %}

[banken](https://github.com/kyuden/banken) is ...,

> Simple and lightweight authorization library for Rails inspired by Pundit. Banken provides a set of helpers which restricts what resources a given user is allowed to access.

## 🤔 Situation
Authorization will be grown with your app, and it will be like this.  
new? refers show?, show? refers index?.

```ruby
class BooksLoyalty < ApplicationLoyalty
  def index?
    @user_context.user == @record.user
  end
  def show?
    index?
  end
  def new?
    show?
  end
end
```

## 👍 Solution
Because each method is the same, they don't transfer their logic. Then, `define_method` may be nice.

```ruby
class BooksLoyalty < ApplicationLoyalty
  [:index?, :show?, :new?].each do |method|
    define_method method do
      @user_context.user == @record.user
    end
  end
end
```

If you need arguments, see also 📚 [my github note](https://github.com/n350071/notes/blob/7f435d60e76acece1ec46efb3fa1d8586e307640/Ruby/define_method.rb).
Devmates.co [Reverse Words In String]
Tags: challenge
Published: 2019-09-25 15:47:33

*Hello👋, 
My name is [Alex](https://twitter.com/alexwawl) and I'm maker of [Devmates.co](https://devmates.co).* 😊

*We are resolving daily coding problems which asked by top tech companies together. We share our solutions, give some help if anyone stuck, support each other and just hangout together in the internet.* 🍻☕️💬

*I get this problem from our members or just searching them in the internet(leetcode forums, Glassdoor, teamblind, etc.). Sometimes this problem can be very easy, sometimes too 👷‍♂️hard, everything depends on skills but we are trying to resolve all of them and Have Fun.*  🙌 

Today I want to share problem which was asked by Bolt (🚖 Taxify).

Feel free to share you solutions in comments. I would love to find "better" solution and put it to the [article](https://devmates.co/solutions/reverse_words_in_string).😉

#####Problem:

Reverse each word in a given string.

You can't use language provided methods (such as split, reverse, etc.)

__Example__

```javascript
__Input:__ 'hello this is devmates'
__Output:__ 'olleh siht si setamved'
```

*Good Luck and Have Fun*😉
Kafka
Published: 2019-09-25 15:20:52

• There are 4 components of Kafka:
```
o Producer
o Consumer
o Broker: A broker is nothing but the server and a node, which manages the topic.
o Zookeeper: Zookeeper maintains the state of brokers, in case of any broker going down or coming up, it notifies the zookeeper and zookeeper informs to the producer and consumer so that producer and consumer are connected to live broker.
```
• Topic is a classification for the message type let's say data type.
• The given topic is splitter into many partitions.
• And these partitions are replicated across more than 1 broker, if the number of brokers is more than 1.
• For the given partitions, there will be only 1 lead node and rest will be the slave node.
• Messages from the producer can go into any partitions and hence gets replicated.
• If the messages are assigned with the key, then it ensures the message with the same key in the particular partitions.
• In this way, it makes sure that messages are sequenced in the partitions.
• Kafka client (producer/consumer) to Kafka data transfer happens through https which makes sure that data is encrypted using SSL certificate.
• Use case:
```
o Messaging: A messaging platform built in publisher-subscriber model.
o Website tracking: to get the real time report of user activity in the website.
o Log aggregation: To aggregate the logs from many services.
o Fault tolerance: Kafka platform enables the back up of the events along with regular synch up.
o Stream Processing: events coming from multiple services can be processed in real 
time and then can be transferred to other platform like storm for further processing.
```
• Eamples:
```
o Twitter uses it to take the post from the registered users to another registered 
user to repost and read and to unregistered user for read.
o LinkedIn uses it for online consumption along with offline analytics while being 
sorted in Hadoop.
o Netflix uses it for real time monitoring and event processing.
```
API Gateway
Published: 2019-09-25 15:11:48

# Proxy
Proxy is a dedicated computer or software system running in the same computer or different computer acts as intermidiary between the requester of a website and the actual web server.
Type of proxy:
• Forward Proxy: it helps in connecting the user to the website.
• Reverse Proxy: it is used:
```
o To allow load balancing between the server.
o To stream internal content to its user. (SSO page)
o To block some particular website.
Nginx 
```

#Load balancers:
• With the many servers configured as upstreams, you can define proxy_pass to this upstreams.
• There are multiple types of load balancers:
```
o Round Robin: this is by default.
o least_conn: the one with the least client connection will be picked up.
o ip_hash: each of the client has some unique key, the first few characters of this key works as server chooser. It helps in speeding up the process.
```
• To provide high availability load balancers, you can plug in external load balancer also.
• Caching
```
o Various cache related information like path, key, validity can be configured to improve the performance.
o User data is suggested not to be cached to avoid sharing one user data with other user.
```

# API Gateway 
It is used to manage the API, also referred as translator, which includes 
• combining more than 1 APIs into 1
• combining responses from more than 1 API into 1
• Providing the default data/message in case of error from any API invocation
• Security management
Welcome Thread - v42
Tags: welcome
Published: 2019-09-25 15:11:35

---
title: Welcome Thread - v42
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
---

![seal says sup](https://media.giphy.com/media/ypqHf6pQ5kQEg/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
REST vs SOAP
Published: 2019-09-25 15:06:06

• REST (REpresentational State Transfer) is an architectural style while SOAP (Simple Object 
Access Protocol) is a protocol.
• REST is all about simplicity, where it comes with the lighter data (JSON), although it 
supports other format as well, e.g. simple TEXT., HTML, XML etc, while SOAP is built within 
the envelop, where it contains data in XML.
• REST comes with SSL security and https while SOAP comes with WS-Security as well.
• SOAP has built in ACID compliance that’s why it makes it favorable choice when it comes 
to sensitive data e.g. financial data.
• AS REST is lighter so it needs less bandwidth as compared to SOAP.
• Data can be cached only in REST not in SOAP.
• SOAP has strict communication contract.
• REST uses URL and URI to access the API while SOAP uses service interface (WSDL file) to 
expose its functionality to client application.
• If the service is required to maintain the state from one request to another then SOAP is 
preferred.
• The WSDL file is a contract between the client and server. The content in this file has all 
the information about the services being exposed, which includes field name, field type. If 
there is any change to any parameter, it would have the huge impact on all the client side 
implementation.
• Using wsimport, you can generate all the classes from wsdl file. Wsdl file is a xml file which 
contains the schema. It can be used to create data object including the Authentication 
detail and sent it over the network. The signature for the request is similar between rest 
based service and soap based service with only difference:
```
o SOAP Action
o Soapenv
o soapenv: Body
```
• Status Code:
```
o 200: Request got executed successfully.
o 201: resource has been created successfully.
o 202: Accept, means the request has been accepted for execution asynchronously.
o 203: Non Authoritative information, means the content has been delivered from 
third party
o 400: Bad request because of syntax error.
o 401: Authentication is needed.
o 403: Authenticated but don't have enough access for the given request.
o 404: Resource not found
```
About Adam Marcus Hendry
Tags: adammarcushendry, adamhendry, tzadikmanagement
Published: 2019-09-25 15:05:25

Adam Marcus Hendry is an accomplished Entrepreneur and Executive who believes in building performance focused organizations through the development of people, processes and culture. As CEO of Tzadik Management, Adam Hendry has led efforts to develop a continuous improvement mindset and establish best practices across all managed portfolios. Assuring everyone is focused on growth and on the processes that impact controllable property expenses in a way that aligns with the company’s purpose, brand promises, employer brand and values.
 
Adam Marcus Hendry has almost 15 years of progressive management experience in the real-estate and property management industry; with significant emphasis in strategic planning and the establishment and management of long term strategic partnerships. Adam Hendry’s market knowledge, financial acumen and experience in opportunity analysis have been critical to his success in foreseeing potential market opportunities and proactively building and positioning a highly motivated and flexible organization to take advantage. While his ability to think “out of the box” has enabled Mr. Hendry to lead his team in developing operational models that better align to strategic and performance objectives.                                                               
A charismatic and visionary leader with a bias for action; Adam Marcus Hendry passionately focused on developing and growing a workforce that the competition would envy, relationships with tenants that cause them to be raving fans, and vendors/partners that speak highly of Tzadik Management (both as individuals and the organization as a whole). All of this done in a way that is scale-able and repeatable across the properties as the company grows rapidly through acquisition.
Linux: persistent logs in systemd-journald
Tags: linux, logs, systemd, journald
Published: 2019-10-07 17:49:30

---
title: Linux: persistent logs in systemd-journald
published: true
tags: Linux,logs,systemd,journald
canonical_url: https://rtfm.co.ua/en/linux-persistent-logs-in-systemd-journald/
---

![](https://rtfm.co.ua/wp-content/uploads/2011/08/linux-logo.png)We have an AWS EC2 which suddenly rebooted.

The issue is that its `/var/log/messages` incomplete and the latest record is about `rsyslog` service killed – but nothing about who killed it and why.

Then I went to the `journald` but "surprise" – it stores logs only for the current boot so there was no way to find the reboot’s root cause.:

```
root@bttrm-stage-console:/home/admin# journalctl --list-boots
0 f527010076a141c5917496c6aa03438a Tue 2019-09-24 12:13:02 EEST—Tue 2019-09-24 17:48:44 EEST
```

So, we need to configure `journald` to store logs after each reboot.

Its config file [`/etc/systemd/journald.conf`](https://www.freedesktop.org/software/systemd/man/journald.conf.html).

To make logs to be stored always – update the `Storage` parameter to the _auto_ or _persistent_.

If _auto_ – then the `/var/run/journal` directory must be created manually, with the _persistent_ – `systemd` will create it.

Update config, set _persistent_, restart `systemd-journald` to apply:

```
root@bttrm-stage-console:/home/admin# systemctl restart systemd-journald
```

Check the logs directory:

```
root@bttrm-stage-console:/home/admin# ll /var/log/journal/
total 4
drwxr-xr-x 2 root root 4096 Sep 24 17:54 7066493f616c4a6285c19cfaa2884b09

root@bttrm-stage-console:/home/admin# ll /var/log/journal/7066493f616c4a6285c19cfaa2884b09/
total 57348
-rw-r----- 1 root root 58720256 Sep 24 17:54 system.journal
```

Reboot the EC2 and check logs again:

```
root@bttrm-stage-console:/home/admin# journalctl --list-boots
-1 f527010076a141c5917496c6aa03438a Tue 2019-09-24 12:13:02 EEST—Tue 2019-09-24 17:56:19 EEST

0 591136b94276490580f4e39e576e639e Tue 2019-09-24 17:56:20 EEST—Tue 2019-09-24 17:56:41 EEST
```

Now you are able to check the previous reboot log:

```
root@bttrm-stage-console:/home/admin# journalctl -b -1

-- Logs begin at Tue 2019-09-24 12:13:02 EEST, end at Tue 2019-09-24 17:57:36 EEST. --

Sep 24 12:13:02 bttrm-stage-console CRON[19407]: pam\_unix(cron:session): session closed for user me-v3
```

Size can be limited by setting the `SystemMaxUse`, see the [documentation](https://www.freedesktop.org/software/systemd/man/journald.conf.html#SystemMaxUse=).

Done.

### Similar posts

- <small>03/01/2019</small> [Linux: systemd-unit files edit, restart on failure and email notifications](https://rtfm.co.ua/en/linux-systemd-unit-files-edit-restart-on-failure-and-email-notifications/)
- <small>03/08/2019</small> [OpenVPN – auto-start on Linux](https://rtfm.co.ua/en/rdy-openvpn-auto-start-on-linux/)
- <small>05/15/2019</small> [Linux: A stop job is running for Session c1 of user setevoy (1min 30s)](https://rtfm.co.ua/en/linux-a-stop-job-is-running-for-session-c1-of-user-setevoy-1min-30s-2/)