teleren/devto huggingface dataset:
Bite the bullet and roll with the punches. Starting to learn ELM. 
Tags: elm, elmlang, functional
Published: 2017-12-22 14:00:21

---
title: Bite the bullet and roll with the punches. Starting to learn ELM. 
published: true
description: I've been meaning to learn ELM and now I'm even more excited to learn it. I found some great educational material and I will share it here.
tags: elm, elm-lang, elmlang, functional
---

I've been meaning to learn ELM and now I'm even more excited to learn it. I found some great educational material and I will share it here.

Videos:

1) The first one is a course by James Moore. I started watching it a little bit. Great explanations and the course is practical. Price: FREE.


https://courses.knowthen.com/courses/enrolled/86520

2) The second one is a course also by James Moore. Called "Elm beyond the basics". It's not free, but I want to buy it. There are team licenses, so if you want to cheap in let me know. Price: $45. 

https://courses.knowthen.com/p/elm-beyond-the-basics

3) The third one is a screen cast with 51 episodes https://elmseeds.thaterikperson.com/

4) The fourth one is a course by Richard Feldman. Price: $39 a months. It's a cost to a subscription for Frontendmasters website.

https://frontendmasters.com/courses/elm/

5) The fifth one is also a course by Pragmatic Programmers. Price: $68 They also have a team discount and a discount until 31st December with coupon code MERRY2017. https://pragmaticstudio.com/elm 

Books:

1) Elm in action by Richard Feldman https://www.manning.com/books/elm-in-action

It's still in progress, but Richard has produced a lot of great materials already. And he is here on dev.to, https://dev.to/rtfeldman/i-am-the-author-of-elm-in-action-ask-me-anything

He also open sourced an SPA app in elm https://dev.to/rtfeldman/tour-of-an-open-source-elm-spa

2) Pragmatic Programmers also have a book on ELM https://pragprog.com/book/jfelm/programming-elm Price: $22.

I'n not an ELM programmer and I haven't read the books so I can't really provide any useful feedback. But I hope this compilation is useful for you.

This in unfinished post, I also will later write add my experience of learning Elm and what I meant by bite the bullet and roll with the punches.
Making NSCollectionView programatically in Swift
Tags: appkit, nscollectionview, swift
Published: 2017-12-22 08:41:18

---
title: Making NSCollectionView programatically in Swift
published: true
description: 
tags: appkit, nscollectionview, swift
---

Original post https://github.com/onmyway133/blog/issues/131

Here's how to create `NSCollectionView` programatically. We need to embed it inside `NScrollView` for scrolling to work. Code is in Swift 4

### NSCollectionView

```swift
let layout = NSCollectionViewFlowLayout()
layout.minimumLineSpacing = 4

collectionView = NSCollectionView()
collectionView.dataSource = self
collectionView.delegate = self
collectionView.collectionViewLayout = layout
collectionView.allowsMultipleSelection = false
collectionView.backgroundColors = [.clear]
collectionView.isSelectable = true
collectionView.register(
  Cell.self,
  forItemWithIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell")
)
```

### NScrollView

```swift
scrollView = NSScrollView()
scrollView.documentView = collectionView
view.addSubview(scrollView)
```

### NSCollectionViewItem

```swift
final class Cell: NSCollectionViewItem {
  let label = Label()
  let myImageView = NSImageView()

  override func loadView() {
    self.view = NSView()
    self.view.wantsLayer = true
  }
}
```

### NSCollectionViewDataSource

```swift
func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
  return coins.count
}

func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
  let cell = collectionView.makeItem(
    withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"),
    for: indexPath
  ) as! Cell

  let coin = coins[indexPath.item]

  cell.label.stringValue = coin.name
  cell.coinImageView.image =
    NSImage(named: NSImage.Name(rawValue: "USD"))
    ?? NSImage(named: NSImage.Name(rawValue: "Others"))

  return cell
}
```

### NSCollectionViewDelegateFlowLayout

