teleren/devto huggingface dataset:
I wrote a python script to output your Mac's total (and Daily Average) uptime since you bought it!
Tags: python
Published: 2019-07-22 16:54:34

So I was curious about how much value my MacBook Pro was in a money-per-hour kinda way and decided to find out how many hours I'd used it for since I bought it.

This turned out to be relatively straightforward as some commands can be run to get the info we need.

The first thing we need to do is find the age of the `/private/var/db/.AppleSetupDone` file which gets created when the Apple setup is... done (🔝 name for a file tbh).

Then we get the number of hours the OS hard drive reports being used for. This limits things if you've replaced your hard drive but I'm not aware of a way around this.

From there it's some pretty simple maths and we have the answer!

[The code is here on Github](https://github.com/MarkLambe/average_mac_daily_uptime)


I haven't spent a huge amount of time working on this so there could be better ways to do any of it, PR's welcome 😊
Have you ever lost your job?
Tags: discuss, watercooler
Published: 2019-07-22 16:54:25

I was recently laid off as my division was downsized. It was about as amicable as the situation could be, I left on good terms with my manager and have plenty of positive references. But I can't help feeling a little depressed. Who else here has ever lost their job? What was the experience like? How long did it take you to move past it? How was the following job search?
How do you profile a node application?
Tags: discuss, node, express
Published: 2019-07-22 16:41:49

I have a forum application, implemented in node and express, integrated with another project and is causing some serious latency issues for some routes and operations. I want to figure out the pieces of codes which are the bottlenecks for these slow operations and want to do some profiling. Is there any tool that could help me with that?
Right now I have written a middleware that calculates the total time for a request but It would be better if I could get something like a stack-trace along with the request URL, something like what django-silk provides for django applications.
First Community Project
Published: 2019-07-22 16:33:47

---
title: First Community Project
published: true
description: [Code for Sacramento](https://codeforsacramento.org/) community project for the city of Sacramento
tags: 
---

Over the past weekend I participated in my first community project with a bunch of devs I've never met before.

## Saturday

Showed up around 9:30am at [SkySlope](https://skyslope.com/). The organizers of the project first discussed the project and their idea of how we could organize around 20 devs across all aspects of the project. We had a small DevOps team who got the database setup on AWS and built the database structure using SQL.

I was on the backend team that handled building out the routes, logic, and sql queries. We had about 10 people working on the backend over the course of the weekend. Pretty early on we decided to use Node as the majority of the team knew it. A more senior dev in the group started to stand up a Loopback server but it ended up being a bit more complex for the everyone to learn and use in a weekend. The decision was made to switch over the Express as it's much easier to work with and get a 0.1.0 project up and running quickly.

The front end team was also a larger team of devs and UI/UX people. They created some great designs and started building out the application in React.

## Sunday

Much smaller team showed up on Sunday. Backend team consisted of about 5 people. Early on we distributed the workload across the team to complete the routes and make sure all the GET routes were working. Near the end of the day we got some POST requests working and started to narrow down the GET SQL queries so they didn't return all data but rather just the data that was needed.

It was a great experience learning the terminology and structure that a larger company and more senior devs use. There wasn't much formality on code structure or how to commit but we got a good amount of work done. I plan on working on the project over the next few weeks in hopes we can get the project ready to use for the city.
How do you respond to "What is tour greatest strength/weakness?" In interviews?
Tags: discuss, career, hiring, impostersyndrome
Published: 2019-07-22 16:24:55

Pretty much what the title says. In an inteview I have never not been asked the queariins:

**What is tour greatest strength?
What is your greatest weakness?**

I recently tried a response by telling them I had to tell mybweakneas first. My weakness is imposter syndrome. Feeling like I'm not qualified or that it some times gets to me when I see a 12 year old programming since 5 is at the same level as I am. Portraying that I know they're not but it feels that way.

And my strength is knowing that my persistence, attention to detail, and teamwork will always push me last that aa well as c9ntinute to make solid software.

The response seemed to go over well with them. I didn't get the job but it was a high demand position and didn't expect to. But I liked their responses with my answer.

How do you respond to these questions?
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2019-07-22 16:24:14

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---
Every Monday we round up the previous week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week. ❤️

#1. Don't Do It!

There's tons of advice on what to do to be a good programmer but Haseeb takes the opposite approach and shares a short list of things _not_ to do. 

{% link https://dev.to/haseebelaahi/what-not-to-do-as-a-programmer-my-list-after-2-years-of-working-with-teams-1b23 %}

#2. Many Benefits

Emma explains what designs systems are and why it's beneficial to establish one. Great primer. 

{% link https://dev.to/emmawedekind/design-systems-part-i-foundations-45hd %}

#3. LOC = Worst Metric Ever

Advice for all developers on writing readable, perfect code in good languages 🤪

{% link https://dev.to/taillogs/what-developers-should-actually-learn-in-college-2nen %}

#4. Power of 10

Rémy interprets the NASA Jet Propulsion Laboratory's Power of 10 rules for web development.  

{% link https://dev.to/xowap/10-rules-to-code-like-nasa-applied-to-interpreted-languages-40dd %}

#5. No Deadline, Full Re-write

Some insight into the decision making process of moving from a monolith to microservices. 

{% link https://dev.to/kristijankanalas/from-monolith-to-microservices-in-one-year-1fff %}

#6. All About K8s

Sendil helps us understand how Kubernets works, how it's architected, and what the various components are. 

{% link https://dev.to/sendilkumarn/kubernetes-for-everyone-opb %}

#7. Enhanced Editor

As long as VS Code is the most searched editor, posts to enhancing your editor setup will continue to be popular and useful for the community :)

{% link https://dev.to/lampewebdev/my-web-development-vs-code-settings-theme-extensions-tips-and-tricks-1324 %}

_That's it for our weekly wrap up! Keep an eye on dev.to this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Monday!_
Instalando NodeJS utilizando Node Version Manager(nvm)
Tags: node, nvm, tutorial, beginners
Published: 2019-07-22 16:18:30

---
title: Instalando NodeJS utilizando Node Version Manager(nvm)
published: true
description: 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/rpvzz4edgrzgjf3xin4l.png
tags: nodejs, nvm, tutorial, beginner
---

Según leí en foros y en la misma documentación de Node no es recomendable usar **sudo** al para instalar paquetes con **npm**.

Así que para evitar tener que escribir **sudo** sin que nos aparezcan problemas de permisos algo que me ha servido es utilizar **nvm** ya que además de no tener que usar **sudo** también me ayuda a manejar las versiones que quiero utilizar de este manejador de paquetes que es **NodeJS**.

Instalarlo ha sido muy sencillo, solo ejecutamos este comando en nuestra terminal:

```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
```

o

```
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
```

Después cierran y abren nuevamente la terminal y listo!

Para comprobar que lo tengan instalado escriben el siguiente comando:

```
nvm --version
```

Probremos instalar Node:

```
nvm install 12.2.0
```

Esa es la versión más reciente de Node, para comprobar que tengamos Node instalado ejecutamos:

```
node -v
```

Si quieres instalar otra version de NodeJS tienes que volver a escribir el comando de arriba junto con la versión que deseas instalar.

```
nvm install 10.15.3
```

Para ver todas las versiones que tenemos instaladas de NodeJS ejecutamos:

```
nvm list
```

---

Por defecto la primera versión de node será la primera que instalamos, pero si queremos cambiar esto solo debemos ejecutar

```
nvm alias default 10.15.3
```

Espero que les haya servido ❤


Referencias:
* https://github.com/nvm-sh/nvm
Do you consider the environmental impact of your software?
Tags: discuss, aws, google, microsoft
Published: 2019-07-22 15:48:50

When writing or deploying software, do you consider the environmental impact of it? Does this factor into the design process when choosing hosting etc?

I've been thinking about this more and more lately as cloud computing environments have started posting their emissions statistics. For example [Google are 100% carbon neutral](https://cloud.google.com/sustainability/), AWS is 50% neutral [with a promise to go 100%](https://aws.amazon.com/about-aws/sustainability/), and Microsoft are [doubling down on sustainability](https://blogs.microsoft.com/on-the-issues/2019/04/15/were-increasing-our-carbon-fee-as-we-double-down-on-sustainability/)
Brainstorm: Some Thoughts About User Behavior Tracking

Tags: hld, architecture, design
Published: 2019-07-22 15:46:57

:point_right:*Remain on high level*
:point_right:*No specific tools/frameworks included*

## Why it matters:point_left:
- Understand your users better
- Narrow the gap between how you expect user to use and how user actually use it
- Marketing data analytics

## How to do it:point_down:

### On client side
- Sync, send and wait
- Async, send and go
- Send in business components
- Send in a separate service
- Keep a local cache for unsent events for resend later
- Local cache size limitation
- API call timeout/failure handling

### On server side
- Log collection, centralize all log from all backend servers
- Generate an event based on predefined event data structure on request
- Direct to database
- Publish over message queue

### Employ a third-party service
- Direct request
- Integrate SDK
- Shared database/separate database

## Data definition:point_up:

### Event
- EventType, what happened
- CreatedAt, when did it happen
- Source, where did it happen
- Payload, who/what was involved

### Result
- StatusCode
- StatusMessage

## API:sunflower:
### create
`Create(Event) Result`
requestAnimationFrame (with high resolution timing, very precise) and performance.now polyfills
Tags: javascript, polyfill, requestanimationframe, performance
Published: 2019-07-22 15:33:23

---
title: requestAnimationFrame (with high resolution timing, very precise) and performance.now polyfills
published: true
tags: JavaScript,polyfill,requestAnimationFrame,performance
canonical_url: 
---

Two Vanilla JavaScript polyfills:

I have just adapted the [window.requestAnimationFrame polyfill made by Paul Irish](https://gist.github.com/paulirish/1579671) to work with high resolution timing automatically (when possible) and improved the performance a little bit. Here it is: [https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0](https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0)

I have also mixed the [window.performance.now polyfill made by Paul Irish](https://gist.github.com/paulirish/5438650) with [Aaron Levine’s](http://%EF%BB%BFgist.github.com/Aldlevine/3f716f447322edbb3671) and modified some of the code to improve it. Here it is: [https://gist.github.com/jalbam/cc805ac3cfe14004ecdf323159ecf40e](https://gist.github.com/jalbam/cc805ac3cfe14004ecdf323159ecf40e)

Both polyfills can be used either separately or together and they will automatically detect whether the web client needs them or not. Just load them in your code (using your favourite way) and, if the client needs them, the polyfills will deploy and be used.

If you want to use them together, remember to load first the code of the [window.performance.now polyfill](https://gist.github.com/jalbam/cc805ac3cfe14004ecdf323159ecf40e) since the [window.requestAnimationFrame polyfill](https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0) could need it.

Any comments are welcome!
Dead Simple Python (An Announcement)
Tags: python, beginners
Published: 2019-07-22 15:06:23

---
title: Dead Simple Python (An Announcement)
published: true
description: A big announcement for fans of the "Dead Simple Python" series.
tags: python, beginners
series: Dead Simple Python
cover_image: https://thepracticaldev.s3.amazonaws.com/i/vu05cx1syrwgpmh4n1qq.jpg
---

First order of business, to all the fans of the *Dead Simple Python* series, fear not! More articles are coming this year!

As you've probably noticed, the series has been on hiatus since March, due to some unforeseen circumstances. In the past month, however, the reason for the delay has been very different, and *quite* exciting!

***Dead Simple Python* is going to be a full-length book!** I signed on with [No Starch Press](https://nostarch.com) (publisher of *Python Crash Course* and *Automate the Boring Stuff With Python*) earlier this month. I've been hard at work on the book ever since, converting the series so far into the first several chapters.

The book will contain all the same information as the article series, and much, much more! I'm diving into many topics that were skipped in the series, and including many expanded explanations.

[![Cover for "Dead Simple Python" by Jason C. McDonald](https://nostarch.com/sites/default/files/styles/uc_product_full/public/dead-simple-python_front.png)](https://nostarch.com/dead-simple-python)

## Where Can I Get The Book?

The *Dead Simple Python* book is available from No Starch Press NOW, wherever you buy your books!

https://nostarch.com/dead-simple-python

## How Can I Help?

Keep reading the articles and giving your feedback in the comments! I read each and every response, and use them to improve the articles (and thus the book).

And, of course, please share the article series with your friends, co-workers, and social media connections.

**Stay tuned for more of the *Dead Simple Python* series, coming VERY soon!**
PtrJS - framework for developing video games in JavaScript
Published: 2019-07-22 14:58:11

Hello world!
I have been working on this project for a few months and I am proud to present to you: PtrJS - framework for developing video games in JavaScript.
It all began with me not wanting to use any frameworks, ironically, so I decided to use plain old JavaScript to create video games using the HTML canvas element. But when I saw how many lines of code are required for, let's say, drawing a simple circle, I was shocked. So I thought to myself "Why not just set it all inside a function so I can use it later?" And one by one, I have created a function for everything that I ever needed whilst developing video games, and more. 
A few months have gone by and now we're here! PtrJS is officially out and <b><i>you</i></b> can use it! You just need to go over to the <a href="https://github.com/leptr/ptrjs" targer="_blank">GitHub repo</a> and read the documentation. It's easy to use, I swear!
You can find the source code and the documentation over at the <a href="https://github.com/leptr/ptrjs" targer="_blank">PtrJS repo</a> on GitHub!
I hope you will enjoy using the framework as much as I have enjoyed developing it.
Cheers!
Numpy and Python
Tags: python
Published: 2019-07-22 14:24:12

---
title: Numpy and Python
published: true
description: python 
tags: python
cover_image: https://cdn.pixabay.com/photo/2015/11/15/07/47/geometry-1044090__340.jpg
---
If you want to work with arrays, matrices and more, the module numpy is great.  Without numpy, you would be using loops to create lists of numbers appending the numbers and so. That isn't very practical.

<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fthumbs.gfycat.com%2FCarefulAlienatedIzuthrush-max-1mb.gif&f=1">

Then there's numpy. You can easily create lists of numbers with numpy.  This can be single list numbers like ones, zeroes or lists that contain incremental values. It even supports multi-dimensional lists. The program below creates different lists. 

    #!/usr/bin/python3
    import numpy
    
    x = numpy.zeros(6)
    print(x)
    x = numpy.zeros((2,3)) 
    print(x) 
    x = numpy.ones((2,3)) 
    print(x) 
    x = numpy.empty((3,3))
    print(x)
 
    print(numpy.arange(6))
    print(numpy.arange(0,6,2) )

Output of the above program

    [0. 0. 0. 0. 0. 0.]
    [[0. 0. 0.]
     [0. 0. 0.]]
    [[1. 1. 1.]
     [1. 1. 1.]]
    [[0.00000000e+000 1.53582796e-316 6.93295664e-310]
     [6.93294681e-310 6.93295664e-310 6.93294655e-310]
     [6.93294681e-310 6.93294681e-310 3.95252517e-322]]
     [0 1 2 3 4 5]
     [0 2 4]

This created different lists of numbers. You can store the output (x =) or directly output it to the screen with the print function

Related links:
* <a href="https://numpy.org/">Numpy module website</a>
* <a href="https://pythonbasics.org/exercises/">Python exercises</a>
* <a href="https://pythonbasics.org/">Learn Python Programming</a>
* <a href="https://pythonprogramminglanguage.com/">Other python tutorial</a>
GraphQL from Ground Up
Tags: graphql, node, apolloserver, apollographql
Published: 2019-07-22 14:09:20

---
title: GraphQL from Ground Up
published: true
description: Learn GraphQL by building a fully-featured API with Node.js.
tags: graphql, node.js, apollo server, apollo graphql
cover_image: https://thepracticaldev.s3.amazonaws.com/i/bmlptxyap1hdan29z45y.png
---

I'm glad to announce my latest course *[GraphQL from Ground up](https://tutstack.io/courses/graph-ql-from-ground-up)* is now available for early access! This is a practical course where you’ll learn GraphQL by building a fully-featured API for a forum completely scratch.

The course cover:

* What's GraphQL and its improvements over REST
* Understand GraphQL schema and type system
* Understand GraphQL scalar types
* Create custom scalar types
* Understand resolvers
* Integrate database with GraphQL
* Understand how GraphQL operations such as query, mutation and subscription works
* Handle file uploads in GraphQL
* Authentication and authorization
* Understand GraphQL directives
* Create custom directives
* Pagination
* Query optimization with Dataloader
* ... and much more


Take advantage of the early access price and get it for just $10.

👉 **[Get the course](https://tutstack.io/courses/graph-ql-from-ground-up)**
Run your Rails migrations from the web browser
Tags: rails, activerecord
Published: 2019-07-22 13:58:15

Something that is painful to me with Rails is when doing a `git pull` on a branch with new migration scripts, and getting this error page:

![](https://thepracticaldev.s3.amazonaws.com/i/ygsalkucfancqm0qnt4t.png)

This is nice, you know there are migration scripts to be executed, you even have the command to be executed in order to _solve_ the issue ... but that's all.

You have to open your terminal, go to the project's folder, run that command (or adapt it to Docker if you're using Docker), it will load the environment (so taking few seconds) then, finally, run the migration scripts.

## Enter the ActiveRecord Migration UI gem

At [Pharmony](http://pharmony.lu/) we took the time to fix it so that now, all of that is now from the past! Look at that:

![](https://thepracticaldev.s3.amazonaws.com/i/bmdzqm15i0jqyyus3z2l.png)

You just get a nice page, with the list of pending migration scripts, and a simple "Migrate now!" button.

As the environment is already loaded, as you're in a Rails app, you don't wast time and just immediately migrate your database! 👌

### Installation

You just have to add the gem to your `Gemfile` from your Rails app, run the `bundle` command and restart your server.

Next time you got pending migration scripts, this page will show up and you'll know what you have to do! 😎

### One more thing

This gem will be enriched with many more features but you already have a ~~buggy~~ log view after the scripts ran:

![](https://thepracticaldev.s3.amazonaws.com/i/oz29hr9bsrixwelginx7.png)

Clicking the migrated script shows the logs of that migration.

## Where is the source code?

The gem is open source, under MIT licence, hosted on our Gitlab group: https://gitlab.com/pharmony/active_record_migration_ui.

Please feel free to contribute and report issues!

Help us to make it visible to the world by upvoting on [ProductHunt.com](https://www.producthunt.com/posts/activerecord-migration-ui)!