teleren/devto huggingface dataset:
Practical issue about DNS – EDNS0
Tags: networking, dns, go
Published: 2018-08-08 13:40:33

---
title: Practical issue about DNS – EDNS0
published: true
tags: networking,dns,golang
canonical_url: https://dannypsnl.github.io//networking/dns/golang/2018/08/07/practical-issue-about-dns-edns0.html
---

I have to create a checker for our DNS server.

Our DNS server will return its config via `TXT`.

Code would like:

```go
package main

import "github.com/miekg/dns"

// func main
m := dns.Msg{}
// `google.com.` is correct format, `.` is required!
m.SetQuestion("google.com.", dns.TypeTXT)
c := dns.Client{}
// write out port 53(:53) is required, dns package we used at here won't automatically fix port to 53.
// Unlike some cli tool such as Dig
response, _, err := c.Exchange(&m, "8.8.8.8:53")
for _, t := range r.Answer {
    txt := t.(*dns.TXT)
    // dns.TXT.Txt is []string
    for _, t := txt.Txt {
        // t is string, now you can use it
        println(t)
    }
}

```

But our config stream is too big to over the limit of UDP! And we must get it.

**RFC 6891** :

> Traditional DNS messages are limited to 512 octets in size when sent over UDP [RFC1035].

After researching, I find we can extend DNS packet size by EDNS0.

**RFC 6891** :

> EDNS(0) specifies a way to advertise additional features such as larger response size capability, which is intended to help avoid truncated UDP responses, which in turn cause retry over TCP. It therefore provides support for transporting these larger packet sizes without needing to resort to TCP for transport.

Code is:

```go
m.SetEdns0(4096, true)

```

In `SetEdns0`:

```go
func (dns *Msg) SetEdns0(udpsize uint16, do bool) *Msg {
	e := new(OPT)
	e.Hdr.Name = "."
	e.Hdr.Rrtype = TypeOPT
	e.SetUDPSize(udpsize)
	if do {
		e.SetDo()
	}
	dns.Extra = append(dns.Extra, e)
	return dns
}

```

The code that change UDP size is `e.SetUDPSize`, so let’s take a look:

```go
func (rr *OPT) SetUDPSize(size uint16) {
	rr.Hdr.Class = size
}

```

Type of `OPT.Hdr` is `RR_Header`, then we dig into **RFC 6891** , on page 5 you can find:

```
The fixed part of an OPT RR is structured as follows:

+------------+--------------+------------------------------+
| Field Name | Field Type | Description |
+------------+--------------+------------------------------+
| NAME | domain name | MUST be 0 (root domain) |
| TYPE | u_int16_t | OPT (41) |
| CLASS | u_int16_t | requestor's UDP payload size |
| TTL | u_int32_t | extended RCODE and flags |
| RDLEN | u_int16_t | length of all RDATA |
| RDATA | octet stream | {attribute,value} pairs |
+------------+--------------+------------------------------+

```

As expected, `RR_Header.Class` will change UDP payload size. Celebrate it!!!

More info:

