teleren/devto huggingface dataset:
What’s your alternative solution? Challenge #10
Tags: challenges, discuss, javascript, codenewbie
Published: 2020-04-03 22:52:48

# About this series

This is series of daily JavaScript coding challenges... for both beginners and advanced users.

Each day I’m gone present you a very simple coding challenge, together with the solution. The solution is intentionally written in a didactic way using classic JavaScript syntax in order to be accessible to coders of all levels.

Solutions are designed with increase level of complexity.

## Today’s coding challenge

```
Calculate the sum of numbers in an array of numbers.

```

(scroll down for solution)

## Code newbies

If you are a code newbie, try to work on the solution on your own. After you finish it, or if you need help, please consult the provided solution.

## Advanced developers

Please provide alternative solutions in the comments below. 

You can solve it using functional concepts or solve it using a different algorithm... or just solve it using the latest ES innovations.

By providing a new solution you can show code newbies different ways to solve the same problem.

## Solution

```javascript
// Solution for challenge10

function sumArray(ar)
{
    var sum = 0;
    
    for(var i = 0; i < ar.length; i++)
    {
        sum += ar[i];
    }
    
    return sum;
}

var ar = [2, 3, -1, 5, 7, 9, 10, 15, 95];
var sum = sumArray(ar);
println(sum);

```


