teleren/devto huggingface dataset:
The Rails presence Method
Tags: rails, ruby
Published: 2018-06-07 15:30:55

---
title: "The Rails presence Method"
published: true
description: A quick dive into a lesser used, but useful Rails method.
tags: rails, ruby
---

> Note: This article was originally written at <https://blog.edwardloveall.com/rails-presence-method>

Rails has a convenient method that I discovered the other day: `presence`. All it does is return itself if `present?`. It's a pretty simple method:

```ruby
def presence
  self if present?
end
```

The [documentation](http://api.rubyonrails.org/classes/Object.html#method-i-presence) has a great example that simplifies this:

```ruby
state   = params[:state]   if params[:state].present?
country = params[:country] if params[:country].present?
region  = state || country || 'US'
```

to this:

```ruby
region = params[:state].presence || params[:country].presence || 'US'
```

Here's another use case. Imagine your app has a page where you can search for users. There's a `show.html.erb` template, and two partials: `user.html.erb` and `no_results.html.erb`.

Your controller will search for users and assign them to an instance variable. If no users were found, we'd rather show the `no_results` partial instead of a blank page:

```erb
<% if @users.present? %>
  <%= render @users %>
<% else %>
  <% render 'no_results' %>
<% end %>
```

With `presence` we can make this code shorter but still readable.

```erb
<%= render @users.presence || 'no_results' %>
```

Most of the time `present?` is probably what you're looking for, but sometimes `presence` really cleans up your code. Keep it in mind.
AlphaGo - AIs might make us better humans
Tags: ai
Published: 2018-06-07 15:08:13

---
title: AlphaGo - AIs might make us better humans
published: true
description: AI might make us better humans
tags: ai
---

Yesterday I watched [AlphaGo](https://www.netflix.com/title/80190844), a documentary on Netflix about the legendary match between a top Go player, [Lee Sedol](https://en.wikipedia.org/wiki/Lee_Sedol) and the AI that [Google Deepmind](https://deepmind.com/) created.

I won't spoiler the details of the matches because I didn't know them either before watching the movie. I knew the overall outcome, but I didn't know the specifics. If you haven't seen it I think it's worth finding out in real time so I avoided Googling about it for a long time :D. The documentary is well made.

The monumental feat to create an AI that can play what is considered one the most complicated board games is definitely impressive.

Lee Sedol's skills are definitely impressive.

What made me think the most and stuck with me is a concept that was repeated more than one time in the film. I'm not quoting here but paraphrasing:

*The machine taught me something new about what it means to be a human*

To me that's the WOW part of the documentary. Yes we can talk about AI and neural networks, yes we are technicians yadda yadda but we're humans first and well, if we don't screw it up and stop making AIs to show us yet another picture of a dog on Instagram, we have the potential to truly make something mind blowing (well aside using CRISPR but that's another story for another day :D). 

AIs that ultimately change or expand our understanding of who we are in the first place.
10 Things I Regret About Node.js
Tags: discuss, typescript, go, node
Published: 2018-06-07 15:03:07

---
title: 10 Things I Regret About Node.js
published: true
canonical_url: https://www.iamdeveloper.com/posts/10-things-i-regret-about-nodejs-14m3/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/pedrq8fz6ig8yugihvbt.jpg
tags: discuss, typescript, go, node
---

Photo courtesy of flickr user [Trygve Lie](https://www.flickr.com/photos/trygve_lie/5831902960/in/photolist-9Tm2z3-9TkXYG-9Snmm2-9TiaVg-986fu7-91Lys4-af3D6G-91PELy-91PFdw-91LxWD-ir76Ci-8vTR8o-91PEMA-guo8Zw-guot1K-8vQPsx-9Skm3e-91LydX-8vQP9D-8izGEj-guo94j-UD21ff-27wa2Xi-9Skmgc-9SqeLo-9SwjVQ-VAVtVQ-Kc6jW6-9Swk7s-8vTQMJ-9Sobs3-aCccoi-8vQP4a-gunPQK-9SkkHP-9SkjYa-8vQNvP-gunfvN-fhpKFt-a31Gwp-8vTRij-9Skmpr-8vQNt4-fhpJRe-ir6Gd4-SyeqvE-9Sqdf1-9Swkk3-keuT4b-UqDk2W).

The creator of Node JS, [Ryan Dahl](http://tinyclouds.org), recently gave a talk at JSConf EU 2018 titled "10 Things I Regret About Node.js"

{% youtube M3BM9TB-8yA %}


It's a great talk about Node and he also goes into some details about his new project [Deno](https://github.com/ry/deno), a secure TypeScript runtime on V8.

Here's some of the things he regrets:

- dynamic languages are great for certain things. In a server though, you want things to be statically typed. (Probably why he wrote Deno in TypeScript and Go)
- design mistakes:
    - didn't stick with Promises in Node (in the beginning), keeping them could have sped up async/await development.
    - security
    - Build system (GYP)
    - package.json

Even Brendan Eich chimed in

{% twitter 1004425861410402304 %}

Give it a watch. I'm curious what everyone's thoughts are.
Ionic Vs React Native: Which is the Best Framework for Mobile App Development
Tags: blog, bestframework, ionicvsreactnativ, mobileappdevelopment
Published: 2018-06-21 09:21:15

---
title: Ionic Vs React Native: Which is the Best Framework for Mobile App Development
published: true
tags: Blog,Best Framework,Ionic Vs React Nativ,Mobile App Development
canonical_url: 
---
![](https://www.itfirms.co/wp-content/uploads/2018/06/Ionic-Vs-React-Native.jpg)

Do you know, there are 5 Billion people uses the smartphones in the world. And if you have a business and want to do it online via mobile app. First you should consider about the platform that is used in developing mobile app. There are available a various frameworks like Ionic, React Native etc. We have mentioned a [comparison between Ionic and React Native](https://www.itfirms.co/ionic-vs-react-native-check-the-best-framework-for-mobile-app-development/). It will be help you to choose best mobile app development framework.
nba_rb, a Ruby wrapper for the NBA Stats API
Tags: nba, opensource, ruby, analytics
Published: 2018-06-07 13:57:41

---
title: nba_rb, a Ruby wrapper for the NBA Stats API
published: true
description: Launching nba_rb to the community
tags: nba,opensource,ruby,analytics
---

In the past couple of years I've worked on and off to put together [nba_rb](https://github.com/FanaHOVA/nba_rb), a Ruby wrapper for the NBA Stats API. I've been using this in a private project for a while and found a lot of use it for it, even though it's in no way, shape or form perfect yet. 

The inspiration for this gem was `nba_py`, the Python equivalent of this gem. They have done an amazing job at mapping out all the endpoints and their params, so big props to them for laying the ground work. Something something on the shoulder of the giants :)

Since I've been the only one really working on it and using the gem, I could use some feedback from other devs who like working with data, especially sports one. This is by no means perfect and it's the first big open source project I'm maintaining, so I'm sure there's a lot to improve :) Feel free to reach out to me at any time with Qs or anything else.
CSS grid exposed as a function to be used in CSS Modules
Tags: react, cssinjs, help
Published: 2018-06-07 13:57:19

---
title: CSS grid exposed as a function to be used in CSS Modules
published: true
description: 
tags: React, CSS-in-JS, help
---

I wasn't sure how other's are doing it, so I made this small lib to help me create a grid while using styled React components with [glamor](https://github.com/threepointone/glamor) or [emotion](https://emotion.sh/). It's called Gridorous and you can find it on [GitHub](https://github.com/kbariotis/gridorous).

Do you happen to know another way?

I will try to migrate my [personal site](https://github.com/kbariotis/kostasbariotis.com/) on it soon so I can test it.
Let's make my website even better
Tags: discuss, webdev
Published: 2018-06-07 12:46:16

---
title: Let's make my website even better
published: true
description: I just finished redesigning my website. It isn't live just yet. I wanted to see what can I do to make it even better.
tags: 
- discuss
- webdev
---

I just finished redesigning my website. It isn't live just yet. I wanted to see what can I do to make it even better. 👌

The link to the current version: https://develop--silvestarcodes.netlify.com/

I would like to get feedback on SEO, performance, page speed optimizations, accessibility, and responsiveness. 💬

First, few notes:
- I am not a designer; I don't have design skills at all, but I have made a prototype in InVision Studio: https://projects.invisionapp.com/prototype/sb-cjfc7amqt005awa01fl56n2s2;
- I have used CSS Grid. Therefore the site looks ugly on any Internet Explorer;
- The source code is available on GitHub, branch `develop`, feel free to look around or create a pull-request: https://github.com/maliMirkec/hexo-sb/tree/develop;
- ~~I am experiencing issues with Critical CSS~~.

Can you help me? Any feedback would be appreciated. 👍

Now, let's make my website even better! 🥇

EDIT, June 12: The design is updated. All issues, except privacy, have been resolved.

EDIT 2, June 20: Privacy issues resolved, pushed to production.
How should we handle duplicate content on dev.to?
Tags: discuss, devto
Published: 2018-06-07 12:13:56

---
title: How should we handle duplicate content on dev.to?
published: true
description: 
tags: discuss, dev.to
---

As more posts appear here I'm noticing more duplicates. People don't always search to see if their ideas have already been covered before writing a new one or making a new spin on an existing post.

Stack Overflow handles this by shutting the new posts down. Yahoo! Answers handles it by not caring and generally being full of it. In every sense.

We're still early days with this site really, so what are other people's ideas about how to handle it?

We currently have "trending" and "classic posts" as asides to posts, but maybe we could have a "related" section based on keywords or something?

Duplicate isn't always duplicate either - an almost identically-named post could be about the news of a pending event or about how that event has changed the world a year on, for example.

Thoughts?
Do you get exhausted from working or studying?
Published: 2018-06-07 11:43:53

---
title: Do you get exhausted from working or studying?
published: true
description: I want your thoughts about getting tired/exhausted from too much work or studying.
cover_image: https://thepracticaldev.s3.amazonaws.com/i/ojceewuvkbjoi8zwhxer.jpg
tags: 
---



P.S: bear with me, I wanna try a playful style of writing my thoughts as a code:


```javascript
function Success(you) 
{
 
    if (you == wanna_be_successful)
    {
        
        study new things, after work, every day (5 days a week), 
        for at least 1 hour a day,
        to keep you = up-to-date and aware of all the new technologies;       
    
    }
    else
    {
       
        you = lag behind your peers and you kinda become value-less 
        in the market;

    }
    
    return you;

}


function Lately(I, experience)
{
    
    let I = PHP Developer
    let experience = 5 years
    let me = []

    2 weeks ago, I refreshed my knowledge of HTML/CSS/JavaScript;
    It felt amazing to catch up with the new additions (especially ECMA6);
    me.push('happy');

    I could study all day long;
    I studied every day, even in weekends;
    me.push('consistent'); 
    
    I thought about it whenever I was hanging out with my family and friends;
    I couldn't wait to go back to study more and more;
    me.push('confident');

    return me;

}

function now(me)
{
    me = [];    

    after those 2 weeks, I couldn't read a single word without feeling
    that my brain is gonna explode;
    me.push('exhausted');
    
    I moved on to do some working on my own website;
    But I still feel like my brain has shrunk or something;
    I cannot focus;
    me.push('empty');

    My intuition tells me that my brain is tired and needs time to relax;
    My (personal) deadlines make me nervous;
    me.push('nervous');

    return me;

}

function YourThoughts(yourThoughts)
{

    what are your experiences with this;
    Too much working, too much studying;
    Should we rest after too much work/study;
    How long should we rest;

    It's been almost 3 days that I cannot do a significant work,
    but I NEED to work, the "world" cannot wait for me that long;

    return yourThoughts;

}
```
Getting connected status on React Native
Tags: reactnative
Published: 2018-06-07 11:02:34

---
title: Getting connected status on React Native
published: true
description: 
tags: reactnative
---

We may need to know if a device is connected to the internet sometimes on React Native.

# What the Doc said
We should be using `NetInfo.isConnected.fetch()` to get a boolean denoting the device is connected or not.

# In fact
Up until the current newest v0.55, it is still observed that `NetInfo.isConnected.fetch()` works properly on Android only. It tends to return `false` on iOS. It is a known bug.

# Solutions from the internet

- Use Event Listener
We can add an event listener and listen to changes in network status.
```js
onInitialNetConnection = (isConnected : boolean) => {
    console.log(`Is initially connected: ${isConnected}`);
    NetInfo.isConnected.removeEventListener('connectionChange', this.onInitialNetConnection);
};

constructor(props : Props) {
    super(props);
    NetInfo.isConnected.addEventListener(
        'connectionChange',
        this.onInitialNetConnection
    );
}
```

- Ping a Website
In this case, y'all can try pinging `google.com`
```js
let req = await fetch('https://www.google.com');
let hasConnection = req.status === 200;
```
> Ugly, but it works.

- Use `NetInfo.isConnected.fetch()` a Few Times ???

Tested on `< v0.55`, I discovered that calling `NetInfo.isConnected.fetch()` multiple times on `componentWillMount` of the root component of the app actually works.

On `v0.55`, this seems to stop working.

```
¯\_(ツ)_/¯
```
Pencil.js
Tags: showdev, javascript, webdev, opensource
Published: 2018-06-07 10:37:21

---
title: Pencil.js
published: true
description: Nice modular interactive 2D drawing library
tags: showdev, javascript, webdev, opensource
cover_image: https://thepracticaldev.s3.amazonaws.com/i/2304ohv8jyqep9k1w5zj.gif
---

# Pencil.js

Today, I want to present you [Pencil.js](https://github.com/GMartigny/pencil.js); a nice modular interactive 2D drawing library written in javascript.

Still in building phase, it already has a lots of features to try out.

## Purpose

### Abstraction
Drawing in a canvas is not trivial.
First of all, the goal is to ease the use of canvas in a browser; allowing anyone to use it with its comprehensible syntax and extensible options.


### OOP
OOP is great, OOP is almighty, OOP saves lives !
Others library exists, but none with a beautiful OOP syntax. It makes code look natural.


### Modularity
Splitting the whole code into modules make everything cleaner.
It also allow you to grab only what you need or replace what you don't like.


### Documentation
A complete documentation goes a long way to help developers.
All functions are assured to have a description and also typed arguments and returns.

## Examples

### [Black triangle](https://rampantgames.com/blog/?p=7745)

Here's a "hello world" kind example.

{% codepen //codepen.io/GMartigny/embed/wXWNgY/?height=500&default-tab=js,result&embed-version=2#%}

### Interaction

Based on events, it's easy to build interactivity.

{% codepen //codepen.io/GMartigny/embed/eKzoXa/?height=500&default-tab=js,result&embed-version=2#%}

There's a lot more options (rotation, cursor, clip ...) and shapes (Star, Image, Path ...) for you to discover.
I event start to add complexe component like user inputs (button, checkbox, slider ...) and it works well so far.

### More ...

There is more example in the [Pencil.js codepen collection](https://codepen.io/collection/XqzkNQ/). If you create something nice, contact me so I can add yours too.

## What do you think ?

First of all, I'm looking for feedback. I would like to build an API that's usable by beginners, but I know it too well. If you have any suggestion or encounter any bugs, let me know.

If you liked it, please, take the time to [upvote it](https://www.producthunt.com/posts/pencil-js).
Thanks for your time and see ya.
Atom and Visual Studio Code
Tags: discuss, editors, atom, vscode
Published: 2018-06-07 10:11:54

---
title: Atom and Visual Studio Code
published: true
description: The acquisition of GitHub by Microsoft stretches out beyond github.com
tags: #discuss #editors #atom #vscode
---

Some years ago Oracle took over two big open source projects, MySQL and Open Office. Whilst MySQL remained open and community driven Open Office did not and was later discontinued. (It eventually got forked and became Libre Office.)

Given the recent acquisition by Microsoft, will any of these editors prevail?
Or is there a large enough ecosystem for they to co-exist?
Understanding Pointers in c++
Tags: explainlikeimfive
Published: 2018-06-07 09:37:39

---
title: Understanding Pointers in c++
published: true
description: Understanding Pointers in c++
tags: #explainlikeimfive
---

So I have been going crazy over this one small concept. I have been trying to wrap my head around pointers. To start off with I understand they point to a specific memory adress. My problem comes in when returing a point from a function. More specificly why I can acess the values in it in a specfic manner. 


The bottom example is what I am messing with at the moment.I am currently returning a pointer to a int that stores a array as the return value. I place it on the stack to be accessed later. I am also aware this is not the best way of doing things but I am just doing this for practice. 



```c++


 int* startTheSquare() {
	 //Keep the array on the stack to be looped through
	static int ar[2] = { 2,4 };
	//This will set the value of x^2
	
	return ar;
	
}

 void outPutValuesToCompute() {

	int* get = startTheSquare();
	

	for (int i = 0; i<2; i++) {
		cout << "Values" << get[i];
	};
 }

int main()
{
	outPutValuesToCompute();
    return 0;
}


```

The part that is tripping me up is why can I point to the memory address of this return type here. 

```c++

int* get = startTheSquare();
```

and then just automatically gain access to the array with out the need of de referencing it? I also want to know if I just access one part of the array why when I have to then deference it but I do not have to use a reference value & to access it. Like I would need to do when pointing to a variable?

example of accessing with out the array.

```c++ 
int* get = startTheSquare();
int *store = get;
```

example of accessing it with the array.

```c++
 void outPutValuesToCompute() {

	int* get = startTheSquare();
	

	for (int i = 0; i<2; i++) {
		cout << "Values" << get[i];
	};
 }
```

example of pointer with variable
```c++
int foo = 10;
int *getFoo= &foo;
cout<<*getfoo
```

Hopefully all of this makes some sort of sense? Please let me know if I need to clarify any thing.
What kind of breaks do you take at work ?
Tags: discuss, productivity
Published: 2018-06-07 08:49:34

---
title: What kind of breaks do you take at work ?
published: true
description: 
tags: discuss, productivity 
---

Up until now I always have been able to work all day without taking breaks (besides a mid-day lunch break) but I'm starting to feel the need to take a small break from time to time.

The problem is, I don't know what to do to make a break useful and efficient. If I do I often just do something else on the computer (checking my personal mails, social media, news...) and it does not feel like a real break at all.

What are your thoughts on this ? Do you take breaks at work ? If so, what do you do ? And for how long ?
This is how I know Developers
Tags: developer, devops
Published: 2018-06-07 08:23:31

---
title: This is how I know Developers
published: true
description: The portrait of a Developer 
tags: developer, devops
---
Have you ever tried to understand developers? I did.


So, Who’s a developer, really?
According to me, developers are:
> analytical
> curious and inquisitive
> flexible
> avid learners
> pragmatic
> team players
> technical

The Developer mindset is interested in:
> how stuff works
> how to make stuff work
> finding a solution to that one unsolvable problem
> learning new things about programming
> trying out new tools

Social platforms of Developers,
> Quora, 
> LinkedIn 
> Medium, 
Websites like DZone, Stack Overflow, Gizmodo, InfoQ, DevOps .com, Linux and JAXenter are extremely helpful.

Companies that help Developers learn DevOps, (you might want to check their blogs and tutorials)
> Docker
> AWS
> Kubernetes
> Puppet
> Chef
> Ansible
> HashiCorp
> Shippable
> Jenkins
>Electric Cloud

Want to add anything else? Please do in the comments.
I'm looking open source project
Tags: discuss
Published: 2018-06-07 08:17:22

---
title: I'm looking open source project
published: true
tags: discuss
---

Hi, guys!

I like programming and i looking open source project.

My skills:

- i created with my team small project in Russia - handsales.ru (if you looking PM in your project)

- i like Node.js:
-- https://dev.to/gaserd/how-to-create-small-search-engine-for-your-awesome-project-40m
-- https://dev.to/gaserd/how-create-small-algorithm-similar-items--46cg

- i like ReactNative:
-- https://dev.to/gaserd/how-make-analytics-for-your-app-in-react-native--35kf
-- https://dev.to/gaserd/mobile-development-in-real-life-5gjd
-- https://dev.to/gaserd/small-trick-for-your-app-to-react-native---side-menu-with-overlay-52be
-- https://dev.to/gaserd/why-i-do-not-use-expo-for-react-native-dont-panic-1bp

And i like JS/CSS/HTML, but i like others language too

How to contact me?

- gaserd123@gmail.com
- https://github.com/Gaserd
- https://mobile.twitter.com/gaserd123
- https://t.me/gaserd

Thanks!
Github Guesser - A Starry Game
Tags: game, preact, react, github
Published: 2018-06-07 07:45:33

---
title: Github Guesser - A Starry Game
published: true
description: A simple "game" written in Preact. Can you guess which repo has more stars???
tags: game,preact,react,github
cover_image: https://thepracticaldev.s3.amazonaws.com/i/tsezzonyw1s7vn5dw0vm.png
---
**UPDATE** Release #2 is OUT!
https://dev.to/davidszabo97/github-guesser---a-starry-game---release-2-20g3

-----

Hey devs!

**I am happy to announce that I am releasing the very first version of my new pet project.**

It's a really simple game: You need to guess which GitHub repository has more stars, based on the given information! Just click / touch the one you think is more popular and in a moment you will know whether you won or lost!

You can find the game here: [**Github Guesser**](https://githubguesser.messedcode.com/?utm_source=devto)
(plain link if you prefer that: https://githubguesser.messedcode.com/)

Soon I will release the source code too on GitHub.
The repository is already initialize if you are interested in watching or starring it: https://github.com/david-szabo97/github-guesser


-----

I am planning a few features to be released in the next few weeks:
* Login using Github so you can track your stats
* Backend: Uploading stats
* Backend: Pull repositories
* Frontend: Show how many people won or lost the combination you just finished

GOT ANY IDEAS? Share it!!!!

-----

**PS** Have you met [**_Static_**](https://dev.to/davidszabo97/static---a-simple-fun-website-1f0p) yet? 
**PPS** You can find my blog at https://messedcode.com
JPA 2.2のJavaDocを日本語に翻訳しました。
Tags: javajpa
Published: 2018-06-07 02:35:26

---
title: JPA 2.2のJavaDocを日本語に翻訳しました。
published: true
description: JPA 2.2のJavaDocを日本語に翻訳しました。
tags: java JPA
---

以下からどうぞ。

https://megascus.github.io/jpa-spec/docs/apidocs/
Recomeded music to listen to while programming?
Tags: discuss
Published: 2018-06-07 02:28:15

---
title: Recomeded music to listen to while programming?
published: true
description: Recomended music playlist to listen to while programming? 
tags: #discuss
---

Hey guys I was wanting to know if you have any music playlists. That you guys can recommend. That you listen to while programming?