teleren/devto huggingface dataset:
Using ffmpeg to compress, convert, and resize videos
Published: 2019-03-29 01:05:45

---
title: Using ffmpeg to compress, convert, and resize videos
published: true
description: 
tags: 
---

*My posts are usually notes and reference materials for myself, which I publish here with the hope that others might find them useful.*

Given a source video `source.mp4`:

To compress for web at a reasonable broadband bitrate of about 1.5Mbps video / 128kbps audio:

```
ffmpeg -i source.mp4 -c:v libx264 -b:v 1.5M -c:a aac -b:a 128k target.mp4
```

To compress and also convert to WebM:

```
ffmpeg -i source.mp4 -c:v libvpx-vp9 -b:v 1M -c:a libopus -b:a 128k target.webm
```

(Note that the 33% lower bitrate -- 1M for VP9 vs 1.5M for H.264 -- is deliberate; VP9 encodes about 20-50% more efficiently than H.264. Opus and AAC are about equally efficient.)

To scale down a high-resolution source video to something more reasonable for Web ([qHD for cellular, HD for broadband](https://en.wikipedia.org/wiki/16:9_aspect_ratio#Common_resolutions)), the `-filter:v` argument is used:

```
ffmpeg -i source.mp4 -c:v libvpx-vp9 -b:v 0.33M -c:a libopus -b:a 96k \
-filter:v scale=960x540 target.webm
```

Command-line options: `-c:v` specifies the video codec; `-b:v` specificies video bitrate; `-c:a` specifies audio codec; `-b:a` audio bitrate; `-filter:v` applies a filter (in this case, scale) to the video stream.

To use the older VP8 codec with WebM, use `libvpx` instead of `libvpx-vp9`.

If the source video does not have an audio track, then omit the `-c:a` and `-b:a` arguments.

To explicitly specify the container format, use the `-f` command-line option: `-f mp4` or `-f webm`.

For MP4 containers, the video codec used is H.264 and the audio codec is AAC, which enjoys near-universal browser support.

For Chrome and related browsers. WebM containers use VP8/9 and Opus. 

Chrome also supports MP4 (H.264/AAC), so there is no point providing WebM unless the file size and/or quality is improved.

Bitrates can obviously be varied; I use 0.5M video and 96k audio for cellular.
Get the number of days between two dates in Go
Tags: go
Published: 2019-03-29 00:49:30

Recently I needed to find the number of days between two dates in Go and kept coming across implementations that didn't quite suit my needs.

So I rolled my own, and I'm pretty proud of how robust it is! :)

```go
package main

import (
	"fmt"
	"time"
)

func main() {
	fmt.Println(daysBetween(date("2012-01-01"), date("2012-01-07"))) // 6
	fmt.Println(daysBetween(date("2016-01-01"), date("2017-01-01"))) // 366 because leap year
	fmt.Println(daysBetween(date("2017-01-01"), date("2018-01-01"))) // 365
	fmt.Println(daysBetween(date("2016-01-01"), date("2016-01-01"))) // 0
}

func daysBetween(a, b time.Time) int {
	if a.After(b) {
		a, b = b, a
	}

	days := -a.YearDay()
	for year := a.Year(); year < b.Year(); year++ {
		days += time.Date(year, time.December, 31, 0, 0, 0, 0, time.UTC).YearDay()
	}
	days += b.YearDay()
	
	return days
}

func date(s string) time.Time {
	d, _ := time.Parse("2006-01-02", s)
	return d
}
```
Visual Studio Tips - Solution Explorer Search
Tags: vstips, csharp
Published: 2019-03-31 00:12:51

---
title: Visual Studio Tips - Solution Explorer Search
published: true
tags: VSTips, csharp
canonical_url: https://hutchcodes.net/2019/03/visual-studio-solution-explorer-search/
---

Solution Explorer Search has been in Visual Studio for a while, but there are a few features that I think many developers overlook (myself included). Here are a few that you might have missed.

<!--more-->

By default, the search will search `Ctrl+;` both the file names and the contents. This is what we want most of the time, but it is possible to search just the file names.

![alt text](https://hutchcodes.net/img/2019/SolutionExplorerSearchNoContents.gif "Visual of disabling search within file contents.")

Some other filters you can apply to your search are Open Files `Ctrl+[,O` and Pending Changes `Ctrl+[,P`. These can be particularly useful when you’re working on a feature that requires changes across multiple files in different layers of your solution. In the gif below I show these filters being used via the UI.

![alt text](https://hutchcodes.net/img/2019/SolutionExplorerSearchFilters.gif "Visual of using search search filters.")
Download artifacts from gitlab
Tags: gitlab, artifacts
Published: 2019-03-28 22:33:26

---
title: Download artifacts from gitlab
published: true
description: what are the correct urls to get the download to artifacts working without 404
tags: #gitlab #artifacts
cover_image: https://thepracticaldev.s3.amazonaws.com/i/xtyr23cvh5jkqul5yiw7.jpg
---

debugging the [download function][gitlab_doc] from [gitlab][gitlab] for artifacts can be quite cumbersome as you have to create them by yourself and you have no easy autogenerated link you can simple copy and paste.

according the docs for getting the latest zip file of an artifact you have to use a link like the following:
```
https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/download?job=build
```

to get a single file out of the artifact you have to (in this case `yaml-convert.phar`) use a link like:
```
https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/raw/yaml-convert.phar?job=build
```

be careful you have to use the exact job name, first i had one stage `build` but two jobs for it `tag` and `master` so my job names were `build:master` and `build:tag` which resulted in a 404 if you use `https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/download?job=build`

i have not tried to use `build:master` as job name for the download url, i renamed my jobs in the `.gitlab-ci.yml` to `build-master` and changed the url to `https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/download?job=build-master` which worked without 404.

after a refactoring of the `.gitlab-ci.yml` file i ended up removing the 2nd job and handling everything in one build job to have nicer urls:

```
# zip file download
https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/download?job=build

# zip file download from tag
https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/2.0.0/download?job=build

# single file download
https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/raw/yaml-convert.phar?job=build
```


[gitlab]: https://gitlab.com/
[gitlab_doc]: https://docs.gitlab.com/ce/user/project/pipelines/job_artifacts.html#downloading-the-latest-artifacts

links:
- cover image by gratisography https://www.pexels.com/photo/person-looking-searching-clean-2371/
Sharing on Dev.to
Tags: beginners, linux, learning, devops
Published: 2019-03-28 21:27:55

---
title: Sharing on Dev.to
published: true
description: Empowering others through empathy
tags: #beginners #linux #learning #devops
---

I've been a part of the Dev.to community for a few months now and have only lurked. Frankly, I've been scared to put my thoughts out for people to read and evaluate. Fear. I have, for the better part of 5 years, lived in fear that what I know has little value. I've lived in fear that I'm going to be thought of as being inferior or dumb.

Recently I started pushing myself to refresh skills that I haven't used in years and learn new ones. A lot of learning on Linux Academy - Linux and AWS. Within my job I've been able to really connect with the platform engineering team who manage our AWS/Linux services. This engagement has helped me regain my confidence, not only in what I already know but asking questions about what I don't know.

I really love the openness and ease of access here on Dev.to. People who are experts in a domain and they are so willing to share what they know. People like myself who are coming back into development or operations can get help without worrying about being degraded for what we don't know.

A quote from one of my favorite people ‘Kindness expressed to someone in a moment of vulnerability can be one of the greatest forces in the world' ~ David Blake, Degreed. 

It takes vulnerability to ask others for help, when you take the time to help, you are changing someone's life. It may be a small change but you are empowering them and helping them be even more than they were previously.

Thank you, Dev.to, for allowing this old lady the chance to be a part of this amazing community and regrow my skills.
Frontend devs: how interested are you in backend APIs and services?
Tags: discuss, beginners, webdev, react
Published: 2019-03-28 19:12:59

---
title: Frontend devs: how interested are you in backend APIs and services?
published: true
description: Any interest in Docker/Kubernetes/Service Mesh technologies from frontend devs?
tags: discuss, beginners, webdev, react
cover_image: https://thepracticaldev.s3.amazonaws.com/i/tk9gfmkxgrc4gvlblguf.jpeg
---

Only yesterday I noticed that [ReactRally CFP](https://t.co/0nagLeZTTl) is open and that it closes in a couple of days.

{% twitter 1102939006042464256 %}

I've spoken at conferences before, done workshops, but it was never on React or frontend development. In my day job, I am mostly working with backends with things like Docker, Kubernetes, Golang, service meshes, serverless functions, etc. 

However, in my free time I've done Javascript, React, and I like it. Coming from the backend world, I always wondered how much interested is there from the frontend devs to learn about Docker, Kubernetes, and service meshes? 

Would a conference session that gives you a basic overview of these technologies interest people, especially if it demonstrates with practical examples of how to use these things? For example, a React app with a couple of backend APIs, perhaps GraphQL and a database? What do you think? 

This is the short abstract I came up with: 


*Have you heard about Docker, Kubernetes, and Service Meshes? Ever wondered what the fuss is all about and how can you use it as a React developer? This session will be a quick and practical tour of Docker, Kubernetes, and service meshes that will give you, and hopefully spark, ideas on how to use these technologies as a React developer.*

What do you think? Only a couple of days left ... ⏰
Design Ideas: 16 Week Writing Streak Badge
Tags: discuss, meta
Published: 2019-03-28 21:00:01

---
title: Design Ideas: 16 Week Writing Streak Badge
published: true
description: 
tags: discuss, meta
cover_image: https://thepracticaldev.s3.amazonaws.com/i/zhxtp7c5bdaj3n4tjcja.png
---

Hey all! As some of you may know, we have two writing streak badges, one for 4 weeks and one for 8 weeks.  


We need to create the next one for 16 weeks. Continuing with the binary "theme" gets tricky as we increase in number size because the badges can't be too wide. So we're going in a new direction, but didn't have any good ideas, so we thought the community might have good thoughts for a new writing streak badge. Any one have any ideas?
RxJS finalize operator to execute logic on Observable termination
Tags: rxjs, angular, beginners, crosspost
Published: 2019-03-28 20:41:21

---
title: "RxJS finalize operator to execute logic on Observable termination"
published: true
cover_image: https://juristr.com/blog/assets/imgs/rxjs-finalize.jpg
description: An RxJS operator for executing logic when the Observable terminates
tags: rxjs, angular, beginner, crosspost
canonical_url: https://egghead.io/lessons/angular-execute-code-when-the-rxjs-observable-terminates-with-the-finalize-operator
---

**In this article we're going to have a look at the RxJS `finalize` operator. To have a practical use case, let's take a look at disabling/enabling a form submit button during an HTTP request.**


## Disabling/enabling a button during an Angular HTTP request

Let's take a look at an RxJS `Observable` subscription:

```typescript
this.someService.fetchDataFromApi()
  .subscribe(
    result => {
      // success
    },
    err => {
      // some error happened
    }
  )
```

Assume this call is triggered by a button click on our form. Many people still double-click on those buttons and we definitely want to prevent 2 calls being sent to our backend API. There are different ways to avoid that of course, but for the purpose of this example, let's go the route of disabling the button once it has been clicked, and re-enable it when the http call terminates.

```typescript
this.isLoading = true;
this.someService.fetchDataFromApi()
  .subscribe(
    result => {
      // success
      this.isLoading = false;
    },
    err => {
      // some error happened
      this.isLoading = false;
    }
  )
```

Whenever `isLoading` is set, we disable our button on the form. Now as in the example before, the `isLoading = false` instruction is duplicated, because we want to re-enable the button in both, success and error cases.

[Read more &raquo;](https://juristr.com/blog/2019/04/rxjs-finalize-operator/?utm_source=devto&utm_medium=crosspost)


---

## TL;DR: Here's the corresponding Egghead lesson

Check out [my corresponding Egghead video](https://egghead.io/lessons/angular-execute-code-when-the-rxjs-observable-terminates-with-the-finalize-operator)
How do you share your knowledge?
Tags: discuss, learning
Published: 2019-03-28 20:21:27

---
title: How do you share your knowledge?
published: true
description: 
tags: discuss,learning
---
I learn a lot from my teammates. From architecture design and code conventions to optimizations, testing and any other dev related topic you can think about.

Yet, sometimes I'm not always sure about a decision we made or I just want to see how other people dealt with a similar problem. So I start looking online for other people's opinions. I go on Stack Overflow, read some blog posts or watch some videos on YouTube trying to search for anything that might help but don't always find any.

I tried posting questions on Slack, Spectrum and other dev related communities. But very often there are so many questions posted there that questions get lost in the crowd pretty fast.

Sometimes I wish I could just sit down with someone and discuss things face to face.

How do you share knowledge with devs outside your company?
Close the Circle
Tags: productivity, motivation
Published: 2019-03-28 19:35:48

---
title: Close the Circle
published: true
cover_image: https://i0.wp.com/leruplund.dk/wp-content/uploads/2019/03/DSC1458-devto.jpg?w=1095
tags: productivity,motivation
canonical_url: http://leruplund.dk/2019/03/28/close-the-circle/
---

Some years back my wife introduced a new principle called “Close the Circle” into our house hold. It was something she had read about somewhere on the www (unfortunately, neither of us can find the original reference).

Closing the Circle means that you finish your job before moving on to the next.

Our interpretation is that you always clean up after you have done something. Some examples: You do not leave the dishes for the next day, you make your bed in the morning, and you clean the bit after going horse back riding (free tip: Always mention horses in your blog). ![🐎](https://s.w.org/images/core/emoji/11/72x72/1f40e.png)

Needless to say, we keep a pretty tidy home.

Of course there will always be jobs that cannot be finished in a short period of time.  They may take weeks or months to complete.  But you  may be able to break the job into smaller task where each can be completed in a shorter time.  For example, the last couple of months I have been putting up new fencing for our horses (there, I did it again) during the weekends.  Each Saturday morning I set new goals for the weekend and when the weekend closing I set my tools aside and made sure everything looked tidy.

I like to apply the Closing the Circle principle to coding as well.

A task (on your Kanban board or whatever) should never be larger than what you can complete before moving on to the next task. That is, before moving on you  
should have made a push to your remote repo and maybe even a pull request with the coded solution for the task including passing unit tests and updated documentation.

I am not saying this is what I always do. I am just saying that is what I strive to do and I think it is something that will keep your code tidy and give you a better work life balance.
Hello World in Coldfusion
Tags: coldfusion, lucee, commandbox, beginners
Published: 2019-03-28 18:58:17

Now that you've read my [Why Coldfusion?](https://dev.to/mikeborn/why-cf-3jal) post (you HAVE, right?), let's do a simple Hello World just to try some sample CF code.

## Installing Commandbox

Installing Coldfusion is as easy as downloading [Commandbox](https://www.ortussolutions.com/products/commandbox#download) and dropping it in a folder. On Linux, you'll want to drop it in a folder somewhere in your `$PATH` - perhaps `/usr/bin`? Otherwise (Windows or Mac) just drop it in a folder and drag the box executable to your taskbar to give yourself a nice quick launcher icon.

## Hello World

Let's do a quick Hello World so we know what we're up against.

1. Create a `hello.cfm` file. Somewhere. (_Anywhere!_)
2. Edit that `hello.cfm`.
3. Type in the following code:

```html
<cfscript>
    writeOutput( 'Hello, World!' );
</cfscript>
```

Ok, so this is the gist of a modern Coldfusion markup (`.cfm`) file. This file is doing two things:

1. Using `<cfscript></cfscript>` to denote the Coldfusion script syntax

This is just CF's version of PHP's `<?php ... ?>` delimiters. Now, there is a fully-supported, fully-capable tag syntax, but I prefer the script syntax for pretty much everything but templating. I think on the whole, modern CF apps are better off using CFscript syntax - but that's just my opinion. Oh, and you only need this `<cfscript>` tag in `.cfm` files - anything in a component (a `.cfc` file)can launch right into script syntax.

1. Using the `writeOutput()` function to print a string value to the buffer

This is hopefully straightforward - we're writing output to the buffer. In this example, we're going to use CommandBox to run the file, so the output will be returned inline to the CommandBox CLI.

## Executing a CFM File in CommandBox

Here's how we run our `hello.cfm` file using CommandBox. First, you'll need to start Commandbox by clicking on the launcher or typing `box` in your Mac/Linux terminal. Once in CommandBox, we'll use the `execute` command to run the script and return the output:

```bash
execute hello.cfm
```

Boom! It's that easy to try Coldfusion*. There's no compiling, no building, and no downloading hundreds (or thousands) of dependencies - just run the script.

If you want to see exactly what that looks like, here you go.

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

_*Please note that this is not a production-ready format - for that you'd want to run `server start engine=lucee@5.2` to install and start the open-source Lucee server. Let me know if you'd like to see a tutorial about that as well - I'm happy to help you get started!_
Tuples and Lists in python
Tags: pythonlist, tuple, python3
Published: 2019-03-28 18:38:28

---
title: Tuples and Lists in python
published: true
description: 
tags: #python#list #tuple #python3
---

https://medium.com/@abhi11210646/tuples-and-lists-in-python-7bb8c9e26cb6
If You're A #CodeNewbie Learning #JavaScript This Is What You Should Learn Today! 
Tags: javascript, json, codenewbie, womenwhocode
Published: 2019-03-28 18:09:36

---
title: If You're A #CodeNewbie Learning #JavaScript This Is What You Should Learn Today! 
published: true
description: Start with the JavaScript Objects if you want to learn JavaScript.
tags: JavaScript, JSON, #CodeNewbie, #WomenWhoCode
---

Beginners who want to learn JavaScript find it hard to get started. Some would dive into the immediate basics while others may choose to do start with more technical stuff. However, today I am sharing with you folks a piece of handy advice. 

So, if you're a #CodeNewbie learning #JavaScript this piece is definitely for you.

This is what you should start learning today:

- 🔘 What are JS Objects?
- 🔘 How to access JS Objects?
- 🔘 Convert JS Objects to JSON
- 🔘 Convert JSON to JS Objects

To learn all of that, I made a quick video tutorial featuring you can convert JavaScript Objects to JSON and vice versa. While watching this video you'll learn the concepts about `console.log()` and how to access any member of JS Objects.

📺 You can watch my #GirlDevMinute Video tutorial here ⬇️


{% youtube nG5TXyyaeDs %}


*ICYMI I started my edutaining series called #GirlDevMinute where I'll share what I know about development and program management. Feel free to [tweet](https://twitter.com/hashtag/GirlDevMinute) about it and say hi (and follow) me [@MaedahBatool](https://twitter.com/MaedahBatool) on Twitter.*
Javascript Conditional Properties
Tags: javascript
Published: 2019-03-28 17:42:21

---
title: Javascript Conditional Properties
published: true
description: mind blown today after seeing a neat spread usage
tags: javascript
---

Did you know you can add properties conditionally to an object with spread?

so instead of 

```javascript
function getUser(banned) {
  const userStatus = {banned, banReason: 'Wizard'};
  // only combine the user status if the user is banned
  const user = { name: 'Micah' };
  if(userStatus.banned) {
    Object.assign(user, userStatus);
  }
   return user;
}


console.log(getUser(true));
console.log(getUser(false));

```

you can do

```javascript
function getUser(banned) {
  const userStatus = {banned, banReason: 'Wizard'};
  // only combine the user status if the user is banned
   return {
    name: 'Micah',
    ...userStatus.banned && userStatus,
  }
}


console.log(getUser(true));
console.log(getUser(false));

```


## Outputs
```javascript
{ name: 'Micah', banned: true, banReason: 'Wizard' }
{ name: 'Micah' }
```

Neat!
Pug vs EJS?
Tags: discuss, help, webdev, javascript
Published: 2019-03-28 17:41:37

---
title: Pug vs EJS?
published: true
description: 
tags: #discuss, #help, #webdev, #javascript
---

I have to decide whether to go with __PUG or EJS__ for a node web app. 

I highly appreciate if you can suggest one over another explaining why you think so.

__Appreciate all help!__
How can I combine tags when searching on Dev.to?
Tags: help, devto
Published: 2019-03-28 16:29:46

---
title: How can I combine tags when searching on Dev.to?
published: true
tags: help, dev.to
---

The search doesn't really work the way I want it to.

Let me demonstrate this with the screenshot.

![Combining tags on Dev.to when searching](https://thepracticaldev.s3.amazonaws.com/i/db2zruiyjzlr18favqe6.png)

I have also tried to something like this: dev.to/t/haskell/challenge

You can guess what happened.
The Mega CSS3 Cheatsheet
Tags: css, css3, cheatsheet, webdev
Published: 2019-03-28 16:03:31

---
title: The Mega CSS3 Cheatsheet
published: True
description: 
tags: #css, #css3, #cheatsheet, #webdev
---
You can download The Mega CSS3 Cheatsheet [here](https://www.dropbox.com/s/lxf803pftynmxz4/CSS3%20Cheatsheet.pdf?dl=0).

Don't forget to subscribe to my [newsletter](http://eepurl.com/gbBYGv)