- [RFC 2671](https://tools.ietf.org/html/rfc2671)
- [RFC 6891](https://tools.ietf.org/html/rfc6891)
- [miekg/dns](https://github.com/miekg/dns)
Powershell closures
Tags: original, shorts, dev
Published: 2020-07-07 09:36:56

---
title: Powershell closures
published: true
date: 2018-08-07 00:00:00 UTC
tags: Original,Shorts,dev
canonical_url: 
---

As a [follow up to the previous article](https://blog.pitermarx.com/2018/08/execute-an-arbitrary-piece-of-code-with-a-temporary-file-uploaded-to-azure-e87f7057f70b/), I needed to warn you (and me) about powershell closures. They didn’t work as i expected

{% gist https://gist.github.com/pitermarx/acfd219c0bb2493fe176cdc9c0e13b9b %}

The confusion point for me was that $Foo can be changed by the invoker, unless we add the .GetNewClosure().

As in the previous article the parameter name $ResourceGroupName is very common, it’s best to always use the .GetNewClosure() on the ScriptBlock
Getting your Linux system to use a logical date & time representation (ISO 8601)
Tags: linux, crosspost
Published: 2018-08-11 10:18:10

---
title: Getting your Linux system to use a logical date & time representation (ISO 8601)
published: true
tags: linux, crosspost
canonical_url: https://mayeu.me/blog/getting-linux-to-use-a-logical-date-time-representation-iso-8601/
---

During one of my many Linux reconfiguration, I wondered if there was a way for me to make it show the date and time by following the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. If you don’t know, that is the standard defining the date format as`2018-08-07` (and other things, like 24-hour format, etc.).

The way you configure these kinds of things in Linux is via the[locale](https://en.wikipedia.org/wiki/Locale_(computer_software)) system. Most of the time, we just configure the `LANG`variable to match our own language (like `LANG=en_US.UTF-8`) and stop the configuration there. But there are more variable than that (like `LC_NUMERIC`,`LC_MONETARY`, `LC_PAPER` to name a few), and the one that interests us today is `LC_TIME`.

It turns out that there is an `en_DK` locale (which is really a haked locale, since English is not a language of Denmark), that follow the ISO 8601 standard!

So you can set up your time locale using `LC_TIME=en_DK.UTF-8` and reach datetime nirvana :pray:

*This post was originally published on [mayeu.me](https://mayeu.me/blog/getting-linux-to-use-a-logical-date-time-representation-iso-8601/).*
My New .NET Core Podcast
Published: 2018-08-06 23:14:45

---
title: My New .NET Core Podcast
published: true
description: A short post all about my new project - The .NET Core Podcast
cover_image: https://dotnetcore.show/content/images/2018/07/Header-Image-2.jpg
---

Back when I started writing about .NET Core (in November 2016), I thought that there was something missing.

Sure, Microsoft and the community had put in a _lot_ of effort getting the documentation off the ground; they also put a tonne of video content out there in the form of the MVA courses. But I felt like something was missing - mainly because I'm an auditory learner.

So I've decided to start a podcast devoted to .NET Core

##### Why?

Why not? The .NET Rocks fellas have a podcast related to .NET Framework (although that's not strictly true anymore, as they talk about everything in the .NET ecosystem); and there are tonnes of podcasts on specific JavaScript frameworks.

Seriously, why not?

The aim of the podcast is to bring a little knowledge of the new ecosystem platform to the podcast listening audience, and to interview folks from the .NET Core, ASP NET Core, EF Core and SignalR communities.

##### Ok. Where?

I've already created a new website specifically for it: [dotnetcore.show](https://dotnetcore.show/) - each post on there will act as show notes for an episode of the podcast.

I also have an [RSS feed](https://thedotnetcorepodcast.libsyn.com/rss) set up, and the show should be starting to be listed in the major podcatchers.

##### Final Thoughts

I was aiming for a short post, and I hope that I've delivered - most of my posts over at [dotnetcore.gaprogman.com](https://dotnetcore.gaprogman.com) tend to be around 3k words.

Head on over to the new show's website to check it out and get a feel for it. As I publish this post (Aug 7th, 2018) there's a single live episode. Give it a listen and let me know what you think.

Connect with me over on [Twitter](https://twitter.com/dotnetcoreblog) and let's talk .NET Core.

Thanks
Component event delegation with vanilla Javascript
Tags: javascript, eventdelegation
Published: 2018-08-06 20:39:11

---
title: Component event delegation with vanilla Javascript
published: true
description: Lets take a look at how we can make use of event delegation to manage our components event listeners efficiently.
tags: javascript, event delegation
---
Last week I wrote about [checking for an element on a page](https://alexcarpenter.me/posts/2018/08/check-for-element/) before executing our Javascript to avoid errors. That example works well if you only have one element to attach an event listener to. If you have multiple components and triggers, we should look into using event delegation to keep our code performant.

So lets refactor our modal component code from last week to make use of event delegation.

```js
function modal() {
  var trigger = document.querySelector('[data-modal-trigger]');
  trigger.addEventListener('click', function() {
    // Modal functionality code
  }, false);
}
modal();
```

First lets pass the `event` through to our modal function. Then we can use the `closest()` method to see if our modal trigger was clicked.

Now that we have refactored our modal function. We can attach an event listener to the document. Now any time a click happens within the document, we run our modal code and pass through the click event.

```js
function modal(event) {
  if (!event.target.closest('[data-modal-trigger]') return;
  // Modal functionality code
}

document.addEventListener('click', function(event) {
  modal(event);
}, false);
```

This allows us to add multiple components to our site and only have a single event listener as shown below.

```js
function modal(event) {
  if (!event.target.closest('[data-modal-trigger]') return;
  // Modal functionality code
}

function accordion(event) {
  if (!event.target.closest('[data-accordion-trigger]') return;
  // Accordion functionality code
}

document.addEventListener('click', function(event) {
  modal(event);
  accordion(event);
}, false);
```

Note that this assumes that your components are all run off of a click event, which might not always be the case. You might also have components which need to watch for `mouseover` or `mouseout` events, which would require seperate event listeners.

Check out the [CodePen](https://codepen.io/alexcarpenter/pen/pZKeKV) to see the code in action.
Module Monday 7: Animated timeline, Right-sized image, Company contact form & more
Tags: showdev, opensource, webdev, javascript
Published: 2018-08-06 20:29:33

---
title: Module Monday 7: Animated timeline, Right-sized image, Company contact form & more
published: true
description: Module Monday 7
tags: showdev, opensource, webdev, javascript
cover_image: https://res.cloudinary.com/component/image/upload/v1533349931/timeline_vfmn9w.png
canonical_url: https://guide.anymod.com/module-monday/07.html
---
## Open-source code & features for any website or web app

Every Monday I post free, open-source mods you can use for quickly adding features to your website or web app.

Everything below is open source and free to use in any project you choose. [Anymod](https://anymod.com) is a service that lets you build & add features like these easily.

Click a mod to see it in action along with its source code.

### Animated timeline
Add and edit events to tell your story.
<a class="button" href="https://anymod.com/mod/nmnko?v=30">View mod</a>
<a href="https://anymod.com/mod/nmnko?v=30">
  <img src="https://res.cloudinary.com/component/image/upload/v1533349933/timeline_50_yolluz.gif"/>
</a>

### Right-sized image
Image resolution determined by screen size: for high quality AND fast mobile downloads.
<a class="button" href="https://anymod.com/mod/kbadr?v=20">View mod</a>
<a href="https://anymod.com/mod/kbadr?v=20">
  <img src="https://res.cloudinary.com/component/image/upload/v1533349931/responsive-image_w1je1h.jpg"/>
</a>

### Company contact form
Works automatically: an easy way for companies to reach you.
<a class="button" href="https://anymod.com/mod/lraln?v=30">View mod</a>
<a href="https://anymod.com/mod/lraln?v=30">
  <img src="https://res.cloudinary.com/component/image/upload/v1533349931/company-form_nwqed7.png"/>
</a>

### Twitter Follow button
Add your username and you're done.
<a class="button" href="https://anymod.com/mod/mlbao?h1=1&h2=1">View mod</a>
<a href="https://anymod.com/mod/mlbao?h1=1&h2=1">
  <img src="https://res.cloudinary.com/component/image/upload/v1533349931/twitter_hyaos6.png"/>
</a>

### Basic card with links
<a class="button" href="https://anymod.com/mod/enbmb?h1=50&h2=100&v=20">View mod</a>
A simple text card with editable content and links.
<a href="https://anymod.com/mod/enbmb?h1=50&h2=100&v=20">
  <img src="https://res.cloudinary.com/component/image/upload/v1533349931/basic-card_un3ina.png"/>
</a>

<hr>

[Anymod](https://anymod.com) supports developers and open source, and Module Mondays are one way we give back to the developer community to help foster a more open, inclusive web.

I post new modules [here](https://dev.to/tyrw) every Monday -- I hope you find them useful!

Happy coding ✌️
Switching careers and two years after that
Tags: frontend, development, career, webdev
Published: 2018-08-06 19:19:14

---
title: Switching careers and two years after that
published: true
description: Mistakes I made while learning to code. And things I learned while working as a frontend developer.
tags: frontend, development, career, webdev
---

In February 2016 I was writing this article about the mistakes I made while learning to code. I was also trying to find a job as a frontend dev or at least an internship.

As I don't think it's necessary to repeat what I wrote on Medium, the article about the mistakes I made can be found over here: [Medium article on freeCodeCamp](https://medium.freecodecamp.org/mistakes-i-made-while-learning-to-code-2a7e3ace092e)

After some time I wrote another one, just to note what I learned on the job and see what has changed during this time. Can be found over here: [Two Years of Frontend Development](https://medium.com/@danielvoicu/two-years-of-frontend-development-76ba3ca0a6b0)

P.S: This is also a post for me to figure dev.to out. :)
Rails Action Pack Variants
Tags: rails, actionpack, variants
Published: 2018-08-06 16:43:56

---
title: Rails Action Pack Variants
published: true
description: Render different HTML/JSON/XML templates for phones, tablets, and desktop browsers. Variants make it easy.
tags: #Rails, #ActionPack, #Variants 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/dt9d21b193q22r1g8tuv.jpeg
---

Recently on one of the projects at [Eloquent Studio](https://eloquent.studio), I needed to render two very different view templates for desktop and mobile, even Bootstrap responsive design did not fit the requirement.

A little hesitant to roll out a custom solution for such a common requirement, I did some google searches and struck up the RailsGuides. `ActionPack Variants` is just what I was looking for. `ActionPack Variants` is a specialisation of `request format`. Released with Rails 4.1, the api was later improved to its current state in Rails 5 as per this [PR](https://github.com/rails/rails/pull/18939)

Within the controller action's respond to block

```
# app/controllers/patterns_controller.rb
before_action :set_variant, only: :show

def show
  format.html do |html|
    html.phone
    html.tablet
  end
end

private

def set_variant
  case request.user_agent
    when /iPad/i
      request.variant = :tablet
    when /iPhone/i
      request.variant = :phone
    when /Android/i && /mobile/i
      request.variant = :phone
    when /Android/i
      request.variant = :tablet
    when /Windows Phone/i
      request.variant = :phone
  end
end
``` 

And setup view templates as
```
# app/views/patterns/show.html.erb

# Show page for desktop view
```

```
# app/views/patterns/show.html+tablet.erb

# Show page for tablet view
```

```
# app/views/patterns/show.html+phone.erb

# Show page for phone view
```

Not just devices, variants can be used for more varied use cases, like rendering different view templates based on user roles.

CoverImage Credits: https://unsplash.com/@bugsster
The legends behind code
Tags: discuss
Published: 2018-08-06 16:38:11

---
title: The legends behind code
published: true
description: 
tags: #discussion
---

A recent [Tweet](https://twitter.com/bendhalpern/status/1025447403896418305) by @Ben got me thinking, there many people out there that have made massive contributions to code and computers in general. Without these people It nearly wouldn't be the same as it would be today.

Such as Grace Hopper:

Often referred to as the first women in software she designed and created the first compiler in her spare time. Additionally she was one of the first programmers to start working on the Harvard Mark I. She has done a lot in the computer science world, everything from being an Navy rear admiral, creating the compiler to creating COBOL one of the first high level programming languages ever made.

Tim Berners-Lee:

Does this man need an introduction? The reason why we're all tweeting away, facebooking and able to interact with millions of people over a computer is because this man invented the world wide web. 

There are many more people that have made contributions to the technology today. Who do you think has made a significant impact for development, and tech?
How it's like to refactor code, written by other developer?
Tags: discuss
Published: 2018-08-06 16:32:24

---
title: How it's like to refactor code, written by other developer?
published: true
description: 
tags: #discuss
---
Currently, I am working in Menuboard manager project written by some other developer. Now, the developer is out of contact. So, I am given the task to refactor his code and add some module. My question is How can one understand the flow of code without any code documentation and project goal??
What's Your Process for Designing a Website
Tags: discuss
Published: 2018-08-06 15:50:26

---
title: What's Your Process for Designing a Website
published: true
description: 
tags: discuss
---

I'm redesigning my personal site from scratch and it's a little more challenging than I expected. The main challenge I'm facing is that I have too many creative ideas I want to implement and some conflict. 

My process:
1. Write out a plan (the layout options, potential content, images, typography, etc.)
2. Draw out the wireframe
3. Create mocks
4. Choose the most suitable color scheme/typography
5. Start designing the site.

How do you guys start out designing your site(s)? The steps, thought process, planning, etc.
App Engineの標準環境でNuxtを使って無料SSR
Tags: vue, nuxt, gae, firebase
Published: 2018-08-03 13:04:53

---
title: App Engineの標準環境でNuxtを使って無料SSR
published: true
description: 
tags: vue,nuxt,gae,firebase
canonical_url: https://crieit.net/posts/App-Engine-Nuxt-SSR
---

Google App Engine（GAE）のStandard EnvironmentにNode.jsが追加されているようです。元々Node.jsは有料のFlexible環境でしか使えなかったため、無料で使えるようになったのは非常に嬉しいです。

元々Firebase HostingやNetlifyで無料でNuxtを動かす事はできるのですが、それらは静的ホスティングサービスのためSSR（サーバーサイドレンダリング）ができません。（Functionsを使ったり等で可能ではあるようですが、アクセスが増えると費用がかさむようになると思います）

GAEであればサーバー上でNodeが動くためSSRも問題なく可能でSEO的にも良さそうです。ということでとりあえずGoogle App Engine上でNuxtを動かしてSSRできるところまで試してみました。

Windows SubsystemのUbuntu上で動かしました。

## ローカルでNuxtプロジェクトの初期化

まずはローカルでNuxtプロジェクトを作成し、動作するようにします。

```sh
vue init nuxt-community/starter-template nuxtproject
cd nuxtproject
yarn
```

とりあえずこれで動くかざっと確認しておきます。

```sh
yarn run dev
```

http://localhost:3000にアクセスして動いていればOKです。

GAEにはビルド済みのものをデプロイするため、予めNuxtプロジェクトのビルドまで行っておきます。

```sh
yarn run build
```

## Google App Engine用の設定

[Nuxt.js on Google App Engine（GAE)](https://qiita.com/SatoTakumi/items/4f418dc5c700b9d66d7d)

上記のページを参考にし、package.jsonのstartスクリプトにポートとホストの設定を行っておきます。（ポートは不要とコメントには書かれているようです）

```json
"start": "HOST=0.0.0.0 PORT=8080 nuxt start",
```

app.yamlも作っておきます。handlersを設定して静的ファイルをキャッシュするようにしないとメモリ不足で止まってしまうらしいです。

```yaml
runtime: nodejs8
env: standard
handlers:
- url: /_nuxt
  static_dir: .nuxt/dist
- url: /.*
  script: auto
```

僕の場合はいつの間にか`.gcloudignore`ファイルがあったので、そちらにデプロイしないファイルを設定しておきました。ない場合は作っておきましょう。`.git`や`node_modules`をデプロイしてしまうとうまくデプロイできないらしいです。

あとはGAEにデプロイします。

```sh
gcloud app deploy
```

ただ、僕の場合エラーになりました。下記を参考にし、sqlite3のライブラリをインストールします。その後Pythonもインストールし直しが必要のようです。僕はpyenvを使っていたためアンインストールとインストールし直しが楽だったので助かりました。

[【ubuntu】ImportError: No module named '_sqlite3'とでたときの対処法【Python】](https://qiita.com/chatrate/items/bc37e3b7b303e834dd1e)

```sh
sudo apt-get install libsqlite3-dev libbz2-dev libncurses5-dev libgdbm-dev liblzma-dev libssl-dev tcl-dev tk-dev libreadline-dev
```

## まとめ

あとはGAEへのデプロイが完了したらメッセージに表示されているようにコマンドやURL直接アクセスで動作確認することができます。問題なくNuxtが動作している画面が表示されていれば完成です。

ソースを見てみるとVueコンポーネント内の文字列などが表示されていると思います。

ただ、Google App EngineのStandard Environmentはデフォルトで128MBのメモリしか無いようです。無料枠だとそれを使うしかないのですが、Nuxtを利用したNode環境だとどの程度の動作まで耐えきれるのかが謎です。引き続き試していってみたいと思います。
The 7 Most Popular DEV Posts from the Past Week
Tags: top7, bestofdev
Published: 2018-08-06 14:38:19

---
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, bestofdev
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---

# 1. 🤒 git pain 🤕

Alex asks 11 Git interview questions in escalating difficulty.  For each, there's a detailed answer — many including code snippets and diagrams.  Try to challenge yourself by checking out the question before glancing at the answer.  

{% link https://dev.to/aershov24/11-painful-git-interview-questions-you-will-cry-on-1n2g %}

# 2. 👣 The Great Editor Journey 👣

From Sublime to Vim to Emacs to VS Code.  Lucas shares key considerations that marked the transition from editor to editor.

{% link https://dev.to/lucasprag/my-editor-journey-sublime-vim-emacs-vscode-19k0 %}

# 3. 🤘 Building a kickass portfolio 🤘

Ali some key insights gleaned from building and re-building her personal homepage.  It's one of the few sites where you get to have full ownership and creative control, so don't hold back.  She also links to a number of other great portfolios.

{% link https://dev.to/aspittel/building-a-kickass-portfolio-28ph %}

# 4. A checklist for commits ✔️✔️✔️✔️✔️ 

Are your commits Frequent, Descriptive, Atomic, Decentralized, and Immutable?

{% link https://dev.to/sublimegeek/do-your-commits-pass-this-simple-test-4ak2 %}

# 5. The JavaScript treadmill 🏃‍

JavaScript fatigue is real.  But are you ready to embrace this new world?  This post introduces some terrific resources and methods for keeping up.


{% link https://dev.to/superkarolis/keeping-up-in-the-javascript-world--50pl
 %}

# 6. Introducing Codier 🚀

What began as a university project is now Codier — a place for front-end coding challenges and community inspiration.  This is beautifully designed and it looks like it's off to a great start 🙌🏽.

{% link https://dev.to/kebabyusuf/introducing-codier---front-end-coding-challenges-and-creations-l7j %}

# 7. 👤 Spoof a Commit 👤

This was a bit unsettling.  Alex describes how to forge a commit, and the best way to verify and sign yours. 

{% link https://dev.to/agrinman/spoof-a-commit-on-github-from-anyone-4gf4 %}