teleren/devto huggingface dataset:
Quick Tip -- F# Code Organization
Tags: fsharp, organization
Published: 2018-03-31 15:51:08

---
title: Quick Tip -- F# Code Organization
published: true
description: 
tags: #fsharp #organization
---

When I started programming F# I would run into the conundrum of where to place types and the functions on those types. Today it occurred to me that I have settled into a nice pattern for this and I thought I would share it.

The directory structure looks something like this:

* MyLibrary (project or even folder)
  * Types.fs
  * Widget.fs
  * Gismo.fs
  * ...

In functional programming types are shared things. They are the junction point between different functions -- both your own and code which uses your library. Here's the pattern for the Types file. Notice the `[<AutoOpen>]` attribute on the module.

```fsharp
// Types.fs
namespace MyLibrary

[<AutoOpen>]
module Types =

    // type defs go here, no functions

    type Widget =
        {
            ...
        }

    
    type Gismo =
        {
            ...
        }

    ...
```

Here is a Widget module containing functions for the `Widget` type.

```fsharp
namespace MyLibrary

module Widget =

    // the Widget type is automatically available in namespace
    let create ... : Widget =
        {
            ...
        }


    // so is the Gismo type
    let toGismo widget : Gismo =
        ...


    let fromGismo gismo : Widget =
        ...

    ...
```

Here's what happens when I use this library.

```fsharp
open MyLibrary

// Types.fs is automatically opened, exposing all types in it
// I can reference the Widget type without namespace
let returnsWidget ... : Widget =
    ...

// The Widget module is also exposed under the same name
let myFn ... =
    Widget.create ...
        |> ...
        |> Widget.toGismo
```

The way we have defined the namespace, types, and modules, the Widget type and all the functions on it will be nicely packaged together under the name `Widget` simply by opening the library. If you were to try to create the Widget type and the Widget module in the same namespace or module, you would get a compiler error because they have the same name. _Update: The previous sentence no longer seems to be true in newer versions of F#._

_You could achieve something similar by adding static extension methods onto the Widget type, but the above is more idiomatic. With type extensions, you can also run into problems with circular references._
Write a GIF player with Golang
Tags: go, gif, korok
Published: 2018-03-31 15:24:38

---
title: Write a GIF player with Golang
published: true
description: With korok we can write a gif player with less than 200 lines code.
tags: go,gif,korok
---

I just wrote a gif player with golang (less then 200 lines code). I use MAC a lot, but it can't play gif like windows, so this project come out.

It's a Golang project, also a [korok](https://korok.io) project. The core code is little:

```golang
func main() {
    gfile := flag.Arg(0)
    // decode !
    gp, err := Load(gfile)
    if err != nil {
        log.Fatal(err)
    }
    w, h := gp.Size()
    options := korok.Options{
        Title: "Gif Player",
        Width:w,
        Height:h,
    }
    korok.Run(&options, &MainScene{p: gp})
}
```

Gif decoding use Golong's gif module, the ui is setup with korok engine's GUI system. In fact, just one method is used:

```golang
gui.Image(1, m.img, nil)
```

This API will draw a Texture at (0,0) of screen. 

I have uploaded the project to Github: https://github.com/ntop001/xgif

About korok: it's component based 2d game engine in Golang, include a concise gui system. I use it to write some small tools. See: https://korok.io/
How to build a content builder in Craft CMS
Tags: craftcms, cms
Published: 2018-03-31 12:50:10

---
title: How to build a content builder in Craft CMS
published: true
description: Learn how to build a great authoring experience using Craft CMS's matrix field type.
tags: Craft CMS, CMS
---

{% youtube VSXglzqJ2Z4 %}

Learn how to build a great authoring experience using Craft CMS's matrix field type.

Read more about this technique on nystudio107's blog [nystudio107.com/blog/creating-a-content-builder-in-craft-cms](https://nystudio107.com/blog/creating-a-content-builder-in-craft-cms]).
Advice requested for my blogging method
Tags: discuss, beginners, portfolio
Published: 2018-03-31 11:24:46

---
title: Advice requested for my blogging method
published: true
description: Advice requested regarding my (newly created) blog!
tags: #discuss, #beginners, #portfolio,
---

Hello all,

First off, I'd like to say I'm happy to write my first post on here! In the short time I've been here, I noticed how great of a community this is and I hope to become actively involved!

