teleren/devto huggingface dataset:
What is a Gem? Part 1
Tags: ruby, programming, gems, beginners
Published: 2019-03-19 16:03:20

---
title: What is a Gem? Part 1
published: true
description: 
tags: ruby, programming, gems, beginners
---

Ruby gems, like a lot of things in ruby, can seem pretty magical at times. How is it possible that I can type ‘gem install rails’ into my terminal and be able to create a web application in a matter of minutes? What is this sorcery? I’m on a mission to find out!

# Back to the Basics

To really understand a gem, we have to take a few steps back. Basically every aspect of computing involves files; a single file can contain a little or a lot of information. For us to make programs and do cool stuff, files have to be used together. It can quickly get very confusing to keep track of what every file is doing. Enter: packages. A package is simply a collection of files and metadata (data that describes other data).

# Gems

In Ruby, these packages are called gems. Gems contain code, documentation, and a gemspec. One of the most widely used gems is [bundler](https://bundler.io/), which is able to look in your Gemfile and download the correct version you need for your program. Another popular gem, [rails](https://rubyonrails.org/), is an entire web application framework that makes building web apps quick and easy.

# Package Management

Just like files, packages can get messy to deal with. A package manager, as the name implies, is software that manages these packages for you. A great example of a package manager that we’ve all used is an app store. A user can easily search for, install, or delete an app without having to do the dirty work of checking dependencies or manually installing each file within the package. Everything is handled for you, so you can get to the good stuff! With the release of Ruby 1.9 in late 2007, the package manager [RubyGems](https://rubygems.org/) became Ruby’s default package manager.

# Conclusion

There is a lot more to be said about gems! For my next post, I’ll dive deeper into what makes up a gem, including the structure and gemspec file. But to summarize for now: gems are packages used in ruby to make programming easier for us. Catch you next time!
Google Stadia
Tags: stadia, google, discuss
Published: 2019-03-19 23:55:02

{% youtube 2jPS6XbTtCo %}

Google unveiled their new video game streaming service today, _Stadia_. Think of it like Netflix for video games -- you wouldn't need to own any hardware other than the screens you already have (your laptop, phone, smart TV). You simply (presumably) buy a subscription to the service, a fancy Google controller, and you can play 4K HD 60fps games anywhere.

[This is a direction that the video game market is naturally poised to move toward](https://www.cnbc.com/2019/03/19/google-stadia-new-streaming-game-service-announced.html), where big tech companies can perform all the number-crunching on their servers and simply stream the resulting video to your screen. Microsoft is working on a competing service, called _xCloud_.

There are downsides to this approach, of course, the most obvious one being latency. It takes time to send your commands to one of Google's servers, have the server perform whatever calculations it needs to do to render the next frame, then send that frame back to you. Gamers on Twitter have decried the lack of any mention of the "L" word during Google's announcement.

Streaming video games also means that you don't _own_ a physical copy of the game, which bothers some. If a publisher decides to pull all their content from Stadia, could you do anything about it? What rights do you have as a subscriber?

I'm very interested in where this is headed, but I have a feeling it might take a while to catch on. Anyway, it will certainly open up a new niche for gamers and game studios alike. What are your thoughts?
Why you should use Netlify instead of GitHub Pages
Tags: hosting, netlify, githubpages, speed
Published: 2019-03-19 22:33:04

---
title: Why you should use Netlify instead of GitHub Pages
published: true
description: 
tags: hosting, netlify, github pages, speed
---

# Netlify is awesome!
I am not being paid to say that. I just think they provide some fantastic free services. There are too many to list here, but these are some features of their _totally free_ services that I would like to highlight to get you to consider checking them out. There are more features that you pay for, but I am only highlighting features for free users. Go check out their website [here](https://netlify.com).

### Free Private Repository Hosting
The best reason to use Netlify is that you can host a private repository. Normally this is a GitHub Pro feature. That's a minimum of $84 per year that not everyone can afford.

### Custom Netlify Subdomains
You can set a custom subdomain (as long as it's not already being used). 

### Custom SSL
If you have your own SSL certificate that you purchased, you can use your custom SSL certification instead LetsEncrypt. Otherwise they also provide an automatic LetsEncrypt SSL certificate like GitHub.

### Speed up your website with Asset Optimization

#### Bundle and Minify CSS and JavaScript

If you're linking a handful of CSS and/or JavaScript files Netlify can bundle them all together and minify them (remove unnecessary whitespace) to speed up loading your pages.

#### Lossless compression for images

Netlify also provides the option to compress images to make for a speedier download.

#### Prerendering

When turned on, Netlify can host your site from one of their CDNs to serve to a crawler to greatly improve SEO.

## Forms
You can receive up to 100 form submissions for free without having to have a backend.

## Does git cmd scare you or your client?
You can deploy using drag & drop as well and still rollback to previous versions with a couple clicks.
useful link that might help                          
Tags: beginners, discuss
Published: 2019-03-19 21:57:19

---
title: useful link that might help                          
published: true
description: Useful link that might help Beginners
tags: #beginners #discuss
---
i found that link and i think it has a useful information that might be helpful and useful for beginners and i thought that i have to share it with you guys 
i wish you all the best with your study 

https://generalassemb.ly/blog/what-is-front-end-web-development/
Clean up and remove a Python3 homebrew install
Tags: python, python3, homebrew, macos
Published: 2019-03-19 20:49:19

---
title: Clean up and remove a Python3 homebrew install
published: true
description: tl;dr how to clean up and remove your Python3 homebrew install
tags: python, python3, homebrew, macos
---

tl;dr TIL pygame is broken using homebrew Python3, so I decided to wipe my shit and start from scratch. I figured I'd give you the quickness on what I did so next time this shit happens to someone, they have a handy reference.

[https://stackoverflow.com/questions/11248073/what-is-the-easiest-way-to-remove-all-packages-installed-by-pip](https://stackoverflow.com/questions/11248073/what-is-the-easiest-way-to-remove-all-packages-installed-by-pip)

TIL about `pip freeze`:

```
freeze	Output installed packages in requirements format.
```

Save the requirements to file if you want to quickly re-install everything you're about to remove.

```
pip3 freeze > requirements.txt
pip3 freeze | xargs pip3 uninstall -y

```

[https://apple.stackexchange.com/questions/284824/remove-and-reinstall-python-on-mac-can-i-trust-these-old-references](https://apple.stackexchange.com/questions/284824/remove-and-reinstall-python-on-mac-can-i-trust-these-old-references)

```
rm -rfv /usr/local/bin/python3*
```

Ok, time to install official Python3.

- [https://www.python.org/](https://www.python.org/)

At this point you can do `pip3 install -r requirements.txt` to reinstall everything you uninstalled. I'm keeping my stuff cleaner for now `^_^`!

-----

To reiterate:

```
pip3 freeze > requirements.txt
pip3 freeze | xargs pip3 uninstall -y
rm -rfv /usr/local/bin/python3*
# Reinstall python3 here!
pip3 install -r requirements.txt
```

-----

# [If you need a Computer Science tutor, code reviewer, or just someone to pair program with, hit me up](https://codementor.io/mikebell66)
Conway's Game Of Life with different rules
Tags: javascript, automation, opensource, react
Published: 2019-03-19 20:11:58

---
title: Conway's Game Of Life with different rules
published: true
description: Have you ever wondered what the Game Of Life would be like if you could change the rules?
tags: JavaScript, automation, opensource, React
cover_image: https://thepracticaldev.s3.amazonaws.com/i/p2vuq1p7vwrkoo3b01cy.gif
---

#Conway's Game Of Life
### [The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life)

If you've spent any time exploring or playing with Conway's Game Of Life, you're probably very familiar with resulting pattern such as:

![game of life representative end state](https://thepracticaldev.s3.amazonaws.com/i/78v3b3nr1pvgyswd2gxr.png)

###But what if you could play with the settings that determine the rules for each turn, and could create patterns such as this?
![game of life and state with different rules](https://thepracticaldev.s3.amazonaws.com/i/fia9w8t7w8wdyfwpfzlc.png)

**Now you can!**

###Here is a deployed version of the project that is [up and running that you can play with](https://lexjacobs.github.io/conways-game-of-life-explorer/)

###I've created a game of life explorer using JavaScript that lets you change the rules.

The default rules are:
* Death by overpopulation if neighbors are greater than 3
* Death by under population if neighbors are less than 2
* Rebirth by reproduction if neighbors exactly equal 3

I've also created simple editing tools that let you add or delete individual cells, play and pause during the evolution of the game, move your cells around on the game board, and also select random starting patterns. You can also change your initial board size, and of the millisecond delay between turns.

This allows you to make interesting starting patterns such as the following:
(scroll to 30 seconds to see the pattern get much more complex and interesting)

{% youtube dPxABgIkjSw %}

###You can explore the code at my repository at:
{% github lexjacobs/conways-game-of-life-explorer %}

I hope you enjoy exploring this project and enjoy learning more about The Game Of Life.

###Please let me know what you think!
D and C++: Passing dynamic strings
Tags: d, cpp, cffi, dlang
Published: 2019-03-19 18:40:40

---
title: D and C++: Passing dynamic strings
published: true
description: Dynamically creating a string in C++ and passing it to D
tags: D, cpp, cffi, dlang
---

The easiest way to get a dynamically created string back out of C++ is to pass a char pointer reference (`char *&`) out parameter to the function we are calling. This allows us to malloc properly within C++ as we don't know the string length to malloc in D.

This simple example creates a string consisting of all the numbers up to an integer n, separated by spaces.

**ex.cpp**

```c++
#include <cstdio>  // for snprintf
#include <numeric> // for iota example
#include <sstream> // string builder
#include <vector>

void numbers_upto(char*& out, int n) {
  std::vector<int> xs(n);
  std::iota(xs.begin(), xs.end(), 0);
  std::ostringstream buf;

  for(const int& x: xs) {
    buf << x << " ";
  }

  std::string str{buf.str()};
  size_t str_size = str.length();

  out = new char[str_size];
  snprintf(out, str_size, "%s", str.c_str());
}
```

**ex.d**

The D side is simple, but note we use a scope guard to free our string once it goes out of scope to avoid a memory leak. The corresponding type to `char *&` in D is `ref char*`.

```d
extern (C++) {
  void numbers_upto(ref char* s, int n);
}

void main() {
  import std.conv : to;
  import std.stdio : writeln;
  import core.stdc.stdlib : free;

  char* s;
  scope(exit) {
    // ensure s is not null before trying to free
    if (s !is null) {
      free(s);
    }
  }

  numbers_upto(s, 10);
  writeln(to!string(s));
}
```

And to compile:

1. `g++ -c -o cpp.o ex.cpp`
2. `dmd ex.d cpp.o -L-lstdc++`
3. `./ex`

It should print:

0 1 2 3 4 5 6 7 8 9

As a bonus we can write a wrapper templated function to call functions of this style, and use a D contract to ensure the string returned from C++ is valid.

Updated **ex.d**

```d
extern (C++) {
   void numbers_upto(ref char* s, int n);
}

void CheckedString(alias Fn, Args...)(ref char* s, Args args) 
out(; s !is null)
do {
  Fn(s, args);
}

void main() {
  import std.conv : to;
  import std.stdio : writeln;
  import core.stdc.stdlib : free;

  char* s;
  scope(exit) free(s);

  CheckedString!numbers_upto(s, 10);
  writeln(to!string(s));
}
```

We can remove the check in the scope guard as the program will be forced into an invalid state before the scope is checked if the contract assertion fails.

The CheckedString function takes a function, a `ref char*` and a set of arguments which will be passed to the function. The out part is a contract which runs after the function has completed. We simply check that the ref string is not null.

Compile in the same way and you should have the same result as before. To test the new functionality out, simply nullify `out` in the C++ code before the end of the `numbers_upto` function, like so: `out = nullptr;` and the D contract should fail as intended.
Do you prefer unix epoch (a number) or ISO 8601 (a string) for timestamps? 
Tags: discuss, webdev
Published: 2019-03-19 18:25:04

---
title: Do you prefer unix epoch (a number) or ISO 8601 (a string) for timestamps? 
published: true
tags: discuss, webdev
---

In interfaces such as APIs such as REST or Graphql, most JSON doesn't support time stamp data type natively, you'll have to use one or the other. Or what alternatives do you prefer to use?
How to get all WordPress posts from the WP API with JavaScript
Tags: wordpress, javascript, api, asyncawait
Published: 2019-03-19 17:54:00

---
title: How to get all WordPress posts from the WP API with JavaScript
published: true
description: Simple JS snippet to retrieve WordPress blog posts as JSON.
tags: wordpress, javascript, api, async / await
---

<em>This post was originally published on my blog, [jacklyons.me](https://jacklyons.me/how-to-get-all-wordpress-posts-from-the-wp-api-with-javascript/)</em>

Just recently I was asked to scrape a Wordpress blog for a client to audit of all their posts. Naturally, the first thought was to just export all the posts, however, after a quick  google I stumbled upon the <strong><a href="https://developer.wordpress.org/rest-api/reference/" target="_blank" rel="noopener">Wordpress REST API</a></strong>. Using the API allows you to make direct requests to any wordpress site and retreive a list of blog posts as a JSON object.

Give it a try right now. Punch this into your browser and  you should get a list of my 10 most recent blog posts:
<pre style="text-align: center;"><code>https://jacklyons.me/wp-json/wp/v2/posts</code></pre>
It's that easy! Inside each post object there is a huge amount of data. You can extract things like post date, post status, and much more. The API documetation states that you can only retreive a maximum of 100 posts per request. In this post I'll show you how to create a function that will get all your posts in a single go! This can be helpful when the site you're scraping has hundreds or thousands of posts.

Below I created a super simple HTML snippet that you can copy and paste into a basic HTML file. Note that I'm using some modern browser and ES2017 features so you'll have to use Chrome or Firefox. Also, it may take a little while if you are scraping a site with a few hundred or thousand posts.

{% gist https://gist.github.com/JackEdwardLyons/edf805de3dd91d14a7a0da8b605a35f4.js %}

If you have any questions, comments or feedback to improve, please just leave a comment :)
Explain 3G, 4G and 5G like I'm 5
Tags: network, explainlikeimfive
Published: 2019-03-19 17:36:21

---
title: Explain 3G, 4G and 5G like I'm 5
published: true
description: What do they mean? Why should I care? How do I benefit?
tags: network, explainlikeimfive
---
The Mobile Developer
Tags: learntocode, codenewbie, mobiledevelopers
Published: 2019-01-31 12:10:09

---
title: The Mobile Developer
published: true
description: This is an article on learning to code with a mobile device
tags: #learnToCode #codeNewbie #mobileDevelopers
---
I started learning to code with my mobile device (Android) 2017 and it was really a defining moment for my journey as a web developer (I'm gradually transitioning to software development).

I was passionate enough to begin learning to code with my mobile device against all odds and discomfort that accompanys learning to code with a mobile device. 

Over the years I have noticed most of the beginners reaching out to me with questions on how to learn to code, like me when I started, do not own a laptop or desktop computer to learn with. So I'd always motivate them to get started with their mobile device. 

But i decided to take it a little farther by writing a book teaching beginners how to start coding by Learning web development. I'm almost done writing the book and created a waiting list for readers that will love to read the book when it's finally out.

## What to expect 

* Basic and in-depth explanations of web technologies like HTML, CSS and JavaScript
* Sample codes to build your muscles memory with
* Recipes for learning to code
* Motivation to continue your journey to becoming the beat Developer you can become.

Here is the [link to the waiting list](https://goo.gl/forms/3UHI4Rful3H8GjGg2)
How could Google possibly know about this?
Tags: discuss
Published: 2019-03-19 17:01:56

---
title: How could Google possibly know about this?
published: true
description: Something quite interesting just happened, and brought some thoughts along with it. 
tags: discuss
---

After a normal day of work I got home as usual and started to chill out at Netflix. After a few minutes, I have decided to finally watch the *Le Fabuleux Destin d'Amélie Poulain* which was at my *should watch someday movie list* for a very long time.


It was only a normal movie session until it got to a scene where a peculiar piece of art was shown. I never knew about it, and I have decided to Google it just out of curiosity.


![Luncheon of the boating party](https://upload.wikimedia.org/wikipedia/commons/thumb/8/8d/Pierre-Auguste_Renoir_-_Luncheon_of_the_Boating_Party_-_Google_Art_Project.jpg/1200px-Pierre-Auguste_Renoir_-_Luncheon_of_the_Boating_Party_-_Google_Art_Project.jpg)
*It is a shame that I didn't know what this piece of art was, considering that it is Renoir's*


Some character at the movie mentioned the painting's name but I didn't pay much attention. I just heard by glance that it started with *lunch* or something.


So, i went to Google and proceeded to type the word *lunch*. By the time I typed the letters *lun*, the first suggestion popped out. It was the painting's name, **Luncheon of the Boating Party**.

And it just blew my mind. I never searched for that in Google. In fact, i didn't know that painting even exist. Google has become such an essential thing in our lives that sometimes we even forget how efficient and *creepy* it is. 

**How could Google know about it?** *Lun*, as I typed, should bring results such as "Lunch near me", or "Lunch for monday" or something like that, not **Exactly what i was thinking about** with no more information that the simple *L-U-N* letters that I gave it.
D and C++: Passing strings
Tags: cpp, d, cffi
Published: 2019-03-19 16:42:54

---
title: D and C++: Passing strings
published: true
description: How to pass strings from C++ to D
tags: C, cpp, D, cffi
---

**ex.cpp**

```
#include <string>

const char* get_string() {
    return "Hello from C++!";
}
```

**ex.d**

```
extern (C++) {
  immutable(char)* get_string();
}

void main() {
  import std.conv : to;
  import std.stdio : writeln;

  string s = to!string(get_string());
  writeln(s);
}
```

And to compile:

1. `g++ -c -o cpp.o ex.cpp`
2. `dmd ex.d cpp.o -L-lstdc++`
3. `./ex`

It should print:

Hello from C++!
Who is hiring? (As of March 2019)
Tags: whoishiring
Published: 2019-03-19 16:00:57

---
title: Who is hiring? (As of March 2019)
published: true
description: Members of the dev.to community sharing open job opportunities at their companies.
tags: whoishiring
---

This is our monthly thread where community members share openings at their companies.

Here a few ground rules:

- Please only post if you are personally part of the hiring company (no recruiting firms)
- Please provide brief background on what your company does
- Only one post per company (you can list multiple openings in the post)

Consider using this template:

```
Company Name | Job Title | Location | Remote or Onsite | (optional) Salary Range | Sponsor visa?

About the company — background, size, etc (1-3 sentences)

About the role(s) — languages, requirements, etc (1-3 sentences)

Do you sponsor visas?

How to Apply — email or application link
```

---

We also wanted to share some quick careers-related notes from our fantastic Sustaining Sponsors.

### Digital Ocean

> At **DigitalOcean**, we're simplifying cloud infrastructure for developers. Here you'll get to work with some of the smartest and most interesting people around; solving unique and complex technical challenges on a scale matched by few companies. If you get excited about stretching yourself in new ways, developing yourself to your fullest potential, with amazingly supportive friends and colleagues; [we want to talk to you](https://www.digitalocean.com/company/careers/?utm_source=devto&utm_medium=display&utm_campaign=Devto_2018_Brand)!

### Triplebyte

> **Triplebyte** now hires software engineers for top tech companies and hundreds of the most exciting startups like Apple, Dropbox, Mixpanel, and Instacart. They identify your strengths from an online coding quiz and let you skip resume and recruiter screens at multiple companies at once. It's free, confidential, and background-blind. [Apply here](https://triplebyte.com/a/YU8fSn0/whoishiring-jan).

### GoCD

> **GoCD** is a free and open source CI/CD tool by ThoughtWorks. You can model your complex workflows, deploy to popular cloud environments such as Kubernetes, and visualize your end-to-end workflows — [download and use for free](https://www.gocd.org/download/).  While we don't have any open positions, there are many ways to [contribute to the community](https://www.gocd.org/contribute/).
Git users and their last commits
Tags: git, logs, bash, linux
Published: 2019-03-19 15:52:30

---
title: Git users and their last commits
published: true
description: Getting a list of users who have committed to a repo, by their last commit date
tags: git, logs, bash, linux
---

I needed to remember who was working with me on a certain project over the last year. I had some trouble remembering, because this last year has been crazy personally, and the project overlapped a couple years. All the years and months and days were running together in my brain.

Fortunately, we have git logs, but it's not straightforward. I came up with this set of commands to help with the task:

```
git log --pretty=format:"%an" | sort | uniq | awk '{system("git log -1 --author="$1 " --pretty=format:\"%ad%x09%an\""); print "\r"}' | sort -k5n -k2M -k3n
```

Here's what we're doing:
1. get all of the user names in the git logs
2. sort them lexically
3. remove repeats (sort -u could have replaced these)
4. do another git log for each user, but print out their last commit, and format it to be just the date and their name separated by a tab. 
5. Sort by the columns (year, month, date)