```swift
func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) {
    guard let indexPath = indexPaths.first,
    let cell = collectionView.item(at: indexPath) as? Cell else {
      return
  }
}

func collectionView(_ collectionView: NSCollectionView, didDeselectItemsAt indexPaths: Set<IndexPath>) {
  guard let indexPath = indexPaths.first,
    let cell = collectionView.item(at: indexPath) as? Cell else {
      return
  }
}

func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize {

  return NSSize(
    width: collectionView.frame.size.width,
    height: 40
  )
}
```
container-upというツールを書いた
Tags: docker, go
Published: 2017-12-23 13:11:40

---
title: "container-upというツールを書いた"
published: true
tags: docker,go
canonical_url: https://blog.web-apps.tech/container-up/
---

 ![container-upというツールを書いた](https://blog.web-apps.tech/content/images/2017/12/container-up.png)

[container-up](https://github.com/nasa9084/container-up)というツールを書いたのでご紹介。

## 背景

このブログは[ghost](https://ghost.org/)というブログエンジンで動いています。動作環境として[Docker](https://www.docker.com/)を使用していて、Ghostの[公式イメージ](https://hub.docker.com/_/ghost/)を使用しています。  
過去の経緯から、単体のDockerコンテナで動作させており、永続データはDockerボリュームとしてマウントしている形です。

扨、Docker ComposeやKubernetesなどのオーケストレーションツールを使っている場合、コンテナのバージョンアップは比較的簡単に行うことができます。  
たとえば、Docker Composeを使用している場合、`docker-compose up`で、新しいイメージで作成したコンテナに差し替えることができます。

しかし、Dockerを単体で使っている場合、基本的には手作業で差し替えを行う必要があります。  
Ghostコンテナの更新時は手作業でBlue-Greenアップグレードを行ってきたのですが、Ghostはかなりアップデートのペースが速く、毎度コンテナを差し替えるのが面倒になってきました。  
それを楽にするため、 **container-up** を作りました。

## インストール

### Go環境がある人

Go言語の環境がすでにある人は、以下のコマンドで使用できるようになります。

```
$ go get github.com/nasa9084/container-up
```

### それ以外の人

Go言語の環境がない人は、[Releases](https://github.com/nasa9084/container-up/releases)ページから自分のOSに併せてバイナリをダウンロード、パスを通してください。  
windows, linux, macos向け、それぞれamd64版のバイナリを用意してあります。  
動作確認はmacos、linux(CentOS 7)のみ行っています。

これら以外の環境の人は、予め[dep](https://github.com/golang/dep)をインストールした上で以下のコマンドでコンパイルしてください。

```
$ git clonse https://github.com/nasa9084/container-up.git
$ cd container-up
$ dep ensure
$ go build -o container-up main.go
```

コンパイルしたら、任意の場所にバイナリを移動し、パスを通してください。

## 使い方

基本的な使い方は、引数にコンテナ名またはコンテナIDを渡すだけです。

```
$ container-up CONTAINER_NAME
```

与えられたコンテナと同じ名称のイメージを使用して、ボリュームやネットワークなどの設定はそのままに新しいコンテナを作成し、差し替えます。  
`:latest`なイメージを使用している場合、`docker pull`した後にこのコマンドを実行することで、最新のイメージから作られたコンテナに差し替わるということです。

もとのコンテナは`--rm`オプションをつけて起動していた場合を除いて、`_oldContainer`というサフィックスが付いた状態でstopします。  
なにか問題があった場合は、このコンテナに戻すと良いでしょう。

もし、元のコンテナが必要ない場合は、`--rm`オプションをつけると、差し替え時に削除します。

```
$ container-up --rm CONTAINER_NAME
```

`:latest`ではないような、バージョンタグが付いたイメージを使用していて、新しいバージョンのイメージを使いたい場合などのため、新しいイメージ名を指定して実行することもできます。

```
$ container-up -i IMAGE_NAME CONTAINER_NAME
```

この場合、差し替えるコンテナは指定されたイメージで作成されます。

これらのコマンドでは、ボリュームのマウント設定は引き継ぎますが、それ以外のファイルはすべて新しいイメージに差し替わります。  
もし、ボリュームマウントしているところ以外に引き継ぎたいファイルなどがある場合<sup><a href="#fn1" id="fnref1">[1]</a></sup>、`-f`オプションにファイルパスを指定することで新しいコンテナにコピーすることができます。

```
$ container-up -f /path/to/file.ex CONTAINER_NAME
```

`-f`オプションは複数指定することができますので、複数のファイルをコピーしたい場合には複数回指定してください。

```
$ container-up -f /path/to/file1 -f /path/to/file2 CONTAINER_NAME
```

現状実装されている機能は以上です。  
ヘルプは`-h`オプションをつけることで見られます。

* * *
<section>
<ol>
<li id="fn1">
<p>たとえば設定ファイルなど <a href="#fnref1">↩︎</a></p>
</li>
</ol>
</section>
Teletype for Atom
Tags: discuss, atom
Published: 2017-12-22 02:56:49

---
title: Teletype for Atom
published: true
description: Could this be the Google Docs of writing code?
tags: discuss, atom
cover_image: https://user-images.githubusercontent.com/29592817/32577928-477e444e-c490-11e7-9118-3c69e51bf097.png
---

GitHub has recently introduced Teletype in to their Atom Editor.

From their website:
> Teletype(beta) for Atom lets developers share their workspace with team members and collaborate on code in real time.

It seems to bring a live edit feature similar to Google Docs right into the editor. Has anyone else had a chance to try this out?

Find more out about on their site https://teletype.atom.io/ or from the blog post on GitHub's blog https://github.com/blog/2468-introducing-teletype-for-atom-code-collaboratively-in-real-time
Производительность AMQP-клиентов на PHP. Benchmark`и всех!
Tags: php, benchmarks, queue, amqp
Published: 2018-02-08 11:34:33

---
title: "Производительность AMQP-клиентов на PHP. Benchmark`и всех!"
published: true
tags:  php, benchmarks, queue, amqp
canonical_url: http://phpprofi.ru/blogs/post/88
---

![](http://phpprofi.ru//resources/img/blogs/275ba737-729e-4a12-aaf2-53498cf63187.jpeg)

Рост популярности [AMQP interop](https://github.com/queue-interop/queue-interop#amqp-interop) вызвал волну вопросов относительно того, какой адаптер является самым быстрым. В этом посте я хочу поделиться своими выводами о производительности постановки сообщений в очередь. Позже будет подобный пост о "разгребании" очереди.

Рассмотрим:

- [php-amqplib](https://github.com/php-amqplib/php-amqplib)
- [amqp-ext](https://github.com/pdezwart/php-amqp)
- [bunny](https://github.com/jakubkulhan/bunny)

а также их адаптеры с имплементацией `AMQP interop`:

- [enqueue/amqp-lib](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/transport/amqp_lib.md)
- [enqueue/amqp-ext](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/transport/amqp.md)
- [enqueue/amqp-bunny](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/transport/amqp_bunny.md)

и один из мира Golang:

- [streadway/amqp](https://github.com/streadway/amqp)

----
Читать далее: http://phpprofi.ru/blogs/post/88

----
En: https://blog.forma-pro.com/php-amqp-clients-benchmark-them-all-8a4e6adb1a6b
Things that weren't so obvious when you started to program in Python
Tags: python
Published: 2017-12-21 21:04:56

---
title: Things that weren't so obvious when you started to program in Python
published: true
description: If I had known, I would not have written so much junk code.
tags: #python
---

I introduced myself in the programming world using very basic languages. Since 4 years ago, I created many many projects using Python, but although the Python Zen says "_There should be one-- and preferably only one --obvious way to do it._", some things aren't obvious.


## One line conditionals.

My old code has too redundant code, specially with conditionals:

```python
if x < 56:
    some = "Dafaq"
else:
    some = "Nope"
```

Nothing simpler than putting:

```python
some = "Dafaq" if x < 56 else "Nope"
```


## One line filtering lists.
One of the most common situations in Python is "filtering" lists. My old way:

```python
a = [2, 24, 88, 32, 1, 6, 88, 10, 15, 34] # example list.
b = []
for i in a:
    if i >= 15:
        b.append(i)
```

Best way:

```python
a = [2, 24, 88, 32, 1, 6, 88, 10, 15, 34] # example list.
b = [i for i in a if i >= 15]
```


## One line sum list values.

Other of the most common things is to sum up the values of a list. My old way:
```python
amounts = [2, 24, 88, 32, 1, 6, 88, 10, 15, 34] # example list.
total = 0
for i in amounts:
    total += i
```

Best way:
```python
amounts = [2, 24, 88, 32, 1, 6, 88, 10, 15, 34]
total = sum(amounts)
```


## In the next chapter...
_Things that weren't so obvious when you starting to using Django..._
Surviving technical debt in the real world
Published: 2017-12-21 20:33:02

---
title: Surviving technical debt in the real world
published: true
description: Surviving technical debt in the real world
tags: 
---

Technical debt is a potentially crippling disease that can take over your codebase without much warning. One day, you’re building features, the next, you struggle to untangle the mess you (or maybe your team) has created.

The good news is you’re not alone. Engineers everywhere accrue technical debt, the trouble is when you never do anything to get yourself out of debt, you just keep smashing features out into the dark abyss of GitHub.

You can train yourself not to take a shortcut all the time, and start to learn the benefits of technical debt when used properly. All it takes is a bit of willpower. Yes, the same thing you use if you want to shed a few kilos. When you take short cuts all the time, it’s hard to bust out of that groove and future proof things.

## Top tips for tech debt

### Does it even work?
Always be testing your code. Even when you write code that you can see is bad, write a test so that when you refactor it you can have a level of confidence it’s still going to work.


### You’re not in control of all situations
There might come a time when you’re pressed to get things done now. When that happens, get it done and take a cheat day. There’s nothing wrong with this, after all you are not your code and businesses want things done yesterday.

Just try to record you took the shortcut perhaps with a Fixme comment and plan to refactor.

### Bugs are bad, mmkay
Be okay with pushing bugs to production. Bugs are not created equally, so of course don’t be okay with breaking the application, but small bugs are going to happen. It is not a measure of your expertise as a developer that you missed it. Rather, I would measure a person’s commitment to fixing said bug rather than producing it in the first place.

### Catch it in code review
Code review is an effective exercise for both reviewer and author. If something is a short cut, make sure the author knows. On the flip side, as an author, make sure you let reviewers know the code could be improved but you will fix it later. Ownership of tech debt is important, because in a team it can often get lost as nobody’s problem until you all have to deal with it.


### Don’t overuse technical debt as an excuse to write bad code
Use technical debt sparingly. If you are spending more time justifying why the code you’re writing is technical debt than writing code. I have bad news for you.

It ain’t technical debt. 

It takes a lot of self control and willpower not to take the easy road, especially when you discover someone else’s technical debt, which they have not bothered to refactor.

It’s a skill, which once mastered, means your coworkers will thank you.

I am by no means an expert at not writing or fixing technical debt, but it has become a satisfying effort for me to fix what was once broken or difficult to understand.

If you’ve read this far, you probably have enough willpower to fix tech debt already…
Mockery: разные возвращаемые значения при разных аргументах
Tags: php, test, mockery, webdev
Published: 2018-02-06 20:06:07

---
title: "Mockery: разные возвращаемые значения при разных аргументах"
published: true
tags:  php, test, mockery, webdev
canonical_url: http://phpprofi.ru/blogs/post/87
---

Иногда при работе с mock объектами библиотеки Mockery, мы хотим сообщить фейковому методу, чтобы он возвращал разные значения для разных аргументов. Это редкий случай, когда мне нужна эта функциональность, но каждый раз, когда мне это нужно, я счастлив, что она есть.

![](http://phpprofi.ru//resources/img/blogs/12fa3d80-ba45-48b8-a532-4052a01f5612.jpeg)

----
Читать далее: http://phpprofi.ru/blogs/post/87

----
En: https://robertbasic.com/blog/mockery-return-values-based-on-arguments/
What are some funny lines of code you've run/written into a project?
Tags: fun, productivity, discuss
Published: 2017-12-21 20:00:35

---
title: "What are some funny lines of code you've run/written into a project?"
published: true
description: "Bonus points if it's in the company codebase."
tags: fun, productivity, discuss
---

Well, it's holiday season in the US and I've been gradually becoming less productive. I'd like to say it's because I have family over and that I haven't had enough sleep lately, but that's only part of the equation. To combat feeling like I've been doing less, though, I decided to work on some smaller tasks and clean up some code that I wrote previously.

Anyway, I ran into a small error when cleaning up the database seed file -- basically a file that you run to create dummy data for development -- and decided to fix it right then and there. No better time than now, right?

To give some background, our tags have two columns, `bg_color_hex` and `text_color_hex`. They're supposed to take in a hex code, and we properly restrict it to alphanumeric characters and a limit of 6 of those in a row -- well, that's what I think it is since it's a regex validator and I didn't want to translate it 🙃. 

There is, _however_, an annoying edge case where we can input it a hex code without the pound sign/hashtag/whatever-people-call-it-nowadays in front of the 6 characters, and the validator will throw us an error. There's no reason for that to not be automated, so I went for it.

As I'm writing the method out, I suddenly had a moment of glorious inspiration. In our quiet office, I smiled to myself at my _extreme_ cleverness.

![me-smiling-like-the-grinch](https://media.giphy.com/media/B5AVgxf0OzlyE/giphy.gif)
<figcaption>More silly and less creepy though.</figcaption>

So, in great joy I wrote out a method that puts the pound sign in front of the color attributes if necessary:
```ruby
  def pound_it
    text_color_hex&.prepend("#") unless text_color_hex&.starts_with?("#")
    bg_color_hex&.prepend("#") unless bg_color_hex&.starts_with?("#")
  end
```
<figcaption>"Pound it" is a slang term in the US for fist bumping. Fist bumping is like high fiving, except with your fist. And their fist, ideally.<figcaption>

Now, the code could probably be refactored, but the beauty of course lies in the name. This happens every time a tag is validated, so know that you are indeed "pounding it" every time you hit the Preview or Save button for your posts.

Hopefully, this end-of-year post will inspire you to do something similar. What are some funny bits of code that you've run into? Have _you_ written anything in your code and gotten it through all the red tape of your company? Would love to hear your stories!
What’s the architecture of your system?
Tags: architecture, design, performance, craft
Published: 2017-12-21 16:42:18

---
title: What’s the architecture of your system?
published: true
description: Software architecture design and concerns
tags: architecture,design,performance,craft
---
I once had an interesting debate with fellow developers over a software performance concern, which prompted us to revisit our architecture. Some argued that we needed a new architecture and indeed some of that work was underway. I had raised a few concerns over some of the architectural decisions that had been made in the past when I first joined the team but for entirely different issues. My particular concerns centered on testability. More precisely, it was practically impossible to test the system without having everything connected. From the UI down to the database – everything had to be running. 

The first architectural decision made was Angular. This clearly struck a chord in my spine as I wrestle the idea. I thought to myself, Angular is a detail. Moreover, a detail that ought to remain hidden from an architectural perspective. The architecture of a system shouldn’t deal with how it is delivered – in my view at least. It is almost like describing the architecture of a house by the types of bricks and cement used. To architect a system is to carefully draw boundaries around the various components that make up that system and connect them in a thoughtful manner, i.e manage dependencies, without revealing the details. The delivery mechanism is a detail. 

But what about agile, you may ask? Didn't we abandon the idea of big upfront designs? Is this what I'm suggesting? The answer, of course, is no. Good architecture is revealed slowly over time as the system grows. It is not something that you and I can craft over the weekend and be set for the remained of the system's lifetime, but rather something fragile - Hence the idea of keeping details hidden. I find it helpful to think of what to keep out rather than what to include when dealing with architectural design. The more I can keep out, the better.
Safari Technology Preview 46 Includes Service Workers
Tags: webdev, news, safari
Published: 2017-12-21 16:09:41

---
title: Safari Technology Preview 46 Includes Service Workers
published: true
description: 
tags: webdev, news, safari
---

Web devs who have gotten into using service workers in browsers that support them are pretty excited about Safari releasing a preview of the Webkit implementation. Service Workers provide a lot of control to the developer in terms of how content is fetched from the network and how it is stored in the browser.

{% link https://dev.to/lauragift21/explain-like-im-five-how-does-service-workers-work-545 %}

{% link https://dev.to/tarun_garg2/getting-started-with-service-worker %}

{% tweet 943545583909838849 %}

{% tweet 943583014298234880 %}

[dev.to](/) makes use of Service Workers and this will help us lean in more on the technology.

Happy coding ❤️
5 More Gotchas of Defer in Go — Part II
Tags: go, programming, tutorial
Published: 2017-12-21 15:59:58

---
title: "5 More Gotchas of Defer in Go — Part II"
published: true
description: Protect yourself from basic defer gotchas. For beginners.
tags: go, golang, programming, tutorial
---

[![](https://thepracticaldev.s3.amazonaws.com/i/uigqjmfdic34nq31n0ex.png)](https://blog.learngoprogramming.com/5-gotchas-of-defer-in-go-golang-part-ii-cc550f6ad9aa)


## What is inside?

* Z to A
* Scope ate my param
* Quick to run the params
* Captured in a Loop
* Point of no return?

**👉 [Press here to read the new article](https://blog.learngoprogramming.com/5-gotchas-of-defer-in-go-golang-part-ii-cc550f6ad9aa)**.

*See you in two weeks!*

---

[Learn Go Programming](https://blog.learngoprogramming.com)

👉 I’m tweeting tips and tricks about Go almost daily, [follow me on twitter](https://twitter.com/inancgumus) and get them.
Zeroqode’s small victory at TechCrunch Disrupt in Berlin
Tags: techcrunch, startup, nocode, developers
Published: 2017-12-21 15:33:20

---
title: Zeroqode’s small victory at TechCrunch Disrupt in Berlin
published: true
description: Zeroqode’s small victory at TechCrunch Disrupt in Berlin
tags: TechCrunch, startup, no-code, developers
---

Throw back to TC Disrupt event with [our interview](https://blog.zeroqode.com/zeroqodes-small-victory-at-techcrunch-disrupt-in-berlin-101b47a17e25) for Tech Crunch. We’re excited to share this video and hear the feedback from you!
Building a news feed with Firebase
Tags: discuss, firebase, reactnative, help
Published: 2017-12-21 12:13:32

---
title: Building a news feed with Firebase
published: true
description: 
tags: discuss, firebase, react-native, help
---

Hey everyone,

I am currently building a React Native application for a college project. The app is a simple social network that lets you do the basic things and uses Firebase to store user data. 

Like every other social network, the app will have a timeline/feed for each user and users will be able to follow each other on the platform. 

Now, how would you go about building a (fairly) scalable news feed with Firebase? 

*My current implementation stores the timeline for each user, and whenever someone they follow posts something, the timeline field gets updated. This is obviously not scalable at all, as it would use up a lot of resources when a user has millions or thousands of followers.*

Would really appreciate any kind of help here, this has been a tricky solution for me to solve :)