So, to get to the point: I'm planning on starting to blog about some of my own projects and just general subjects that I'd like to learn more about and how I would apply it to a dataset. This was initially planned as a personal, private thing, but I noticed that it's handy to gain some online presence. As these things can easily be combined, why not just do it eh?

I wrote a few basic posts to try out what is possible on GitHub pages and now I feel confident enough to show you all my first setup of my site. It's nowhere near how I would like to have it in the end, but I would like to have some feedback and advice on its current state. Also, I don't think I'll keep the current site title, but we'll see down the road...

One of my biggest doubts is how I show my readers the used code: right now, I have a sort of spoiler element that hides the code until the user clicks on it. I chose for this method to increase readability of the posts themselves. Here is an example of my [latest post](https://mvdsman.github.io/blog/Simple-pairwise-alignment/).

Of course I'll have to do some manual editing when trying to publish the same posts to other platforms like Dev.to using Atom, since the spoilers are not imported very well. In these cases, I figured to just keep the standard method of showing code chuncks between paragraphs.

So, what is your approach and what is your opinion on how I decided to structure my posts?

PS: any feedback on other things are also very much appreciated!
はてなブログのHTTPS対応で混在コンテンツエラーに遭ったので対処しました
Tags: blog, https, web
Published: 2018-08-01 01:22:44

---
title: はてなブログのHTTPS対応で混在コンテンツエラーに遭ったので対処しました
published: true
tags: blog,https,web 
canonical_url: https://takimura.hateblo.jp/entry/2018/03/31/140829
---

![f:id:findcafe:20180331132220p:plain](https://cdn-ak.f.st-hatena.com/images/fotolife/f/findcafe/20180331/20180331132220.png "f:id:findcafe:20180331132220p:plain")  
ようやく私のアカウントも[はてなブログ](http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0)の[HTTPS](http://d.hatena.ne.jp/keyword/HTTPS)配信に対応したので有効にしてみました。[HTTPS](http://d.hatena.ne.jp/keyword/HTTPS)配信を有効にすることにより、通信の暗号化を行うことができます...

[Read more](https://takimura.hateblo.jp/entry/2018/03/31/140829)
Are there any good tutorials for React Native for experienced React developers?
Tags: discuss, javascript, react, reactnative
Published: 2018-03-31 03:25:47

---
title: Are there any good tutorials for React Native for experienced React developers?
published: true
description: 
tags: discuss,javascript,react,react-native
---

Hey guys, I'm about to start working on a React Native project, and for the last 9 months I have been using React on the web and I kinda want to skip the learning React and JavaScript part and jump right on the React Native specifics. Can you recommend me good tutorials that are made for established web/React developers?

I would also love if you have links to some expert/hardcore React Native tutorials so that I can go deeper into the matter later on.

Thanks in advance!
Go already has RSpec!
Tags: go, testing, rspec, tabledriven
Published: 2018-03-31 03:24:50

---
title: Go already has RSpec!
published: true
description: Writing BDD style tests using Go testing library
tags: go, testing, rspec, table-driven
---

You can use `(*testing.T).Run(string, func(t *testing.T))` to run each test case in isolation and also is more readable than table driven approach.

```go
import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestRateRecipe(t *testing.T) {
	t.Run("ok", func(t *testing.T) {
		res := post("/recipes/1/rating", nil)
		assert.Equal(t, res.Code, http.StatusOK)
	})

	t.Run("id is invalid", func(t *testing.T) {
		res := post("/recipes/foo/rating", nil)
		assert.Equal(t, res.Code, http.StatusBadRequest)
	})
}

```
The Fundamentals of Security Every Developer Should Understand
Tags: security
Published: 2018-03-30 15:07:52

---
title: The Fundamentals of Security Every Developer Should Understand
published: true
description: Some of the great DEV wisdom on security
tags: security
cover_image: https://cdn-images-1.medium.com/max/1920/1*yGvt69JA9m-KwDWjSH9DRg.jpeg
---

Last week I made this thread:

{% link https://dev.to/ben/what-are-some-fundamentals-of-security-every-developer-should-understand-3ki3 %}

I want to share with you some of the great answers. There is a ton of wisdom here, so read on.

{% devcomment 2knh %}

{% devcomment 2kml %}

{% devcomment 2kn2 %}

{% devcomment 2ko4 %}

{% devcomment 2l5h %}

### Speaking of fundamentals...

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

I hope this was helpful. There are a lot of specific rules we can follow in terms of security, but starting from principle is key. And we can never assume that everyone already knows and grasps the fundamentals. Go forth and secure your software!
Explain multiple setIntervals with same time.
Tags: explainlikeimfive, help, javascript, node
Published: 2018-03-31 01:58:48

---
title: Explain multiple setIntervals with same time.
published: true
tags: explainlikeimfive #help #javascript #nodejs
---
Since JavaScript is single threaded, if I set two time intervel to run 2 functions with same time. Will it execute 2 functions or just one?


For example I have set two set intervals to run two function every 30 minutes. 

Or it'll queue two functions for execution?
Access host from a docker container
Tags: docker
Published: 2018-03-31 00:20:38

---
title: Access host from a docker container
published: true
description: I wanted to access host port from a docker container. 
tags: #docker
---

This information is as of 2018-03-31 with Docker 18.03.0-ce

I wanted to access host port from a docker container. 

For example, an nginx process is running on the host machine with port 8888 open, then I would like to create a container which can curl host:8888.

I know how to discover container-to-container, but don't know how to get host IP address from a container.

Therefore, I wandered the internet.

## Precondition

I mainly use **Docker for Mac**, but sometimes use **Linux**. So I want my containers to run on both platform.

## TL;DR

https://github.com/bufferings/docker-access-host

## Host networking mode?

I found Docker has "host networking mode".

https://docs.docker.com/network/host/

With this mode, the container seems to be able access to the host with "127.0.0.1". How easy! I found it!

So I tried it and it works on my Linux machine, but it didn't work on my Mac. Then I found:

https://docs.docker.com/network/network-tutorial-host/#prerequisites

> The host networking driver only works on Linux hosts, and is not supported on Docker for Mac, Docker for Windows, or Docker EE for Windows Server.

(´・ω・｀) ok... let me find another way please.


## host.docker.internal?

I found I can resolve `host.docker.internal` as the host IP address in the container on Docker for Mac. Great! That's what I wanted to know! But... where's Linux version of it...?

(´・ω・｀) NotFound...

In addition, I was a little bit confused there're several names:

* docker.for.mac.localhost <- from 17.06.0 but now deprecated
* docker.for.mac.host.internal <- from 17.12.0-ce-mac46 but now deprecated
* **host.docker.internal** <- from 18.03.0-ce-mac59

https://docs.docker.com/docker-for-mac/release-notes

## Finally, my solution is like this.

I created `docker-entrypoint.sh` :

```bash
HOST_DOMAIN="host.docker.internal"
ping -q -c1 $HOST_DOMAIN > /dev/null 2>&1
if [ $? -ne 0 ]; then
  HOST_IP=$(ip route | awk 'NR==1 {print $3}')
  echo -e "$HOST_IP\t$HOST_DOMAIN" >> /etc/hosts
fi

(main entrypoint)
```

and create Dockerfile call this file as an entry point.

```bash
COPY docker-entrypoint.sh /usr/local/bin/

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
```

As a result, Docker for Mac do nothing because it has "host.docker.internal" and Linux version add it into hosts file.

(๑•̀ㅂ•́)و✧

The sample code is here:
https://github.com/bufferings/docker-access-host

I hope host.docker.internal will be added for Linux near future.

If you know better solution, please let me know.
What I Learned this Week (March 30, 2018)
Tags: discuss
Published: 2018-03-30 20:48:06

---
title: What I Learned this Week (March 30, 2018)
published: true
description: What I Learned this Week (March 30, 2018)
tags: discuss
---

## Directed Graphs: [Connected Components](https://en.wikipedia.org/wiki/Connected_component_%28graph_theory%29)

I started researching algorithms for finding Connected Components in a Directed Graph, for the purpose of being able to more efficiently add visibility into large dependency graphs (particularly in a database; e.g., job `J` uses table `T` to produce `T'`...).  This information could be used to develop more time-efficient schedules that produce data at my institution.  Having an idea how I would find "islands" in our dependency graph, I decided to research it and try to learn something about Graph Theory.

Further reading for me: [Strongly Connected Components](https://en.wikipedia.org/wiki/Strongly_connected_component) is a method to determine areas in a graph that are more strongly connected than others.  This seems pretty cool.  I wish I had a practical use for it!

## Relearn: [DAG: Topological Sort](https://en.wikipedia.org/wiki/Topological_sorting)

Regarding the above problem, I implemented a topological sort of our dependency graph to find all of the jobs that can run in parallel to make our scheduling more efficient.  Finally: I used something from a class in my job!  It is always satisfying using something that used to be homework.

## libclang

Apparently, you can leverage C frontend built for LLVM via the libclang library.  See [this post](https://shaharmike.com/cpp/libclang/) for more details.  Utilizing this, you can parse C++, traverse the AST--Great stuff.

There are even [nodejs bindings](https://www.npmjs.com/package/libclang).

## RPython

If you are wanting to produce a VM that supports interpreting _and_ a Just-in-Time compilation, RPython is pretty amazing.  [This article](http://tratt.net/laurie/blog/entries/fast_enough_vms_in_fast_enough_time.html) is a very interesting read.

**TLDR;** RPython is a VM generator: it consists of a language (a subset of Python) and a tool that analyzes `(interpreter code + hints)` and produces a (C-based) VM (interpreter + JIT) for you.

## Shibboleth

Recently I was brought on as a resource on a project in my department that requires integration with the Single Sign-On service Shibboleth.  Fun-fact: [Shibboleth is mentioned in the Bible](https://biblehub.com/esv/judges/12.htm) (Judges 12:6) as a way that the ancient Israelites enforced border-control during a time of hostility amongst their own clans.

Shibboleth as a product is highly configurable, and a semi-complex beast.  While I have previous experience with setting it up, it seems there is always something else to learn about it.  Most of my learning on this front has been spent in frustration whilst attempting to make it work in an equally complex, load-balanced environment.
Selam
Tags: deneme
Published: 2018-03-30 20:26:18

---
title: Selam
published: true
description: deneme
tags: deneme
---

        <?php 

        try {
	      $db=new             PDO("mysql:host=localhost;dbname=eticaret;charset=utf8",'root','12345678');
 //echo "hit the switch!";
}

catch (PDOException $e) {

	echo $e->getMessage();
}

 ?>
Have blocks return the last statement with the Comma Operator
Tags: javascript, webdev
Published: 2018-03-30 19:15:13

---
title: Have blocks return the last statement with the Comma Operator
published: true
description: A good use for a not so common feature of JavaScript
tags: javascript, webdev
---

Some languages allow for a syntax that allows for the last statement to be automatically be returned by the block.

```java
{ 
  System.print("one")
  System.print("two")
  System.print("three")
  2 + 4
}
```

We can achieve this in JavaScript with the [comma operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator).

```js
const doSomethings = () => (
    console.log(location.href),
    global.variable += 4,
    12 / 2
);
```

And just like that, the two code blocks from above would return the same thing!
Web Features Have No Versioning System
Tags: webdev, browserdev
Published: 2018-03-30 18:52:30

---
title: Web Features Have No Versioning System
published: true
description: After reading the HTML spec, I ran into this problem
tags: webdev, browserdev
---

Something I've noticed from being a web developer, looking out on the vast horizon of development platforms, is that being a web developer has a very unique set of challenges. I think that a lot of them arise from two factors. One is our best feature and the other is a fixable problem.

1) ""anyone can make a web browser""
2) the Web has no versioning system

The first problem, as I mentioned earlier, is actually our biggest feature but the problem arises because the user expectation is that our site, (full functionality aside) needs to "just work" in a way that at at the bare minimum, fails gracefully telling the user something about the status of the device they're on and if they can use the site.

The second is fixable. And no, I'm not proposing we have a Web 2, Web 3, etc. It's amazing that there isn't an order to the Web APIs such that vendors can implement them in the order that makes the most sense for the hardware the browser will be running on. However, from both a developers' and a potential new browser's perspective the fact that the progress of most specs can only be tracked through a Git commit history.

> ECMAScript itself and most CSS features don't particularly have this problem, but HTML and a lot of the Web API extensions to JavaScript run into the issue above

The WHATWG says they don't want to publish a spec with problems. And I get it. No one does, but what version numbers do is give developers a baseline of reference for what functions and features are available for their disposal. It would also give new and current browser developers checkpoints of functionality to tackle so that they could focus their efforts better. It would set up a way for the browser to know "hey this site wants WebUSB 2, but I know I only support v1, I should tell the user!"
Dear dev.to, I made it.
Tags: thankyou, discuss, career, developer
Published: 2018-03-30 18:42:10

---
title: Dear dev.to, I made it.
published: true
description: I took your advice.
tags: thankyou, discuss, career, developer,
---

On November 23rd, 2017, I wrote here seeking advice from the community about an important career decision. You can read that below... {% link https://dev.to/shripathy/i-am-quitting-my-job-as-a-project-co-ordinator-to-pursue-my-passion-as-a-developer-am-i-doing-the-right-thing-a8b %}

Everyone was supportive of the decision that I was about to take and reassured me that I was doing the right thing. Thanks to all of you, I quit my job a week after that on November 30th, 2017. 

The following month, I didn't do anything about my career and decided to have some "ME TIME". From January 1st, 2018, I started looking for jobs and also started working on my coding skills which I had lost touch because of my previous job. I wouldn't say I improved a lot over the past three months but I definitely learned few important skills for the job. 

After a lot of rejection emails(my lack of experience was the main reason), failed interviews and sleepless nights, there was one person who saw the passion in me (I am not going to mention his personal details here as I need to ask his permission before writing about him). He is not an HR person but the CTO startup called Paperflite and he asked my mobile number after seeing my resume on AngelList. Of course, I gave him my number and he called me up and we had a solid 30 minutes conversation about my previous jobs and about his startup. After that session,   he sent me a task which I successfully completed and then I was called up for an in-person interview(it was just a face to face discussion about my previous jobs and the task that he had given me). The interview ended on a positive note for me as I was selected for the job. 

So yeah... Here I am... 4 months after writing the above article... working as a developer for a startup called Paperflite. I would like to thank every single soul who encouraged me to take that decision, CTO who believed in me, the founder & co-founder of Paperflite who also believed in me and were supportive of my CTO's decision.

#Dear dev.to, I made it <3

P.S. Pardon if the story was boring and not well written. I expressed it as much as I can 😬

I rant about tech here - [@ShripathyR - Twitter](https://twitter.com//shripathyr)
I post few pictures here - [@Shripathy - Instagram](http://instagram.com/shripathy/)
I am planning to write more articles here - [@Shripathy - Dev.to](dev.to/shripathy)

![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/miu087w87btyq2ntntjw.jpg)
Work vs. Play
Tags: discuss, career
Published: 2018-03-30 18:16:49

---
title: Work vs. Play
published: true
description: What contrasts do you see when you compare what you do professionally versus what you're learning and doing for fun?
tags: #discuss #career
---

I've blogged a lot in the past about my Pebble watchfaces, and my journey with learning Dart, but today I wanted to talk about something else that's been on my mind recently.

**This isn't going to be a discussion about what technology is the best**, but a narrative around how I've noticed differences between what I do in my _career_ as opposed to what my _interests_ are, and the different things I've been _learning_.

Historically, I've always used Java and C# for most of the enterprise development I've done over my career. Android applications, Windows Apps, Java servers and services have all consumed a majority of my time when it comes to my career. I've even managed to sprinkle a little bit of web development in there using Durandal/Aurelia. Even in college, **we always used Java** to do most of our assignments. Java and C# were always languages that I was very comfortable using, and I still consider them the two languages that I know best.

What I've noticed recently, however, is that the things that I develop that don't get shipped to production are **vastly different** from the things I'm learning and developing for fun.

So much of my time coding spent away from Visual Studio/C# and Eclipse/Java/Maven has been spent in Visual Studio Code, working through tutorials on React, Angular, or Amber, or maintaining Hubot scripts written in CoffeeScript, or working on other miscellaneous JavaScript projects using NPM. I've began to slowly start becoming more and more comfortable with other languages, often times finding their features and tooling _better_ than what I've used in my professional life.

The contrasts to me are pretty astonishing. It's almost as if I'm happily living two separate lives as an engineer, each coinciding with one another and constantly evolving to become better and better at completely technologies and stacks.

What sorts of things do you notice about your professional work and your personal work? Do you do much of the same things professionally that you do personally? Or is the professional work you do as extremely different as what I'm noticing? 

If it's different, do you enjoy the difference and variety, or would you rather your personal and professional lives converged more? If not, what keeps you from breaking out of your comfort zone?