teleren/devto huggingface dataset:
Awesome Terminal upgrades - Part Two: Upgrade and use a newer version of ZSH on macOS
Tags: opensource, productivity, zsh, bash
Published: 2019-12-15 02:36:00

---
title: Awesome Terminal upgrades - Part Two: Upgrade and use a newer version of ZSH on macOS
published: true
description: Awesome Terminal upgrades - Part Two: Upgrade and use a newer version of ZSH on macOS
tags: opensource, productivity, zsh, bash
series: Awesome Terminal upgrades
---

This is part two in the **"Awesome Terminal upgrades"** series. In this short tutorial we will cover ZSH on macOS and how you can upgrade and manage it using Homebrew. 

## Install [Homebrew](https://brew.sh/)
> The missing package manager for macOS (or Linux)

We will be using Homebrew to manage everything for us, if you don't have it installed, go ahead and do it now!

```
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```

By default OSX has ZSH installed, but we're going to use homebrew to install ZSH so we can upgrade it and keep up to date with new releases.  


### Confirm the current active zsh version:

``` 
zsh --version
```

### Confirm the location of zsh:

```
which zsh
```
The output should look like `/bin/zsh`

### Confirm the shell that’s set for your user:

```
dscl . -read /Users/$USER UserShell
```
The output should look like `UserShell: /bin/zsh`


### Install ZSH:

```
brew install zsh
```

### Use brew ZSH:

```
sudo dscl . -create /Users/$USER UserShell /usr/local/bin/zsh
```

After that, restart your Terminal to have it take effect.

Now if you run `which` again, you’ll see the system is recognizing the one you installed:

```
which zsh
```
The output should look like `/usr/local/bin/zsh`

### Confirm you're running brew ZSH:

```
dscl . -read /Users/$USER UserShell
```
The output should look like `UserShell: /usr/local/bin/zsh`

### Change your shell to the right ZSH

```
sudo chsh -s $(which zsh)
```

Sometimes Switching ZSH shells can throw up some unsuspected errors, so you might want to add this to your `.zshrc`

```
export PATH=$HOME/bin:/usr/local/bin:$PATH
```

Awesome, your shell is now using ZSH managed by Homebrew! 
You can update ZSH whenever you like, as well as your other Homebrew installs by running:

```
brew update && brew upgrade
```
Send message as a Telegram bot. What may go wrong?
Tags: telegram, bots, node, javascript
Published: 2019-12-17 13:45:11

Last month I've worked on [@hltvFeatured](https://t.me/hltvFeaturedBot) – it's a Telegram bot to get notifications about upcoming Counter-Strike: Global Offensive matches featured by HLTV.org. 

