teleren/devto huggingface dataset:
I'm Jake
Tags: introduction, bio, whoami
Published: 2017-11-17 03:14:29

---
title: I'm Jake
published: true
description: 
tags: #introduction, #bio, #whoami
---

Hey guys,

My name is Jake Varness, and I'm a Software Engineer!

I've spent the last few years trying to be a polyglot of sorts, but I have spent a lot of my professional experience developing in C#, Java, and JavaScript.

I currently work as a Team Lead and Software Engineer at [Cerner Corporation](http://www.cerner.com), where I primarily develop software used by clinical and inpatient pharmacists around the world.

Before that I worked for [Service-Link](http://www.service-link.ca) developing electronic meter-reading software for utility companies across the US and Canada.

Currently, outside of my normal day-to-day at Cerner, I have been trying to learn a mixture of things here and there: Angular, TypeScript, React, Dart, Go, etc. I'm also trying to figure out what the best way is for me to contribute back to the FLOSS community... If you have some projects that you need work done on lemme know and I might sling some PRs your way!

Thanks for having me here dev.to community, and I hope that you all find whatever I say on here to be interesting or useful to your career!
How do you learn a new programming language?
Tags: discuss, learning, languages
Published: 2017-11-17 02:31:50

---
title: How do you learn a new programming language?
published: true
description: 
tags: discuss, learning, languages
---

Sign for a course maybe? Look for video tutorials on YouTube? Head-first into a book? Which one do you think is the best way?

I want to know your methodology, I'd be great if you pointed out your level of experience so we can maybe see if learning habits change with it.
Can I hide the type?
Tags: cpp
Published: 2017-11-16 20:20:12

---
title: Can I hide the type?
published: true
description: 
tags: cpp
---

Private member is not accessible from outer the class. Private member is inner only unless provide indirect method by pointer or reference.

And I can specify `private` for type.

For example,

```cpp
#include <iostream>

class foo {
private:
  class bar {};
public:
  static bar make_bar(void) {
    return bar();
  }
  static void print_bar(bar) {
    std::cout << "bar" << std::endl;
  }
};
```

I hope hide `foo::bar`. I do not want you make objects of `foo::bar` type.

In C++11 and later, you can use private types with `auto` or `decltype`.

```cpp
int main(void) {
  foo::make_bar(); // OK
  foo::print_bar(foo::make_bar()); // OK
  foo::bar x = foo::make_bar();    // Error : foo::bar is private
  auto x = foo::make_bar();        // OK : You can use `auto` in C++11 and later
  decltype(foo::make_bar()) y = foo::make_bar(); // OK : You can use `decltype` in C++11 and later

  return 0;
}
```

Is there way to hide the type?
Mention at PUG Challenge
Tags: openedge, datadigger
Published: 2018-01-22 20:05:21

---
title: "Mention at PUG Challenge"
published: true
tags: OpenEdge, DataDigger
canonical_url: https://datadigger.wordpress.com/2017/11/16/mention-at-pug-challenge/
---

Today, in the opening session of the PUG Challenge in Prague, DataDigger was mentioned as a good example of a nice open source project in OpenEdge. Well, of course, who am I to disagree? So thanks Mark!

[![pug_mention2](https://datadigger.files.wordpress.com/2017/11/pug_mention2.jpg?w=840)](https://datadigger.files.wordpress.com/2017/11/pug_mention2.jpg)

And also thanks to [Arno van der Ende](https://www.linkedin.com/in/arnovanderende/) for the photo

&nbsp;
Complete a Stream of CompletableFutures
Tags: java, stream
Published: 2017-11-17 10:39:40

---
title: "Complete a Stream of CompletableFutures"
published: true
tags: java,stream
canonical_url: https://jensonjava.wordpress.com/2017/11/16/convert-listcompletablefuture-to-completablefuturelist/
---

Sometimes I find myself in the situation where I have to perform some asynchronous tasks and perform another asynchronous task when all those tasks have been completed. As always in such situations, I’ve searched [stackoverflow](https://stackoverflow.com/questions/30025428/listfuture-to-futurelist-sequence) for a how-to and the top rated answer suggests the following solution:

{% gist https://gist.github.com/jklingsporn/b39128fac9c6d8cfe2a3e71241815c12.js %}


That solution totally works and it is good. However, if you often deal with `Streams`, a more functional approach would be neat. So I started coding a `Collector` that does this operation for me in one go. I won’t go into detail of how a `Collector` works, but this [blog-post](http://www.nurkiewicz.com/2014/07/introduction-to-writing-custom.html) helped me out a lot understanding it.

Finally I ended up with this solution, which I’ve uploaded to [github](https://gist.github.com/jklingsporn/f82b5248f33e0f23a15e33af1429dce3):

{% gist https://gist.github.com/jklingsporn/f82b5248f33e0f23a15e33af1429dce3.js %}

And here is how you would use it:

{% gist https://gist.github.com/jklingsporn/278c5e248ccc1a6d8483703b8c69cc0e.js %}

Happy coding!

* * *

**Update**

Obviously it was late yesterday D: The solution I posted was hidden in another answer with less upvotes. It suggest using `Collectors.collectAndThen` together with the sequence-method above. In my opinion this is cleaner than following my approach with writing the `Collector` on your own&nbsp;(DRY-principle). The final solution is posted below and it contains another `Collector`-factory method that can be used if you’re not interested in the results or the `CompletableFutures` to collect are of type `Void`.

{% gist https://gist.github.com/jklingsporn/9216cb6e71ff72ec3c20ff3ccfd50675.js %}

  
[![](http://feeds.wordpress.com/1.0/comments/jensonjava.wordpress.com/1121/)](http://feeds.wordpress.com/1.0/gocomments/jensonjava.wordpress.com/1121/) ![](https://pixel.wp.com/b.gif?host=jensonjava.wordpress.com&blog=28976806&post=1121&subd=jensonjava&ref=&feed=1)
ArangoDB : The new Graal ? Part 1
Tags: arangodb, javascript, foxx
Published: 2017-11-16 18:40:49

---
title: "ArangoDB : The new Graal ? Part 1"
published: true
description: First post about arangoDB & Foxx
tags: arangodb, javascript, foxx
---

# ArangoDB : The new Graal ? Part 1

I discovered [ArangoDB](https://www.arangodb.com) 2 years ago ... I was looking for something new, something fresh. I was bored about deploying new application for any new project. Then I found ArangoDB ... And I still wonder why few people know it !

ArangoDB is a multi-model database (key/value; documents; graph) with transactions and joins.

ArangoDB provide [Foxx](https://docs.arangodb.com/3.2/Manual/Foxx/AtAGlance.html), a micro service engine embedded in ArangoDB. Last but not least, Foxx services scales with database cluster. It's very powerful and can cover your needs for almost all your projects.

To be honest I use ArangoDB in single instance mode for now.

How does a service looks like ? 

```js
'use strict';
const db = require('@arangodb').db;
const createRouter = require('@arangodb/foxx/router');
const router = createRouter();

module.context.use(router);

router.get('/', function(req, res) {
    res.send({ hello: 'world' });
});
```

Easy, isn't it ? You can create any Rest verb you want (e.g. `router.get`, `router.post`, `router.put`, `router.delete`, `router.patch`)

Ok that's cool ... but how to interact with the database, the collections, the graphs ? 

ArangoDB provide a language request called [AQL](https://docs.arangodb.com/3.2/AQL/index.html) which will allow you to run requests in database just like SQL.

Let say we have created a collection called `posts`

Here an endpoint to load all posts filtered by a specific status and also return joined user.

```js
router.get('/posts/:status', function(req, res) {
    const documents = db._query(`
        FOR post IN posts
            FILTER posts.status == @status
            FOR user IN users
                FILTER posts.user_key == user._key
                RETURN { post: post, user: user }
    `, { status: req.pathParams.status });

})
```

ArangoDB UI will provide you a nice swagger documentation such as :
![swagger](https://www.arangodb.com/wp-content/uploads/2012/02/arangodb_web_ui_foxx.png)

The biggest benefit to run Foxx is that it is hosted in the heart of the database and requests are blazing fasts. 

On [Part 2](https://dev.to/solisoft/arangodb--the-new-graal--part-2-6mc) I'll show you how to secure your APIs with a [Json Web Token](https://jwt.io/)

For people working on OSX I wrote [foxx-framework](https://www.foxx-framework.com/) to simplify my daily workflow.
Fizz Buzz with compile time programming
Tags: scheme
Published: 2017-11-16 18:27:22

---
title: Fizz Buzz with compile time programming
published: true
description: 
tags: Scheme
---

[Fizz Buzz](https://en.wikipedia.org/wiki/Fizz_buzz) is screening problem for computer programmers. It is also used for esoteric programming play sometimes.

Kazuho [wrote a program](http://blog.kazuhooku.com/2017/11/fizzbuzz.html) to generate a string of Fizz Buzz at compile time in C++. gos-k also [wrote](http://gos-k.hatenablog.com/entry/2017/11/13/205634) in the same concept in Common Lisp.

And I wrote in Scheme (R6RS).

```scheme
(import (rnrs))

(define-syntax make-fizzbuzz-string
  (lambda(ctx)
    (syntax-case ctx ()
      ((_ n)
       (integer? (syntax->datum #'n))
       (call-with-string-output-port
         (lambda(port)
           (do ((i 1 (+ i 1)))
               ((< (syntax->datum #'n) i))
             (display
              (cond
               ((zero? (mod i 15)) "fizzbuzz")
               ((zero? (mod i 5))  "buzz")
               ((zero? (mod i 3))  "fizz")
               (else i))
              port)
             (newline port))))))))

(define (fizzbuzz)
  (display (make-fizzbuzz-string 100)))

(fizzbuzz)
```

For compile-time programming, LISP is much easier than C++.
dev.toに投稿してみた
Published: 2017-11-16 17:19:42

---
title: dev.toに投稿してみた
published: true
description: first post at dev.to
tags: 
---
初めてdev.toに投稿してみた。
hatebuの噂通り、とにかく爆速。
リッチじゃない分シンプル。

もしかしたら色々書いてみたいと思うかもしれない。
けど一回目はこんな程度にしておく。
Unity C# snippets
Tags: unity3d, cs
Published: 2017-11-16 15:29:19

---
title: Unity C# snippets
published: true
description: memo for code snippets
tags: #unity #cs
---

DateTime and long.

```
DateTime now	= DateTime.Now;

// convert DateTime to long.
long nowTics = now.Ticks;

// convert long to DateTime.
DateTime dt1 = DateTime.FromFileTime (nowTics); // NG.
DateTime dt2 = DateTime.FromFileTimeUtc (nowTics); // OK!

Debug.Log ("TEST now  .. (" + now.ToString ("yyyy-MM-dd HH-mm-ss") + ")");
Debug.Log ("TEST dt1  .. (" + dt1.ToString ("yyyy-MM-dd HH-mm-ss") + ")");
Debug.Log ("TEST dt2  .. (" + dt2.ToString ("yyyy-MM-dd HH-mm-ss") + ")");
```

String and int.

```
// string to int.
string nString = "128";
int n = int.Parse(nString);

// int to string
int a = 128;
string aString = a.ToString();
```

プラットフォーム判別.
```
// Platform Dependent.

#if UNITY_EDITOR
Debug.Log("Unity Editor.");
#else
Debug.Log("Not Unity Editor.");
#endif

#if UNITY_EDITOR_WIN
Debug.Log("Windows editor");
#elif UNITY_EDITOR_OSX
Debug.Log("macOS editor.");
#endif

#if UNITY_STANDALONE_WIN
Debug.Log("Windows standalone.");
#elif UNITY_STANDALONE_OSX
Debug.Log("macOS standalone.");
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
Debug.Log("Windows.");
#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
Debug.Log("macOS.");
#endif



#if UNITY_IPHONE
Debug.Log("ios.");
#elif UNITY_ANDROID
Debug.Log("android.");
#endif
```

コンストラクタ.
```
// Constructor.
public class Data
{
	public int id;

	public Data( int aId ){
		id = aId;
	}
}
```

Enum - Basic.
```
public enum Type{
	TYPE0	= 0,
	TYPE1	= 1,
	TYPE2	= 2,
	TYPE3	= 3,
	TYPE4	= 4,
	DEFAULT	= TYPE0,
}

Type typeTest = Type.DEFAULT;
```

Enum - Convert from an integer, or a string.

```
using System;

Type type1 = (Type)Enum.ToObject(typeof(Type), 1);

Type type2 = (Type)Enum.Parse(typeof(Type), "TYPE2");
```

Enum - Convert to an integer, or a string.

```
int  intType0  = (int)Type.TYPE0; // 0

string stringType0 = Type.TYPE0.toString(); // "TYPE0"
```

Array
```
float[] values = {1.0f, 1.0f, 1.0f};


float[] threeValues = new float[3];


// float[] mustSetSize = new float[];    // Error.

```

For-Loop for the children.
```
foreach (Transform child in transform)
{
    // child.gameObject.SetActive(false);
}
```

Write UTF-8 with BOM
```
string filepath = "test.txt";
bool append = false;
StreamWriter sw = new StreamWriter( filepath, append, System.Text.Encoding.UTF8 );

sw.Write ("UTF-8!\n");

sw.Flush();
sw.Close();
```

print stack trace
```
Debug.Log("called from.. @"+UnityEngine.StackTraceUtility.ExtractStackTrace());

```
Getting started to writing an App by Go
Tags: dep, go, programming, direnv
Published: 2017-11-16 15:17:17

---
title: "Getting started to writing an App by Go"
published: true
tags: dep,go,programming,direnv
canonical_url: 
---

We have things to care about when before writing the Go code.That is about management of GOPATH and vendor package versioning.

GOPATH is having a large package dependency scope by default.This cause a performance degradation of a build, editor, and other relational tools.Furthermore, it is difficult to manage package versions. _go get_ fetch packages to the same context of each package.

But we can solve this by changing GOPATH depending on that context.There are a little bit different method of the standalone apps and reusable packages.

I introduce how to get started.

# Install direnv

Before reading this, there is an article I wrote before, I recommend you read that first.

[Preparing the development environment for Go in late 2017](https://dev.to/hatajoe/preparing-the-development-environment-for-go-in-late-2017-a73)

_direnv_ is a tool that an environment switcher for the shell.

[direnv/direnv](https://github.com/direnv/direnv)

With this, you can use arbitrary directories as GOPATH.You can get a minimum scoped development environment in this way.

```
% echo $GOPATH
/Users/hatajoe
% cd work
% mkdir app
% cd app
% direnv edit .
use go go1.9.2
layout go
```

By doing this, GOPATH is changed to _/Users/hatajoe/work/app_ when moving into _/app_ directory.

# Install dep

_dep_ is a tool that for Go dependency management.

[golang/dep](https://github.com/golang/dep)

By using _dep_, we can fetch the same revision packages at any time.

# standalone apps

The definition of standalone is whether it is referenced by others or not.If you make a standalone app, doing like this.

```
% pwd
/Users/hatajoe/work
% mkdir app
% cd app
% direnv edit .
use go go1.9.2
layout go
% git init
% git add .
% git commit -m “initial commit”
% mkdir -p src/app
% cd src/app
% dep init
% ls
Gopkg.lock Gopkg.toml vendor
```
That’s it! We ready to start coding.

# reusable packages

If you make a reusable package, doing like this.

```
% pwd
/Users/hatajoe/work
% mkdir my-package
% cd my-package
% direnv edit .
use go go1.9.2
layout go
% mkdir src/github.com/hatajoe/my-package
% cd src/github.com/hatajoe/my-package
% dep init
% ls
Gopkg.lock Gopkg.toml vendor
% git init
% git add .
% git commit -m “initial commit”
```
You know that it has a little bit different from standalone apps.

---

Thank you for reading. Feedback is welcome.
If you have any ideas and improvements feel free to respond me!
Apache Groovy with Java 7 and 8 syntaxs
Tags: groovy, java
Published: 2017-11-16 15:02:11

---
title: Apache Groovy with Java 7 and 8 syntaxs
published: true
description: 
tags: groovy,java
---

Since Apache Groovy 2.6(latest vesrion is 2.6.0-alpha-2 at 2017-Nov-16) it can use Lambda syntax from Java8 and try-with-resources from Java7.
Groovist uses alreday like these functions.(Closure)
But adapting to Java's syntax is really important to reach Java Developer who doesn't use yet Apache Groovy.

Install Apache Groovy, then change file name from `Foo.java` to `Foo.groovy` and execute simply `groovy Foo.groovy`.
Java Developer equals Apache Groovy Developer  again since Apache Groovy 2.6.

But this functions are not yet standard on Apache Groovy.
Apache Groovy 2.6 supports optionally, Apache Groovy 3 support as default.
Apache Groovy 2.6 is yet alpha phase. but it is allready out. we can test it!

# Install Apache Groovy 2.6

Install via sdkman.
**Apache Groovy 2.6 is not yet support Java8 syntax as default**
It have to be specified an option `-Dgroovy.antlr4=true` by execute groovy.




```shell
[koji:~]$ sdk install groovy 2.6.0-alpha-2 
[koji:~]$ sdk use groovy 2.6.0-alpha-2

# to activate Java7/9 syntax.
[koji:~]$ groovyConsole -Dgroovy.antlr4=true&


# of course you can JAVA_OPTS.
[koji:~]$ echo $JAVA_OPTS

[koji:~]$ export JAVA_OPTS="-Dgroovy.antlr4=true"
[koji:~]$ echo $JAVA_OPTS
-Dgroovy.antlr4=true
[koji:~]$ groovyConsole&

```

# try-with-resources

```groovy
def file = new File("/tmp/test.txt")

/*
def fileReader = file.newReader()
println fileReader.ready()
fileReader.close()
println fileReader.ready() // java.io.IOException: Stream closed. of ocurse :)
*/

// try-with-resources ! Since Apache Groovy 2.6 can use!
try(BufferedReader br = file.newReader()) {
    br.eachLine {
        println it
    }
} catch(Exception e) {
    println e
}

// Normal Groovy way!
file.withReader {BufferedReader br ->
    br.eachLine {
        println it
    }
}

```

# Use Lambda


```groovy
// Lamda syntax is available!
java.util.function.Function<Integer, String> test = (i) -> {"${i} !?"}
assert "123 !?" == test.apply(123)

// Lambda with streams.
List<Integer> list = [1,2,3,4,5]
assert [10, 8, 6, 4, 2] == list.stream().map((a) -> {a * 2}).sorted((a, b) -> { return b - a; }).collect()

// Normal Groovy way!
assert [10, 8, 6, 4, 2] == list.collect{it * 2}.sort{a,b -> b <=> a}
```

I like Groovy style more than Java.
But this new syntax parser is really helpfull for Java Developer learning Apache Groovy.
Reviewers Needed
Tags: ruby, api, github, testing
Published: 2017-11-16 14:38:57

---
title: Reviewers Needed
published: true
description: 
tags: #ruby #api #github #testing
---

I am pretty well finished with the Tester Tour of the example testing for the GitHub API.  It shows, from the tester's point of view, how the REST API testing framework works.  This is part of my own GitHub project, RubyTest.

I'll be grateful for any reviewers' comments, which can be created as Issues on the RubyTest project itself (best, b/c records!), or can be emailed directly to me at burdettelamar@yahoo.com.

Links:
<ul>
	<li><a href="https://github.com/BurdetteLamar/RubyTest/blob/master/examples/github_api/TesterTour.md#tester-tour">Tester Tour</a> (please review)</li>
	<li><a href="https://github.com/BurdetteLamar/RubyTest/tree/master/examples/github_api">Example code for testing GitHub API</a></li>
	<li><a href="https://github.com/BurdetteLamar/RubyTest">RubyTest project on GitHub</a></li>
</ul>
API Design - securing user registration API endpoint with multiple clients
Tags: api, discuss, rails, node
Published: 2017-11-16 14:36:43

---
title: API Design - securing user registration API endpoint with multiple clients
published: true
description: 
tags: api, discuss, rails, nodejs
---

I'm currently working on a proof of concept system which involves a backend API which is used by multiple possible client applications, including mobile clients and a isomorphic React client.

I've largely taken care of authentication and authorization, the only remaining problem (that I can see at least) is the route to register users - POST /users/, as it is public with no authorization required. My main concern is protecting that route from malicious spamming beyond implementing CORS and rate limiting.

E.g. `curl -X POST -d "{ email: 'hello@gmail.com', password: 'nahnah' }" http://host.com/api/v1/users`

What would my options be here?

One solution I've come up with is force the SPA to submit the sign up form to an express route within the server that serves the SPA (it requires SSR) to make the API call on the server, meaning the browser's network tab will have no record of the API call. This would mean I'd also have to implement a CSRF token in the SPA. Or use reCaptcha?

Also, is this is just generally a bad idea?
dev.toは超高速だがまだ致命的に遅い
Tags: devio, performance
Published: 2017-11-16 14:13:48

---
title: dev.toは超高速だがまだ致命的に遅い
published: true
description: 
tags: #dev.io  #performance
---

それはログイン時。

ログイン方法が「Twitter認証」か「GitHub認証」しかないため、一度外部へ飛んでから認証を許可する操作をして、また戻ってくる。その外部（TwitterやGitHub）はdev.ioに比べて非常にレスポンスが遅い。明らかなボトルネックだ。

ログインセッションが非常に長く保たれるのかもしれないが、dev.toのユーザーはソフトウェアエンジニアが多いだろうから、きっとMacやスマホを何台も持っている。ログインは登録後も確実に何回かは行う操作であり、そのたびに外部へ認証をしにいくのはストレスフルだ。

だから一刻も早くパスワード認証の仕組みを作ってほしい。パスワードでの認証の仕組みをdev.io内に持てば外部サイトへ飛ぶ必要はないためいくらでも高速化が図れる。

パスワード認証だとそれを入力する手間もあるが、最近のブラウザはパスワードの保存と自動入力、そして他のデバイスとの同期は朝飯前だ。結果としてTwitterやGitHubの認証よりもずっと早くログインできるだろう。

以上、ikuwowの勝手な要望でした。
Lazy FizzBuzz
Tags: ruby
Published: 2017-11-16 13:39:10

---
title: Lazy FizzBuzz
published: true
description: 
tags: Ruby
---

I though up this [Fizz Buzz](https://en.wikipedia.org/wiki/Fizz_buzz) suddenly when I was about to go to the bathroom. So I made this note 😇

```rb
def genarate_lazy_list(number, yell)
  [*Array.new(number - 1, nil), yell].cycle
end

numbers = 1.step.lazy
fizzes = genarate_lazy_list(3,'Fizz')
buzzes = genarate_lazy_list(5,'Buzz')
fizzbuzzes = genarate_lazy_list(15,'FizzBuzz')

# Add backslash for irb. I prefer leading dots to trailing ones.
numbers \
  .zip(fizzes, buzzes, fizzbuzzes) \
  .map { |n, fizz, buzz, fizzbuzz| fizzbuzz || buzz || fizz || n } \
  .take(30) \
  .each(&method(:puts))
```
```:stdout
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
```