teleren/devto huggingface dataset:
Go vs PHP for short JSON-retrieving code
Tags: go, php, json, tutorial
Published: 2020-01-17 06:49:51

I found [this nice tutorial](https://dev.to/cskonopka/get-daily-earthquake-data-from-the-usgs-using-go-45gl) on retrieving data about recent earthquakes (from US gov service) - it nicely prints the place and magniuted of every event! Thanks to Christopher (@cskonopka)!

Example uses `Go` - and I'm currently studying this language. It seems, however, that for simple JSON retrieval/parsing task compiled languages are not excellent. I'm from `Java` world myself and it is always weird for me to create special class or structure repeating the expected JSON.

I feel `Python` or `PHP` may give easier code. So let's try for comparison (I choose `PHP` as it's syntactically closer to `Go`). I ~~promise to find~~ [did](https://dev.to/rodiongork/go-vs-php-json-and-earthquakes-part-2-3cdc) struct-less approach in Go too :)

### Let's code!

**Firstly** - create url by glueing the service address and date parameters:

```php
$url = "https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson";

$today = date('Y-m-d');
$yesterday = date('Y-m-d', time() - 24 * 60 * 60);

$fullUrl = "$url&starttime=$yesterday&endtime=$today";
```

**Second step** - fetch data, check for error and parse json:

```php
$data = file_get_contents($fullUrl);

if ($data === false) {
    echo "Error retrieving json\n";
    exit(1);
}

$json = json_decode($data);
```

**Third and last** - let's print places and magnitudes of events!

```php
foreach ($json->features as $record) {
    $prop = $record->properties;
    echo "{$prop->place} {$prop->mag}\n";
}
```

### Analysis

So the code has much similarity between PHP and Go, but we get some leisure due to:

- ready functions to perform HTTP request and parse JSON
- fact that scripting language creates structs from JSON "on the fly"

The last is quite nice feature to me, as I mentioned, working in backend services with Java and similar compiled languages, I always felt it is painful rewriting and rebuilding files in several projects when some JSON response format is changed (this is especially true if some strictly-thinking colleague makes unmarshaller break upon new/unknown attributes).

However, as I said, I'm going now to try and see for struct-less approach in Go (brief googling hints there are ways). Hope to post this separately when I build example.

Thanks for reading that far :)
HTML5  Basics
Published: 2020-01-17 06:44:17

In Module 2 we explored the concepts expressed below;

Write code to mark the text Gourmet Thai Cooking as a heading with the second level of importance.

To mark the text Gourmet Thai Cooking as heading with second level of importance and italicize it, the code should look as follows; <i><h2> Gourmet Thai Cooking </h2></i>.

What is the div element and why will you often encounter it in pre-HTML5 code?

Div element defines a division or section of a HTML document. It is more frequently encountered in pre HTML5 because back then sections were defined as divisions using the div element. <article> & <section> are semantic elements that replace <div> whenever possible. 

What element would you use to indicate a change of topic within a section?

To indicate a change of topic within a section the <hr></hr> tags should be used. 

Write the code to mark the text Daily Special as emphasized text.

To mark the Daily Special as emphasized text the following code should look as follows; <em> Daily Special </em>.

Write code to mark the text H2SO4 with subscripts.

To mark subscripts in the chemical composition above, the code should look as follows; H<sub>2</sub>SO<sub>4</sub>.

Write the code to link the web page to the CSS file mystyles.css.
In order to link the web page to the CSS file mystyle.css, the code should look as follows; <link rel = “stylesheet” href = “mystyles.css”>.

Write the expression to insert the em dash into a web page using the character code 8212.

&#8212; is the way to insert the em dash into web page using character code. 

Write the code to insert an inline image using the source file awlogo.png and the alternate text Art World.

In order to insert an inline image using source file awlogo.png and the alt text Art World, the following code should be displayed; <img src= “awlogo.png” alt= “Art World”>.
QuickBooks Error PS033
Published: 2020-01-17 06:37:31

Being a QuickBooks user, I must say that if you ever got under with QuickBooks Error PS033 then you should call the QuickBooks Support team. 

The foremost is to Check for your installation, as this error is the result of improper installation. <a href="https://quickbooksfixes.com/quickbooks-payroll-update-error-ps033-how-to-fix/">QuickBooks Error PS033</a> incurs on our screen when there is a poor internet connection.
First CRUD application! (Express.js/MongoDB)
Tags: javascript, node, beginners, mongodb
Published: 2020-01-17 06:17:00