![Example of @hltvFeatured message](https://thepracticaldev.s3.amazonaws.com/i/zb9ihaoxjfca6rbgsd7r.png)

After a few weeks in production I've got an alert that the bot fails on sending notifications to subscribers. I had no access to my PC, so it was so nervous. I didn't know what may go wrong. 

When I back to home first of all I opened IDE and started debugging. There were no issues with database, the app's code or network. But the Telegram API returns error `400: Bad Request: can't parse entities`. I've started analyze what wrong with the messages and why it didn't fail before.

Telegram API allows to format messages in two styles: [Markdown and HTML](https://core.telegram.org/bots/api#formatting-options). I've selected Markdown as less verbose and wrote a small function to convert match data entity to a Markdown string:

```javascript
function convertToMessage({ event, href, stars, title, unixTimestamp }) {
  const when = new Date(unixTimestamp).toUTCString()
  const date = formatUTCString(when).replace(/\s/g, NBSP)

  return `
[${title.replace(/\s/g, NBSP)}](${href})
Rating: ${'☆'.repeat(stars) || '–'}
_${date} @ ${event}_
`.trim()
}

```

That day matches had an interesting event name: _cs_summit 5_ and I immediately noticed it. As you can see the convert function makes date and event _italic_: `_${date} @ ${event}_`. So the message contained three underscores. I didn't expect that Telegram API can't parse a message like that, so I've started search for a dependency to escape symbols like `_`, `*` and `[` in matches data before inject it in message template.

You have no idea how I was surprised when Telegram API answered with the same error for a message with escaped symbols. This time I went to google it. The solution was a suggestion to use HTML markup and escape symbols. I've updated my function and... it works!

```javascript
function convertToMessage({ event, href, stars, title, unixTimestamp }) {
  const when = new Date(unixTimestamp).toUTCString()
  const date = formatUTCString(when).replace(/\s/g, NBSP)

  return `
<a href="${href}">${escapeHtml(title).replace(/\s/g, NBSP)}</a>
Rating: ${'☆'.repeat(stars) || '–'}
<i>${date} @ ${escapeHtml(event)}</i>
`.trim()
}
```

I can't imagine a case when Markdown is a good choice  to markup messages delivered by a bot. And if you can, please, share in comments :)
Why do you write code??
Tags: discuss
Published: 2019-12-15 12:45:54

I get asked this question alot because it normally looks like I enjoy what I do. Actually, the real question is why do I write code?

I personally code because it gives me enjoyment. I don’t think I have ever had a job more satisfying than coding and solving problems, Creating web sites and web applications feels like something i was always ment to do,i don't see myself doing anything else.

##What are your reasons??
Beginner's Guide to Requests and APIs
Tags: python, requests, beginners
Published: 2019-12-16 09:21:19

The **requests** module is your portal to the open web.🤯 Basically any API that you have access to, you can pull data from it (Though your mileage may vary). 



## Getting Started ✊

Installing requests needs [pipenv](https://pypi.org/project/pipenv/), so go ahead and install that first if you don't have it. If you do, simply run this command:
```python
pipenv install requests
```

### Let's go ahead and pick an API to use.🤔
Here is a great resource to public APIs: 
{% github public-apis/public-apis  %}
 
Let's use the **kanye.rest** API for this quick example: https://kanye.rest/  

## Diving In 🙌
Let's import the all mighty:
```python
import requests
```
And **get**-ting the data is pretty straightforward:
```python
kanye_url = requests.get('https://api.kanye.rest')
```
Print it in JSON format:
```python
print(kanye_url.json())
# gets a random quote
# {'quote': 'Tweeting is legal and also therapeutic'}
``` 

It is important to read the docs of each API because each API is unique 🧐

Let's say we want to get a Chuck Norris joke from this API: 
From the docs it uses a different URL, so let's go ahead and code that:
```python
chuck_url = requests.get('https://api.chucknorris.io/jokes/random')
print(chuck_url.json())
```
... will output something like this:
```
{'categories': [], 'created_at': '2016-05-01 10:51:41.584544', 'icon_url': 'https://assets.chucknorris.host/img/avatar/chuck-norris.png', 'id': 'DLqW_fuXQnO1LtveTTAWRg', 'updated_at': '2016-05-01 10:51:41.584544', 'url': 'https://api.chucknorris.io/jokes/DLqW_fuXQnO1LtveTTAWRg', 'value': 'Chuck Norris Lost his virginity before his Dad...'}
```
...not exactly pretty to look at, so let's *pretty-print* it:💅
```python
# 👇 Add this import below at the beginning of your file    
# import json

print(json.dumps(chuck_url.json(), indent=2))
```
Now it looks like this: 
```
{
  "categories": [
    "science"
  ],
  "created_at": "2016-05-01 10:51:41.584544",
  "icon_url": "https://assets.chucknorris.host/img/avatar/chuck-norris.png",
  "id": "izjeqnjzteeqms8l8xgdhw",
  "updated_at": "2016-05-01 10:51:41.584544",
  "url": "https://api.chucknorris.io/jokes/izjeqnjzteeqms8l8xgdhw",
  "value": "Chuck Norris knows the last digit of pi."
}
```
Now that's much more readable! 💪💪💪

Sources:
🐍 https://3.python-requests.org/
📖 https://github.com/public-apis/public-apis
🌊 https://kanye.rest/
🤠 https://api.chucknorris.io/
How to connect Power BI to ODBC data source and access data in 3 steps

Tags: odbc, powerbi, software, odbcdriver
Published: 2019-12-16 10:14:24

How to connect Power BI to ODBC data source and access data in 3 steps

- Install the driver and configure an ODBC data source. Start Power BI and choose Get Data > Other > ODBC.
- Choose the DSN that you configured for the ODBC Driver and enter your credentials in the next step.
- Now Power BI database connection is established: you can load a table for business intelligence reporting.

Devart drivers provide Direct access to your databases and clouds from Power BI, which eliminates the use of database client libraries, simplifies the deployment process, and extends your application capabilities.

Learn more at [https://www.devart.com/odbc/powerbi/](https://www.devart.com/odbc/powerbi/)
What tools do you all use for multiple monitor setup?
Tags: productivity, discuss
Published: 2019-12-17 07:09:19

I recently got my setup to 5 monitors. So far it's been good and I am getting used to a few little quirks of the new flow, but I am curious if anyone out there has any cool programs or tips for being more productive on a setup like this. I am on Windows 10 if that matters.
Digital nomads, remote work, travelling... What makes you love/hate this?
Tags: discuss, travel, motivation, career
Published: 2019-12-17 09:46:00

Hey 👀✨

I'm thinking about writing an article about how to travel and work remotely cheap, having fun, and having a comfortable stay. 

I haven't got much experience about working in different countries, so I thought it may be a good idea to see **what you people think about this topics**, and also to **collect information, links and any kind of help you'll like to share with the world.**

So... **what makes you love || hate travelling, working remotely etc...?**

Personally, I cannot find any blockers for me to do this (yet), so I'm eager to read what you have to say 🙈✨

![Travelling](https://media.giphy.com/media/l3V0uMsvphowDr17O/giphy.gif)
Lost in Translation (An Alexa Skill)
Tags: alexa, aws
Published: 2019-12-17 13:11:54

*"Alexa, launch [Translation Lost](https://smile.amazon.com/dp/B082R3YQ3B/ref=sr_1_1)"*


Lost in Translation was the first Alexa Skill that me (and a friend)  published on Amazon's Alexa Skill Store. This post will overview what the game does, how it does it's stuff, and some of the problems we ran into.


## What It Do

Lost in Translation is a speech based game in which Alexa says a phrase in an accent and the player has to guess what Alexa said. For example, Alexa might say something like "May the Force be With You", but in a Korean accent. After which the player should respond with that same phrase. By default, the player has five minutes to score as many points as they can, with each phrase correct being a point. If they need help, the player can  ask Alexa for a hint, or just give up on the phrase if it's too hard (sometimes it's near impossible).
## How It Do

[Code Repo](https://github.com/Viltaria/Translation-Lost)

This project was written using Amazon's [Litexa](https://litexa.com/), or a literate style programming language for Alexa Skills. Litexa provides an easy interface interacting with AWS services such as DynamoDB, S3, and Polly. You can view the entire workflow of the Skill in `litexa/main.litexa`.


## Problems
- Limited Alexa/Polly [Voice Support](https://developer.amazon.com/en-US/docs/alexa/custom-skills/speech-synthesis-markup-language-ssml-reference.html#voice)
    - Alexa doesn't support a lot of the voices that AWS Polly offers, this led us to hardcode a lot of the voice phrases, as we couldn't dynamically generate most of the ones we wanted (the Asianic Language ones are just hilarious)


[Try it out!](https://smile.amazon.com/dp/B082R3YQ3B/ref=sr_1_1)

[More Info](keygolem.com/lost-in-translation/)
Practical Puppeteer: How to emulate timezone
Tags: puppeteer, javascript, timezone
Published: 2019-12-17 14:33:39

Hi everybody! Today Puppeteer topic will be about emulating timezone when accessing a web page. This feature available since Puppeteer version 2.0.0 and I think this API is very useful for testing or other use cases.

My use case would be testing data that has datetime information related to user's timezone when he/she access my website.

Now I just want to create a small script to test this nice feature. On Puppeteer, the API to emulate timezone is `page.emulateTimezone(timezoneId)`. The scenario is we will set the timezone to `Asia/Makassar` (which is GMT+8) and we will go to website https://whatismytimezone.com to check the timezone emulation correct or not. Simple right?

Let's start.

## Preparation

Install Puppeteer

```
npm i puppeteer
```

## The code

File `emulate_timezone.js`

```js
const puppeteer = require('puppeteer');

(async () => {
	// set some options (set headless to false so we can see 
	// this automated browsing experience)
	let launchOptions = { headless: false, args: ['--start-maximized'] };
	
	const browser = await puppeteer.launch(launchOptions);
	const page = await browser.newPage();

	// set viewport and user agent (just in case for nice viewing)
	await page.setViewport({width: 1366, height: 768});
	await page.setUserAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36');

	// emulate to Asia/Makassar a.k.a GMT+8
	await page.emulateTimezone('Asia/Makassar');

	// go to the web
	await page.goto('https://whatismytimezone.com');

	// close the browser
	// await browser.close();
})();
```

As usual, I set the `headless` option to `false` so we can see the browser in action and I am not close the browser at the end of the script.

## Run it

```
node emulate_timezone.js
```

If everything OK then it will show information like below.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ot23bm5pqcgce4d26adl.png)

My timezone is `GMT+7` and above screenshot is show `GMT+8` (since we set timezone emulation to `Asia/Makassar`). It means the timezone emulation works perfectly.

Thank you and I hope you enjoy it.

Source code of this article available at https://github.com/sonyarianto/emulate-timezone-in-puppeteer.git

## Reference
- https://pptr.dev
- https://whatismytimezone.com
Chord Diagram 🔥
Tags: codepen, fusioncharts, charts, chord
Published: 2019-12-17 16:25:34

---
title: Chord Diagram 🔥
published: true
tags: codepen, FusionCharts, charts, chord
---

<p>Chord diagram is a visually appealing way to represent weighted relationships in a radial layout. Entities (or categories) among which the weighted relationship exist are drawn on the circumference whereas the actual weighted relationship are drawn as links in the circular space of the chord diagram. Most of the time this weighted relationship is a flow or a movement like, migration of people from one country to another, or, subscribers switching telecom operators. The essence of a chord diagram is in knowing the dominant relationship and one can toggle to narrow focus on most important relationships.</p>

<p>Learn more about chord diagram <a href="https://www.fusioncharts.com/charts/chord-diagram" target="_blank">here</a>.</p>

{% codepen https://codepen.io/fusioncharts/pen/OJPbwxJ %}
Ship Accessible [React] Apps
Tags: a11y, webdev, react, javascript
Published: 2019-12-17 19:01:30

---
title: Ship Accessible [React] Apps
published: true
description: Humans with disabilities have a right to access the same wealth of knowledge and utility the internet provides able-bodied folks.
tags: a11y, webdev, react, javascript
cover_image: https://og-image-egghead-course.now.sh/develop-accessible-web-apps-with-react?v=20191209devto
---

Assuming for a moment that you can see...

Have you ever blindfolded yourself and tried to use your computer or phone?

When was the last time you navigated your current project with a screen reader?

Maybe that's somebody else's problem?

🙄

A large number of people with impairments or disabilities are unable to use the web effectively.

This is not their fault. 

It's unacceptable to ignore this fact.

As web developers, we have a responsibility to try harder. To do more. To learn what it takes to make our applications as accessible as possible.

This means we need to understand the modern tools and techniques to make this happen and deliver a consistent user experience to as many folks as possible.

Listen, we're not here to lecture you, but as a society, we have to come together. 

This isn't about wagging our fingers or posturing for internet points.

Accessibility matters!

**Humans with disabilities have a right to access the same wealth of knowledge and utility the internet provides able-bodied folks.**

We have a *responsibility* to do the right thing and take a stand for accessible web applications.

None of us are perfect, but we can choose to do better.

Erin Doyle is an expert in creating accessible React applications and has put together a course for you that presents a concrete process to test and develop with accessibility in mind.

After watching her new course, you’ll be prepared to audit and fix issues in your existing apps and have a better understanding of how to approach development from the perspective of your users.

Even if you aren't building React apps right now, these concepts carry over and the course is an exploration of common patterns and solutions for accessible modern web applications

[![](https://res.cloudinary.com/dg3gyk0gu/image/upload/c_scale,dpr_auto,e_unsharp_mask:100,w_244/v1576543637/email-images/AccessibleReact_1000.png)](https://egghead.io/courses/develop-accessible-web-apps-with-react)

-> [Building Accessible React Apps](https://egghead.io/courses/develop-accessible-web-apps-with-react) (*this course is egghead members only, but the first couple of lessons are free to view*)

Erin and I also [recorded a podcast](https://egghead.io/podcasts/test-driven-accessibility-with-erin-doyle) on this subject!
Top 5 DEV Comments from the Past Week
Tags: bestofdev
Published: 2019-12-17 19:51:56

---
title: Top 5 DEV Comments from the Past Week
published: true
description: Highlighting some of the best DEV comments from the past week.
tags: bestofdev
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--7VrAA2ln--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://thepracticaldev.s3.amazonaws.com/i/qmb5wkoeywj06pd7p8ku.png
---

This is a weekly roundup of awesome DEV comments that you may have missed.  You are welcome and encouraged to boost posts and comments yourself using the **[#bestofdev](/t/bestofdev)** tag.

The discussion of **[How many programming languages do you know?](https://dev.to/ben/how-many-programming-languages-do-you-know-50op)** generated two particularly great replies.  First, @deciduously offers a good-hearted response:
{% devcomment j1n5 %}

@kenbellows follows up later in the thread with three "themes" across different programming languages:
{% devcomment j213 %}

@isaacdlyman offers thoughtful response to **[What’s the most under-appreciated software?](https://dev.to/ben/what-s-the-most-under-appreciated-software-ce4)**:
{% devcomment in00 %}

@thatonejakeb adds their suggestion to **[What's the best thing to do when you've run into a debugging dead end?](https://dev.to/ben/what-s-the-best-thing-to-do-when-you-ve-run-into-a-debugging-dead-end-39jg)**:
{% devcomment j3d5 %}

@samuraiseoul chimed in to the **[9 Extremely Useful HTML Tricks](https://dev.to/razgandeanu/9-extremely-useful-html-tricks-463a)** thread to talk more about datalist tag, and to offer a cool trick of their own:
{% devcomment io27 %}

See you next week for more great comments ✌
Tips ORM Laravel that can help you
Published: 2019-12-18 01:50:10

The Eloquent ORM Laravel is too difference ORM that all others Framework that I used, he really help us are productive work, let's go around a somethings tips that I separated for you.

### 1. Order by
```php
$items = Item->orderBy('created_at', DESC)->get();
```

### 2. Where
```php
$items = Item->where('category_id', $id)->orderBy('created_at', DESC)->get();
```

### 3. Where month (Ex.: January)
```php
$items = Item->whereMonth('created_at', '1')->get();
```

### 4. Where year
```php
$items = Item->whereYear('created_at', '1999')->get();
```

### 5. Where between
```php
$users = DB::table('users')->whereBetween('votes', [1, 100])->get();
```

You can also use aggregate, _sum, max, min, count, avg_, for example
### 6. Aggregate
```php
$users = DB::table('users')->count();
```

Sometimes, you may not want to select all columns, so, using _select_ method, you can specify the columns you need
### 7. Select specify columns
```php
$users = DB::table('users')->select('name', 'email as user_email')->get();
```

### 8. Select random row
```php
$randomUser = DB::table('users')
                ->inRandomOrder()
                ->first();
```

### 9. Union querys
```php
$first = DB::table('users')
            ->whereNull('first_name');

$users = DB::table('users')
            ->whereNull('last_name')
            ->union($first)
            ->get();
```

### 10. Join tables
```php
DB::table('users')
        ->join('contacts', function ($join) {
            $join->on('users.id', '=', 'contacts.user_id');
        })
        ->get();
```

It`s, I hope you like ten tips of Eloquent Power, if you need read more about this topic, check out the documentation of Laravel: 

- https://laravel.com/docs/5.8/queries
- https://laravel.com/docs/5.8/eloquent

See you later!
Seeking any help/resources for MacOS logging using Splunk
Tags: security
Published: 2019-12-18 04:40:14

We need to index system logs from about 100 Macs using Splunk. I have more experience with iOS mobile device management rather than logging with Mac.

If anyone has any pointers I'll post updates here. Thanks! 

Update (January 2020)::
Apple has an entirely new binary, database format for logging their os. This prevents other parties (like Splunk) from reading logs and the daily log can exceed several GB in size with 20 million log entries! 

Solution: script tasks using native utility LOG to extract logs you need. I'm still not able to get this in a human readable format but slow progress is better than none I suppose.

We will only be able to use bash scripts so if anyone has a hobby of working with bash on Mac I'm all ears🤗
Frameworks can be frustrating sometimes
Tags: wordpress, joomla, cakephp, cordova
Published: 2019-12-18 12:41:01

Frameworks, like wordpress, joomla, cake php, spring, cordova and so on, can really be a pain in the ass. They don't give you enough flexibility to adjust what you need to. You are typically at the mercy of their community. 

You always need to work within the frame, except you are a good programmer you can study the files and make your code changes to your taste. The whole idea of a framework should be speed, organisation and FLEXIBILITY.
 
It would be nice to get some frameworks that allow developers customize the codes easily to their taste, without having to send series of mails to support or checking countless files to link where each function came from.