To quickly verify this solution, copy the code above in this coding [editor](https://codeguppy.com/code.html) and press "Run".

> Note: The solution was originally designed for [codeguppy.com](https://codeguppy.com) environment, and therefore is making use of `println`. This is the almost equivalent of `console.log` in other environments. Please feel free to use your preferred coding playground / environment when implementing your solution.
What’s your alternative solution? Challenge #9
Tags: challenges, discuss, javascript, codenewbie
Published: 2020-04-03 22:52:11

# About this series

This is series of daily JavaScript coding challenges... for both beginners and advanced users.

Each day I’m gone present you a very simple coding challenge, together with the solution. The solution is intentionally written in a didactic way using classic JavaScript syntax in order to be accessible to coders of all levels.

Solutions are designed with increase level of complexity.

## Today’s coding challenge

```
Create a function that will convert from Fahrenheit to Celsius.

```

(scroll down for solution)

## Code newbies

If you are a code newbie, try to work on the solution on your own. After you finish it, or if you need help, please consult the provided solution.

## Advanced developers

Please provide alternative solutions in the comments below. 

You can solve it using functional concepts or solve it using a different algorithm... or just solve it using the latest ES innovations.

By providing a new solution you can show code newbies different ways to solve the same problem.

## Solution

```javascript
// Solution for challenge09

function fahrenheitToCelsius(n)
{
    return (n - 32) / 1.8;
}

var r = fahrenheitToCelsius(68);
println(r);

```


To quickly verify this solution, copy the code above in this coding [editor](https://codeguppy.com/code.html) and press "Run".

> Note: The solution was originally designed for [codeguppy.com](https://codeguppy.com) environment, and therefore is making use of `println`. This is the almost equivalent of `console.log` in other environments. Please feel free to use your preferred coding playground / environment when implementing your solution.
DevOps in March: Everything #devs need to be aware of. 
Tags: devopsnews, tech, testing, devlive
Published: 2020-04-03 22:51:05

As the world went into lockdown, things have gone real tough for the devops engineers out there. 

Excessive loads on data networks led companies to take desperate measures. 

Rightly so, people seemed to be glued with their screens. Not that they're not glued otherwise. 

The fact that meetings they stopped using their phones in are not happening, however, has added the extra dimension of loads. 

This led Netflix to announce that they will be trying and work with their delivery teams to lower the usage by 25% without affecting the quality. Read more: https://yourstory.com/2020/03/coronavirus-youtube-netflix-facebook-bit-rate-network-congestion

Amid this chaos, teams yet to adopt DevOps have sure understood how wrong they have been. It's important for everyone to understand the impact of this delivery methodology. 

Popular for its usage by developers building AI applications, Azure too went for prioritized resource allocation. Considering the gravity of the situation on a global level, it's hard not to appreciate this. 

Having said that, creating a great set of tools and frameworks for AI developers has always been a priority for Azure and other cloud computing moguls. Read more: https://blog.unboxinnovations.com/python-for-artificial-intellingence-ml/

In other news, AWS has finally launched a new low-cost HDD storage option to Amazon FSx to Windows FileServer. Now, that's some news to jump on. Whether you need to manage a content management system or database at a departmental store, this HDD option will be ideal for all. Excited to see how things work out with this one. 

That's all for this week's roundup. Be sure to check out next month's roundup. 

Feel free to hit me up with any suggestions that you might have, or just leave a good-ol' comment down.
Day 109 : Place to Rest
Tags: hiphop, code, coding, lifelongdev
Published: 2020-04-03 22:15:47

_liner notes_:
- Professional : Didn't really get to do too much. Had a couple of meetings. I can tell I'm getting sick. My manager was super supportive that I take care of myself. Shouts to my whole team. Awesome people. I think I got my work to a nice place so I can rest.

- Personal : Last night, I was able to set up hosting for both the track submission and admin parts of my personal project.

![Looking up at the night sky with a lot of stars in Arches National Park, Utah, USA](https://dev-to-uploads.s3.amazonaws.com/i/5859p89evnv276fw9uhn.png)

Going to keep resting and get some stuff done for the radio show tomorrow. Good thing I got a lot done during the week. Want to get one more thing working on the admin section and start reaching out to artists to submit tracks.

Have a great night and weekend!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube MqbDrE_t888 %}
Trim Videos Instantly
Tags: todayilearned, productivity, bash, watercooler
Published: 2020-04-04 00:42:54

---
title: Trim Videos Instantly
published: true
description: How to save hours by trimming videos instantly without reencoding or rerendering in video editing software.
tags: todayilearned,productivity,bash,watercooler
canonical_url: https://bernd.dev/2020/04/trim-videos-instantly/
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/oh5miz0zy7mw9p4k46cx.png
series: Video Content Creation
---

Is your video too long for upload to Twitter or Instagram? Or do you want to export just a specific clip? Using video editors to trim videos requires reencoding the entire video which takes a long time. Instead I will show you how to **instantly** trim your videos and even maintain embedded subtitle tracks.

### Background
A few days ago I created a post on easily [adding subtitles to your videos](https://bernd.dev/2020/04/adding-subtitles/). Today I wanted to verify that Twitter correctly shows these subtitles, but I discovered that my video was too long. Having played with **FFmpeg** I suspected that there may be a more efficient way for trimming videos than using a video editor. Be prepared to have your mind blown! 🤯

## Requirements

### FFmpeg

You will need the open-source [FFmpeg](https://www.ffmpeg.org/) tool.
> FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.

Please follow the [installation instructions here](http://ffmpeg.org/download.html).
On Mac, simply use *Homebrew* with `brew install ffmpeg`

## Instantly trim videos

The following command reads the source video and copies all streams contained within (video, audio, subtitles) to the output. The various time parameters ensure only a specific part of the original video is written to the output. **The video and audio streams are not reencoded.** The time required for reencoding would directly depend on the duration of the video, however we are simply copying parts of the video.  For this reason **the following operation is near instant**. A huge time saving over workflows involving video editors.

{% gist https://gist.github.com/berndverst/6308d9427e5df935dbe331c135e82502 file=trimvideoinstantly.sh %}
Built a community sharing platform in my isolation to help with covid19
Tags: covid19, elixir, phoenix, tailwindcss
Published: 2020-04-03 21:32:18

---
title: Built a community sharing platform in my isolation to help with covid19
published: true
description: During my 14 day self isolation I decided to put it to good use and build community sharing platform.
tags: covid19, elixir, phoenix, tailwindcss
---

I was forced into isolation after returning to Melbourne from the US. Luckily, I had a friend in my apartment building to provide me with groceries - but I wondered how the less fortunate would be handling it.

So during my 14 days stuck in my apartment I built this web app to allow people to signal if they need help or offer to provide help. Hopefully it helps someone, somewhere! A friend did the landing page, and another friend is trying to get it out there. Anyway, check it out and register your ability to help your local community.

www.crisisheroes.com

Tech:
[Elixir (Phoenix)](https://www.phoenixframework.org/)
[Postgres](https://www.postgresql.org/)
[Algolia](https://www.algolia.com/)
[Tailwind CSS](https://tailwindcss.com/)
[Alpine JS](https://github.com/alpinejs/alpine)

Deployed to [Google Cloud Platform - App Engine Flex](https://cloud.google.com/appengine/docs/flexible)
Twiliohackathon Project - ConnectShop
Tags: twiliohackathon, reactnative, node, mongodb
Published: 2020-04-03 21:26:16

## What I want to build

Hey, this is my first blog for Twiliohackathon, and our first milestone is brainstorming an idea, UI/UX designs and codebase structure.

Before talking about the idea, let me share you about me and my team partner Uphaar, we both live in same city and due to lockdown we're facing issues like not access to the market or nearby general store because most of the time they're closed and we're not allowed to go outside unless necessary. 

To tackle this, we thought to build an application which can connect consumers to shopkeepers so they can track which nearby shops are opened and contact them and also tells consumer is there rush in the shop or not so the user can go out accordingly.

We can integrate Twilio in the application in the following ways:
- Adding OTP verification for users.
- Push SMS notification for the consumer whether the shop is opened.

We decided to keep the tech stack:
- React Native
- NodeJS
- MongoDB

### Designs
For now, I'm building the designs and here goes the <a href="https://www.figma.com/file/9dG1Yv7Y2StuCsPN58zWVr/ConnectShop?node-id=0%3A1">link</a>.

### CodeBase
We will setup Github repository and build proper database designs for same.

## Let me know your opinion on our idea.
Thankyou! <3
Formated clock in JavaScript
Tags: todayilearned, javascript
Published: 2020-04-03 21:21:11

How to get a formatted clock display easily in JavaScript with Intl.DateTimeFormat.

```js
const date = new Date();
const time = new Intl.DateTimeFormat('default', {
  hour: 'numeric',
  minute: 'numeric',
}).format(date)
```

Bonus, it will be formatted according to the users' local settings. For me, time will be '23:00', while those on 12-hour clock will see '11:00 PM'.

No need to deal with string splitting, or concatenation of values.
hey all!
Published: 2020-04-03 21:06:33

Here's some background on me:

I was born and raised in San Jose, CA; In fact, I live not too far from netflix, roku, splunk, altify, and bluejeans. By the time your reading this post I have already graduated culinary school and yes I did go to culinary school and I had some great times working in a few of the best kitchens in the Bay Area. 

Im learning to code because I wanna become a web developer!
Stop use geoip for language detection
Tags: geoip, locale, development, feedback
Published: 2020-04-03 20:54:25

---
title: Stop use geoip for language detection
published: true
description: many sites use geoip to detect the language their page should be shown in. this is simply wrong.
tags: #geoip, #locale, #development, #feedback
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/6kl1oleboaj9ldjvk9pz.jpg
---
today i wrote a ticket at gog.com but it is also a general problem in webdevelopment. many sites use geoip to detect the language their page should be shown in. this is simply wrong.

to make it simple, i just pasted the feedback text i posted them here:
---

i live in austria, in austria we talk german but for software i prefer english at all costs. all my devices and software are configured to use english. my operation system, my steam client, my games and also my browser.

i know that steam is bad and you are the good ones but you give me a really bad experience if i visit your website. if i am not logged in (and this is the default because i always clear cookies), the site in german. i don't like german in this context. i hate it. 
it feels as if i tell you what i want (with my browser correctly setup to send your site an english locale request) and you simply don't listen. steam is also not save from that, they sometimes play the wrong game trailer - as soon as i read german subtitles or someone talks german in a gametrailer i close the store page - not interested any more. 

please stop using geoip and listen to the browsers locales. it is a very bad move made by some websites but it's simply wrong. the users operation system is most of the time configured in the language which the user prefers and so all software also gets installed in this language including the browser. so simply respect that.
imagine a user is from russia, lives in austria and only speaks russian and english, the person could be confused with a german webpage. even worse would be if i travel to japan and you would show me your webpage in japanese. maybe i wouldn't even be able to find the language switch button.

so again: please stop using geoip for language detection, use browser locales and make me smile and have a good experience when i visit your website.

thanks for reading

regards
j.

links:
- cover image by stevepb https://pixabay.com/photos/confused-muddled-illogical-880735/
From A mechatronics engineer to a software developer 
Tags: laravel, flutter
Published: 2020-04-03 20:24:42

this is my first post here,I joined dev.to after I quit all my social media accounts.

I just started my decision today to take a pivot in my career, after I found that my passion is to write code.

I found myself more comfortable when I think in design a software architecture, or a database schema , or just writing a code

Now I am learning flutter, and I am very interested in this new technology.

I have some successful previous experience with software like working with laravel and its MVC architecture, and fronted web development
3D Printed Face Shields
Tags: 3dprinting
Published: 2020-04-03 20:20:20

Hi All,

I really wish my first post wasn't about this sort of thing, but here goes.

I sincerely hope you DO NOT need this information, but just case, I am sharing our experience with crowd sourcing COVID-19 Face Shields. The link below has the .stl files and parts we used. Tidbits like using the 3D printers from local schools to scale up production can help a lot.

Be well!
Dan

https://github.com/bha-github-organization/trip-d-print#3d-printed-face-shields
Is React a dev or prod npm dependency?
Tags: discuss, react, npm, javascript
Published: 2020-04-03 20:20:03

---
title: Is React a dev or prod npm dependency?
published: true
description: Should react be in dependencies or devDependencies inside package.json?
tags: discuss, react, npm, javascript 
---

**Do you add `react` in your dependencies or devDependencies inside package.json and explain why you choose that?**

#### My thoughts

##### dependencies

It can be here since its part of the application which gets shipped. Or you can say its used by the application/library at runtime.

##### devDependencies

It is still part of the dependency but its needed during release/compile time but for consumers they don't need it since bundled code already has that in it.
Tracking Migraines with SMS
Tags: twiliohackathon, python, api
Published: 2020-04-03 20:00:31

---
title: Tracking Migraines with SMS
published: True
description: My submission to the Twilio x DEV Hackathon!
series: Tracking Migraines with SMS
tags: twiliohackathon, python, api
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/2bck9yiv5wg8u4wa3821.png
---

[Comment]: #(https://www.allpeoplequilt.com/sites/allpeoplequilt.com/files/uploads/cutting_setting_squares_and_trianges.pdf)

Happy Friday! I am excited to try something new and begin working with Twilio's APIs. 

## Category - Engaging Engagements and Interesting Integrations 

I am focusing on two categories during this hackathon: Engaging Engagements and Interesting Integrations. 

**Engaging Engagements** looks at developing applications that a company could implement to better engage with their customers or to manage their business and **Interesting Integrations** focus on the integration of Twilio with at least one other API.

## Overview 

During this hackathon, I am looking for a simple method to collect data using SMS and Google Sheets. Every month I spend time logging migraines for the doctors office but don't remember the questions she commonly asks, or the details she found important from my last appointment. This application is being created as a way to log migraines in Google Sheets by quickly filling out the details of a survey sent through SMS. The user can then print off the sheet that has been populated and bring it with them to their next doctor's appointment.

### Commonly Asked Questions for Migraines 

- In a scale of 1-10, how would you rate your migraine?
- Where is your migraine located today?
- How long did your migraine last (in hours)?
- What medication did you take to treat the migraine?
- Has anything changed? Is anything out of the ordinary? 

### Development Stack 

I am working with the Twilio API to develop a Python Flask app that generates a survey for migraines and saves the data in a Google Sheet. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/la7zchv71vf9rdwe5em7.png)

I look forward to posting each week my progress and learnings as I tackle this problem. Stay tuned for next weeks post as I begin to utilize Googles API to read and write data to a sheet!  

## Additional Resources

### Reference Links 
[Twilio's Rest API](https://www.twilio.com/docs/usage/api)
Serverless Eventing: A Series
Tags: cloudnative, kubernetes, serverlesseventing
Published: 2020-05-29 22:52:54

---
title: Serverless Eventing: A Series
published: true
series: Serverless Eventing
date: 2020-04-03 19:50:20 UTC
tags: CloudNative,Kubernetes,ServerlessEventing
canonical_url: https://thejaysmith.com/titles/serverlessjay/severless-eventing/serverless-eventing-a-series/
---

\*\*"I want a data-driven organization!"\*\* We have all heard this in recent years haven't we? Maybe it was at an All-Hands, maybe your manager, probably at a mixer in Silicon Valley somewhere. My healthcare provider told me about their new "data-driven matching".

[Continue reading - Serverless Eventing: Cloud Native Messaging with NATS Streaming Server](https://thejaysmith.com/titles/serverlessjay/severless-eventing/serverless-eventing-a-series/) appeared first on [Jason (Jay) Smith](https://thejaysmith.com).
Automate your Github Pull Requests to Changelog Generation Flow via PRCLbot
Published: 2020-04-03 19:11:29

## Problem
When multiple people are working on a repo in Github, the chance that they are aware of all changes becomes slimmer. With time, changelog files get bigger and they might get less human-readable and less-searchable. The well-maintained changelog also has valuable data that can be used to debug issues effectively, gain insights and to keep track of the team's productivity and metrics.

## Solution
To solve this, I built PRCLbot which is an easy-to-setup github app to automate changelog generation flow from merged pull requests, keep the team connected with new changes and help you gain insights from it.

## Key Features
- Intuitive dashboard to keep track of changelog history, release versions, etc.
- Advanced filtering options to extract the desired changelog.
- Derive project insights and metrics from your changelog.
- Keep different versions of changelog depending on branches (production, development, QA, Staging, etc).
- Create public links for changelog which can be shared with everyone. Keep your users in the loop with the team's awesome progress.


For more details:
Youtube walkthrough: https://www.youtube.com/watch?v=nm2rghSMW1o
Github Marketplace App Link: https://github.com/marketplace/prclbot-automate-your-pull-requests-to-changelogs-generation-flow
Docs: https://docs.prclbot.com/

Feel free to check it out. Would love to hear your thoughts/insights/feedback on it.
Thanks! :D
Mocking private static final log
Tags: java, testing
Published: 2020-04-03 18:25:46

Tests for logging is something I have tried to avoid in the past. Today I had to write some code which exports [TestRail](https://www.gurock.com/testrail) results to [splunk](https://www.splunk.com/) and I was determined to test the output.

Instead of searching for how to do this using jmockit or mockito (since this hasn't worked for me in the past) I decided to try using reflection myself. I searched for "java reflection change private static field" and came across [this](https://stackoverflow.com/questions/3301635/change-private-static-final-field-using-java-reflection) post on stackoverflow. The post shows a way to change the value of a public static final field. There are some caveats but in the case of `Logger` it works out.

Combining this information with mockito I was able to mock the logger for a class and test logging output. First the test setup (junit 4.13):

```
@RunWith(MockitoJunitRunner.class)
public class SplunkReporterMethods {
  @Mock private Logger log;
  private SplunkReporter reporter;

  @Test
  public void report() {
    reporter.report(new Car());
    then(log).should().info("{\"name\":\"car\",\"speed\":4}");
  }
}
```

To setup the SplunkReporter class with a different logger the mock needs to be injected into the private static final field. This can be done in an `@Before` method.

```
@Before
void setup() {
  //allow log field to be changed
  Field field = SplunkReporter.class.getDeclaredField("log");
  field.setAccessible(true);
  
  //remove final modifier
  Field modifiersField = Field.class.getDeclaredField("modifiers");
  modifiersField.setAccessible(true);
  modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);

  //set to mock object
  field.set(null, log);
  reporter = new SplunkReporter();
}
```

First, the setup method makes `log` accessible but that is not enough. The modifiers on the field need to be changed so `final` is removed. The Field class does not have a setter for the modifiers field and so `modifiers` needs to be set in `field` using reflection. Finally the static field is set to the mock object.