Hey DEV's!

This is actually my first post and to be honest, I am kinda excited to share this with you all.🤪

I've been studying programming for the past few months. HTML and CSS were familiar but I had no clue about Javascript.

I took a really awesome course on Udemy that helped me a lot. Then, right after that, I took another one about Node.js/ Express, and MongoDB.

In my case, I learn by "doing". So, instead of following the same projects, I decided to create a basic **CRUD** application to apply what I have been learning.

The result:[ Journals](https://appjournals.herokuapp.com/)

What I **used/learned** along with this project:
-CSS Framework (PaperCSS)
-API's
-Server-side Rendering (Pug)
-Javascript fundamentals and ES6
-Node.js & Express.js
-MongoDB
-Github
-Heroku

And so much more! 😯

I know that this will be a long journey but after finishing this as my second project (The first one was a simple To-Do List built with Javascript), I can say that it is totally worth it!

**What helped me:**
1. Create a plan (What I will learn first? And after that?)
2. Followed concepts, not "Do what I Do" (Never followed the same project, always tried something different with the same concepts)
3. “The best is the enemy of the good.” mindset!

About the number "3". I started to learn programming before but I gave up twice because I couldn't get everything at first. Stupid mistake!
Now, I will try. If that doesn't work, I will try another way. It doesn't matter if it is not the BEST way, but if it works, **I will celebrate my small victory TODAY and improve TOMORROW!**😌

That's all! I hope to be more around here!
Best,

Lucas L.

PS 1: This was only for learning purposes.
PS 2: The list with things I didn't focus was way bigger (handling errors, security, authentication, etc...)

----
**TO FIX:**
- If you try to create a post without one of the fields (First Name, Last Name, Title, or Text), it will return an error.

----
Let's fight Pneumonia with free compute from Kaggle
Tags: machinelearning, python
Published: 2020-01-17 03:44:04

# Pneumonia xray detector

![xray](https://thepracticaldev.s3.amazonaws.com/i/0xcu7fxz2i5djx9l2q3z.png)



Let's use the power of machine learning to fight back against pneumonia.

We will fight pneumonia using 2 resources
1. Kaggle.com
2. "Deep Learning with Python" by Cholet

### Kaggle
Let's use the awesome resources that Kaggle.com can provide us. We can use their GPU power, data sets, and awesome community support.

Check the code out [here](https://www.kaggle.com/shanecandoit/pneumonia-chest-xray) 

### Deep Learning with Python
I was able to do all this with just the examples from "Deep Learning with Python" by Francois Cholet,(the author of the Keras framework).

## Step 1 Find a dataset to use

I went to kaggle and then to [datasets](https://www.kaggle.com/datasets) and searched for [pneumonia](https://www.kaggle.com/search?q=pneumonia) and picked [this dataset](https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia). There are other better ones, but that's the one I started with.

## Step 2 Write a classifier

![accuracy](https://thepracticaldev.s3.amazonaws.com/i/5oaw3gpcp3b8czwaj0yj.png)


I went to page 132 in the book which has a cats-vs-dogs classifier. I basically the same code. (I actually moved some training images into the validation set because there were so few validation images).

I had this working and labelling healthy lungs as 0 and xrays with pneumonia with a 1. These are both classification problems (not "which of 10 categories is this" like MNIST).


## Step 3 A score helps, a heat map helps more

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

A score is not good enough, we can do better. Let's have the model make a heatmap so a human can see which part of the xray is more likely to be diseased. That is a much better diagnostic tool, I think.

I used the code on pages 174 and 175 to create a heatmap. This could tell a physician were to look in the xray for problems.


## Now what?

Try to learn machine learning too! Use the high quality [Kaggle](kaggle.com) datasets and their competitions to make it fun. 
 - Doing this pneumonia classifier felt way more meaningful than another lame MNIST or dog-vs-cat classifier.
 - Creating more people with skills like this may lead to better medical outcomes and cheaper healthcare.
 - Show me what you got ML leaners!
Closure in Javascript
Tags: javascript, webdev, career, tutorial
Published: 2020-01-17 05:19:44

 **closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain. The closure has three scope chains: it has access to its own scope (variables defined between its curly brackets), it has access to the outer function’s variables, and it has access to the global variables.**


__code__
{% runkit %}
function dosomecalculations() {var a=5;var b=4;function multiply() {
    var result = a*b;
    return result;
}
return multiply;
         }


var output = dosomecalculations(); 

//code for output
console.log("The result:", output());  

{%endrunkit%}
The 3 mechanisms cooperating to control the Bitcoin Supply
Tags: bitcoin, halving, twitterbot, aws
Published: 2020-01-17 05:07:44

I built a twitter bot called @BitcoinProgress [https://twitter.com/BitcoinProgress] with the primary intention of educating users about the quadrennial subsidy halving event. If you're interested in learning about the halvening event, give the bot a follow and check out Andreas Antonopolous' bitcoin book chapter 10 on "Mining and Consensus" on GitHub:

https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch10.asciidoc#bitcoin-economics-and-currency-creation

Basically, the supply and creation of new bitcoins are controlled via a few simple mechanisms. The basics of how bitcoin is created as follows:

The first mechanism is the distribution of Bitcoin to miners:
Bitcoin miners compete to find a nonce value that falls below a certain target. When a miner finds a valid nonce that, upon being hashed, results in a number lower than the target - they are subsidized for their work in both transaction fees and new Bitcoin. The initial subsidy started at 50 BTC. 

The second mechanism controls the pace that new Bitcoin is created:
Finding the nonce should take roughly 10 minutes on average in order to control the pace at which new bitcoin enters the market. The network makes difficult adjustments every 2016 blocks to regulate block time.

The third and final mechanism controls the quantity of Bitcoin that is generated over time:
The block subsidy is halved every 210,000 blocks or roughly every 4 years until the subsidy reaches 1 satoshi at which point it cannot be halved any further and the block subsidy ends. This halving cycle will repeat a total of 33 times.

If you found this interesting, then follow https://twitter.com/BitcoinProgress to track the halvening! 

If you are interesting in viewing the code you can check it out here:

https://github.com/deevolutionism/bitcoin-halving-progress-bar

The bot currently runs on an AWS lambda instance.
Setup Flashcard App The Hard Way
Tags: react, typescript, testing, tutorial
Published: 2020-01-17 04:52:33

How to start your own version of the project from scratch using create-react-app.

##1. Install Node Js
[Download page](https://nodejs.org/en/) Install Node if you don't have it already.

##2.Install NPM
[Download page](https://www.npmjs.com/package/download)
Install NPM. Once it is installed, open a command prompt and type 'npm-v'. Then hit enter. If NPM is installed, it will show you the version number.

```
npm-v 
```

##3. Use NPX, which comes with NPM, to run create-react-app
[Create React App instruction page](https://create-react-app.dev/docs/adding-typescript/)
Go to the directory where you want to create your project folder. Note: create-react-app creates a new folder inside the folder where you run it. So if you want to create your project in a folder /MyUserName/projects/flashcard, go to /MyUserName/projects and run create-react-app there. If you make the flashcard folder and run create-react app in it, you will end up with /MyUserName/projects/flashcard/flashcard

```
npx create-react-app flashcard --typescript 
```

##4. Use NPM, not NPX, to install the libraries
Install [React Testing Library](https://testing-library.com/docs/dom-testing-library/install)

Install [Semantic-UI-React](https://react.semantic-ui.com/usage)
```
npm i semantic-ui-react

npm install --save-dev @testing-library/react

npm install --save-dev @testing-library/jest-dom
```

##5. Try to Run it
Once you have installed the libraries, navigate to the folder using your command line. Type npm start and hit enter and the default create-react-app should start running. It will likely open the web browser and show you a spinning React logo.

##6. Add Semantic-UI-React styling
The easiest way to add the css styling that makes Semantic-UI-React components look right is to edit the index.html file and add a link to the Semantic-UI-React CDN.

If you want to install it a different way, look at this [link](https://react.semantic-ui.com/usage/).

#### Semantic UI React the easy way
Open the file %project directory%/flashcard-app/public/index.html
The top lines should look like:

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
...more stuff below
```

Paste the following in below the favicon code
``` 
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css" />
```

Now the top of your index.html should look like this:

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
...more code below
```

You are ready to get started! Go back to the Introduction to see an explanation of what a test is, or go to the second post to make the first component.
Python - Pipe-Oriented Programming
Tags: python, pipeorientedprogramming, functional
Published: 2020-01-17 04:20:30


How to do #PipeOrientedProgramming in Python.

With an example doing simple arithmetic operations,
as the result of one function is piped into the next.

The "lNum" util function means "log number".


```python
from pyLog import lNum
from pyNum import minus3, mod6, times2, minusNum, mNum, minNum

def pipepy(*funcs):
    def inner(data, funcs=funcs):
        result = data
        for f in funcs:
            #tsk: throwIfNotFunc
            result = f(result)
        return result
    return inner


# testonly
p1 = pipepy(
    mod6, lNum,  # 5
    times2, lNum,  # 10
    minus3, lNum,  # 7
    minusNum(4), lNum,  # -3
    mNum(2), lNum,  # 5
    minNum(25), lNum,  # 20
)
p1(5)
```


Also, three ways to curry a function in python...

```python
#curry, v1
def minusNum(x):
    def inner(y):
        return x - y
    return inner



#curry, v2
def mNum(x): return lambda y: x-y



#currry, v3
minNum = lambda x: lambda y: x-y
```



Resource:

{% twitter 1215430659767853058 %}



## Final words
If you have any input, ideas, opinions, questions, let me know.

There more pipe-oriented programming idioms, patterns and ideas coming in the future.
Geographical Version of Schelling's segregation Model built with Python!
Published: 2020-01-17 04:14:48

Check out this desktop application I have built with PyQt5 and PyQtGraph https://github.com/kartikeyas00/geo-schelling 

It allows to run the simulation for Schelling's segregation model on a real map. In this case, they are all 50 American states. 

Why I have built this app?
The main motivation was that in lots of agent based modeling cases and especially in Schelling's model of segregation, geological or geographical version is not present or when they are present they are not very well implemented. I wanted to see the Schelling's model simulating on a real geography and the outcomes of the simulation as the model is based for real world. After implementing the model and visually seeing the result, I was able to conclude thaat how segregation can happen in the real world (Obviously if we leave certain factors alone) based on the Shelling's approach.
How I Split Work: Recap
Tags: agile, workflow, productivity, beginners
Published: 2020-01-17 03:25:31

---
title: How I Split Work: Recap
published: true
description: Step by step process on how I go about splitting work
tags: agile, workflow, productivity, beginners
series: How I Split Work 
---

First off, thank you to everyone who has read my posts this will be the last one of the series. Today I will be recapping the series into a much smaller set of notes so you can bookmark this page for later.

1. Pitch
    1. Elevator pitch or more of user features and experiences.
    1. Enough to sell you on the idea
    1. Could come from anyone
1. Cut
    1. Take the pitch and cut out fluff, emotion, examples or unnecessary details
    1. Technical details are also cut and can be saved for the very end
    1. We end with a bullet point list of requirements
1. Merge
    1. Combine any bullet points that are very similar and can be handled together
1. Abstract
    1. Anything too specific can be abstracted up a level
    1. We end with a clean set of requirements
1. Detail your end results
    1. Blurb every idea you have
    1. You may need to trim down some ideas to fit your timeline, but I like to keep them all somewhere for later
    1. Check each idea to make sure it is viable and even possible
1. Detail how users start the experience
    1. Match your end results and requirements to what you will need
1. Draw it out
    1. Take the start and end to draw out a graph leaving a gap in the middle
    1. Fill in the middle, lining up the start and end parts with the requirements
1. Break down
    1. Take any abstract, high-level node and add details
    1. Split any merged requirements into separate nodes
    1. Make note of any edge cases and abort conditions
1. Review
    1. Get someone else to review your chart, preferably someone who wasn't part of the process
1. Cleanup the chart
    1. Optional: If you want to clean up your graph and maybe upload it somewhere
1. Order
    1. Start with closing the start > finish loop
    1. Then get the program to work correctly ( sometimes this is done already )
    1. Then handle any skipped edge cases, usually saving exceptions for last

If at any point you feel things are not lining up or feels a little off, maybe even too big. Stop and go back a step or two and try again. More art than science here, quickly doing one or two iterations until you are happy is better than being far off later.

Now you can start working, follow the style you prefer. I recommend TDD ( test-driven development ) or XP ( extreme programming ).

That is it, thank you for reading this series.
Introduction To Asynchronous JavaScript
Tags: javascript, asynchronous, http
Published: 2020-01-17 03:07:59

##**Introduction**

In JavaScript , we need to deal with Asynchronous behaviors.
- **Synchronous Code** - In synchronous programs, if you have two lines of code (**code1 followed by code2**), then **code2** cannot begin running until **code1** has finished executing.

- **Asynchronous Code**- In asynchronous programs, you can have two lines of code (**code1 followed by code2**), where **code1** schedules some task to be run in the future, but **code2** runs before that task completes.

*Note*: *JavaScript can have asynchronous code, but it is generally single-threaded.*

```
loadPastAsync(function(){
   //..wait till posts are fetched
   //..Do something with posts
});

doSomeThing(); 
   //Doesn't have to wait until post load

```

**Most Async codes you work with, will be a part of API or a Library**

For example,

- XMLHttpRequest & Fetch
- jQuery Ajax, Axios, other HTTP Libraries
- Node.js fs(File System) module

##**There are a few ways to work with Async Codes**

- Callbacks
- Promises
- Async/Await

##👏**What is AJaX**??

**AJaX - Asynchronous JavaScript with XML**

- It is a set of web technologies
- Send & Receive data asynchronously
- Doesn't interface with the current page
- JSON has replaced XML for the most parts nowadays.

![Request Response Criteria](https://thepracticaldev.s3.amazonaws.com/i/w9q3n4zvc0d4xe9wn2g6.PNG)

###*Importance*
- Make Async requests in the background.
- No page reload / refresh required(fast).
- Fetch data.
- Very interactive.

##**XmlHttpRequest(XHR) Object**

- API in the form of an object.
- Provided by the browser JS environment.
- Methods transfer data between client & server.
- Can be used with other protocols than Http.
- Can work with data other than XML(JSON,Plaintext).

####*What is JSON* ??
- JavaScript Object Notation

###***Other libraries & methods to make Http requests***

- FetchAPI (Good to work with)
- Axios (External library)
- Superagent (External library)
- jQuery (*Not recommend nowadays*)
- Node Http (*This is nice if you are using node.js*)


####👉**What's Next?** 

IF YOU HAVE DONE READING "Introduction To Asynchronous JavaScript" ARTICLE, I SUGGEST YOU TO READ MY NEXT ARTICLE.

- [How to make/code XHR Object Request ?](https://dev.to/mihinduranasinghe/xmlhttprequest-xhr-object-request-34dj)


##**Thank You**

***Hope you all enjoyed and learned something on this. Please let me know your comments suggestions and any questions you have about this blog.***

👉 Visit me - [https://mihinduranasinghe.com/](https://mihinduranasinghe.com/)
Configurando git en Windows para utilizarlo desde la linea de comandos
Tags: spanish, git, windows, commandline
Published: 2020-04-07 12:27:44

---
title: Configurando git en Windows para utilizarlo desde la linea de comandos
published: true
date: 2020-01-17 03:00:00 UTC
tags: spanish, git, windows, command line
canonical_url: https://blog.rodrigojuarez.com/dev/2020/01/17/windows-git.html
---

Uno de mis objetivos de este 2020 es aprender a utilizar Git desde la linea de comandos

En mi maquina de desarrollo principal utilizo Windows, por lo que aqui veremos los pasos que sigo para configurarlo

- [El enlace de descarga](https://git-scm.com/download/win)
- Seleccion de componentes, en general dejo las opciones por defecto, agrego algunos comentarios y los pasos en los que cambie los valores iniciales

![Image](https://i.imgur.com/uEuEMBh.png)

- Como editor selecciono VS Code (que ya tengo previamente instalado)

![Image](https://i.imgur.com/AUqb3nH.png)

- En relacion a la configuracion del PATH, dejo el valor recomendado, que me va a dar acceso al comando git cuando abra la linea de comandos

![Image](https://i.imgur.com/EIsqjkw.png)

- Como aplicacion de terminal, selecciono la aplicacion por defecto de windows

![Image](https://i.imgur.com/inrXsAB.png)

- Luego de finalizada la instalacion, ejecuto el siguiente comando desde la consola, para asegurarme que todo esta correctamente instalado

```
git --version

```

![Image](https://i.imgur.com/GvZUwVi.png)