teleren/devto huggingface dataset:
Convert seconds to day, hour, minutes and seconds in Python
Tags: python, beginners
Published: 2020-02-13 13:24:21

In Python, the <a href="https://docs.python.org/3.8/library/time.html">time</a> module provides many time related functions. 

You can use the time module to get the <a href="https://pythonbasics.org/time-and-date/">time and date</a> and other things. You can use the function *time.time()* to get get the current time

```python
import time

time.time()
```

But if you output it with the print function, it doesn't show in human readable format. Instead you get a number called the <a href="https://en.wikipedia.org/wiki/Unix_time">epoch</a> or Unix time. 

<img src="https://duckduckgo.com/i/aa977c6c.jpg" alt="unix time">

This is a system for describing a point in time that is used by computers. So how do you convert it to time?

Before playing with time module, you should know the <a href="https://pythonbasics.org">basics of Python</a>.

## ctime

One way to solve this is by calling the function ctime(). The ctime() function converts a time (seconds since the <a href="https://en.wikipedia.org/wiki/Unix_time">epoch</a>) to a string of a form: 'Sun Jun 20 23:21:05 1993'.

```python
import time

now = time.ctime(int(time.time()))
print(now)
```

The program shows the current date and time:

```
Thu Feb 13 14:00:03 2020
```

## strftime

To get just the time you can use the function strftime(). This outputs hours "%H" and minutes "%M". To get the seconds you can use "%S". Try the code:

```python
import time

now = time.strftime("%H:%M", time.localtime(time.time()))
print(now)
```

## alternative

To convert the time manually to hours, seconds and minutes you can do the math manually. Then use <a href="https://www.python.org/dev/peps/pep-0498/">f-strings</a> to output 2 digits for every variable:

```python
import time

time = time.time()
time = time % (24 * 3600)
hour = round(time // 3600)
time %= 3600
minutes = round(time // 60)
time %= 60
seconds = round(time)

print(f"{hour:02d}:{minutes:02d}:{seconds:02d}")
```

This returns the nicely formatted time:

```
$ python example.py
13:06:29
```


**Related links:**
* <a href="https://docs.python.org/3.8/library/time.html">Time module for Python 3</a>
* <a href="https://pythonbasics.org">Learn Python</a>
Contentful certification exam review
Tags: contentful
Published: 2020-02-13 13:23:49

---
title: Contentful certification exam review
published: true
description: 
tags: Contentful
---

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

I recently undertook the the Contentful certification exam (managed to pass on my second attempt 😂).

The exam is multiple choice and really does test your knowledge of Contentful.

If you're interested in taking the exam read through the "Contentful certification study guide" watch all the videos and the slides... 

I found after my first attempt that I needed to brush up on my knowledge of the different API's and SDK's.

https://public.learningcenter.contentful.com/catalog

The exam costs $250.
Learning about sapui5 ? First post ! Morning guys!
Tags: sapui5, sap, javascript, tutorial
Published: 2020-02-13 13:03:55

Nice meeting you guys ! I already have two days here, and its incredible awasome, now coming back to the title, So far on my three years of experience mostly JS, and C# for Programming only (obviously if i add JS that means i have worked with Web development).


Well so far the road has been incredible, and now i am working with SAPUI5, the issue here, is that i noticed there's two ways to build apps or proyects with it.

The XML way, and the JS way,  again come to issue. The whole documentation is written or dedicated to the XML way to build, is there any other place you guys might now about where i could learn the JS way to build it?  I am already praciting and learning a lot, but it would be nice to follow on point what i am doing.





if(true){Say('I love you' + ';)');



Cheers !
Access Azure SQL Database through Private Link
Tags: azure, privatelink, azuresqldatabase
Published: 2020-02-13 13:03:49

#The issue

Recently one of our teams has changed location. They moved from one cozy place with a dedicated IP to a corporate building with an IP range and port restriction.

The issue is: our development environment integrates an Azure SQL Database, using (among other thing) the firewall to restrict access.

#The attempt

We tried without success to use [Azure Relay Bridge](https://github.com/Azure/azure-relay-bridge) though a dedicated VM following [this article](https://github.com/AdamPaternostro/Azure-Relay-Connect-To-SQL-PaaS-Without-Firewall-Rule).

#The solution

We finally turned to VPN P2S solution, using Azure Gateway, a VNet and Azure Private Link. 

The idea is simple: making the database accessible from the VNet through a private IP.

But, using the IP address to connect instead of the FQDN, raises another issue. An error "The target principal name is incorrect" happened during connection.
Luckily, Internet has always raised the issue, and has almost the (right?) answer to [it](https://social.technet.microsoft.com/Forums/en-US/e1f801ea-405d-4a41-a9b9-e55dbdbee215/connect-with-ipadress-only-private-link-public?forum=ssdsgetstarted).

So the solution was either to modify the host or to create a private DNS Zone.

I hope this help.

If you are look for some inspirations for basic architecture, you can have a look at this [diagram](https://github.com/timothywarner/azure-class-diagrams/blob/master/azure-iaas-ref-arch.png).
How to test your serverless apps
Tags: todayilearned, devops, cicd, serverless
Published: 2020-02-13 13:00:20

*TL;DR notes from two articles I read today.*

### [The best ways to test your serverless applications](http://bit.ly/320vtrH)

- For the serverless functions you write, test for each of the following risks: configuration (databases, tables, access rights), technical workflow (parsing and using incoming requests, handling of successful responses and errors), business logic and integration (reading incoming request structures, storage order in databases).
- Break up functions into hexagonal architecture (ports and adapters) with separation of concerns through layers of responsibility. 
- For unit tests, use a local adapter or mock as an adapter to test the function business layer in isolation.
- Use adapters to simulate to test integration with third-party end services. Save memory and time by testing not for full integration but file storage integration with the in-memory adapter.
- For proper monitoring of integrations, use back-end tools such as IOpipe, Thundra, Dashbird, Epsagon, etc., and front-end tools such as Sentry or Rollbar. You can also use an open-source error tracking app such as Desole that you install in your AWS account.  

*[Full post here](http://bit.ly/320vtrH), 10 mins read*

---

### [How to measure the reliability of your software throughout the CI/CD workflow](http://bit.ly/39u5Emc)

- In addition to CI/CD, you should consider incorporating continuous reliability in the workflow. This may mean more focus on troubleshooting than on writing code.
- Consider whether to automate every step, or even whether some steps should be automated more than others. 
- Look beyond log files and testing to determine quality of code: set up advanced quality gates to block problematic code from passing to the next stage and use feedback loops to inform more comprehensive testing.
- In addition to log aggregators and performance monitoring tools, get a more granular understanding of app quality by ensuring you can access the source code, variable state and stack trace at the time of an error. Aggregate this data across the app, library, class, deployment or another boundary for an insight into the functional quality of the code.
- Based on this data, you can categorise known, reintroduced and unknown errors, classify events, understand frequency and failure rates, enabling you to write more comprehensive tests for development and pre-production environments alike, driving the higher code quality.   

*[Full post here](http://bit.ly/39u5Emc), 6 mins read*

---

*[Get these notes directly in your inbox every weekday by signing up for my newsletter, in.snippets().](https://mailchi.mp/appsmith/insnippets?utm_source=devto&utm_medium=post08&utm_campaign=is)*
Daily Developer Jokes - Thursday, Feb 13, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-02-13 13:00:02

---
title: "Daily Developer Jokes - Thursday, Feb 13, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Thursday%2C%20Feb%2013%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e12597fe0374.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ Where do developers drink?

___A:___ The Foo bar
 -->
Stopwatch in Python
Tags: python, beginners
Published: 2020-02-13 12:52:55

In <a href="https://python.org">Python</a> you can use the time module to wait (you can also get the <a href="https://pythonbasics.org/time-and-date/">time and date</a>). To be explicit, the time module provides various time-related functions.

This is very useful for many applications. If you make a game, it should not update every millisecond. If you make weather station software, it makes no sense to update in such a short time. For an alarm clock app, you need it to wait.

Lets say you want to make a stopwatch, without the program pausing there would be no way to create one.

## Sleep function

The module time has a function named <a href="https://pythonspot.com/sleep/">sleep</a>, which pauses the program (it complete freezes the program).

```python
time.sleep(t)
```

This waits for t number of seconds. Consider this program which waits for one second before it outputs the next word.

```python
import time.sleep

print("Hello")
time.sleep(1)
print("World")
```

## Stopwatch

So you can use the <a href="https://pythonspot.com/sleep/">time.sleep()</a> function to pause the program. But a stopwatch doesn't have a limit, it needs to go on. For that, you can use a <a href="https://pythonbasics.org/while-loop/">while loop</a>. Then you can use Ctrl+c to exit the program.

```python
import time

while True:
    print("Clock ticks")
    time.sleep(1)
```

If you run the above program it outputs:

```bash
➜  ~ python3 stopwatch.py
Clock ticks
Clock ticks
Clock ticks
```

Until you press Ctrl+c. Now it needs to count seconds, you can use time.time() to get the current time.

The example below will output every second passed until Ctrl+C is passed. 

```python
import time

start = time.time()
while True:
    time.sleep(1)
    total_secs = round(time.time() - start)
    print(total_secs)
```

## Formatting

To format it you can use <a href="https://www.python.org/dev/peps/pep-0498/">f-strings</a> with two digits. With a simple calculation you can get the minutes and seconds.

```python
import time

start = time.time()
while True:
    time.sleep(1)
    total_secs = round(time.time() - start)
    minute = round(total_secs / 60)
    seconds = round(total_secs % 60)
    s = f"{minute:02d}:{seconds:02d}"
    print(s)
```

**Related links:**
* <a href="https://docs.python.org/3/library/time.html">The time module</a>
* <a href="https://pythonbasics.org">Learn Python</a>
Nice Bootstrap Cards Hover Animation
Tags: codepen, css, beginners, html
Published: 2020-02-13 12:50:13

<p>Custom bootstrap cards with custom hover functionality</p>

<p>I made some hover effects for the bootstrap cards with nice animations</p>

{% codepen https://codepen.io/FlorinCornea/pen/vMRKXp %}

<p>Hope you liked it</p>
Applying CSS :focus-within
Tags: css, beginners, tutorial
Published: 2020-02-13 12:45:46

In my quest to learn something new every week. I came across a not so new pseudo-class element [:focus-within](https://drafts.csswg.org/selectors-4/#the-focus-within-pseudo). Let's take a look at how it works and how to apply it to our styles.

The `:focus-within` pseudo-class represents an element that is paired with the `:focus` pseudo-class or has a descendant that is matched by `:focus`.

> NB: the focus here means when you click, tap or tab through an element such as a form input or a link.

I like how [Chris Coyier](https://css-tricks.com/almanac/selectors/f/focus-within/) explains it in simple terms:

> It selects an element if that element contains any children that have `:focus`.


## How is this different from `:focus`?
The `:focus` pseudo-element works differently, an element receives focus when the `:focus` element is applied to it, but, in a case when you have a collection of child elements it is not common to use `:focus` pseudo-class to select the parent element. The `:focus` pseudo-class applies only to the focused element itself.

{% codepen https://codepen.io/lauragift21/pen/VwLLggX  default-tab=css,result %}

This is what `:focus-within` is able to solve. We can use `:focus-within`pseudo-class if we want to select an element that contains a focused element or elements that has descendants matched by `:focus`. Let's see how to achieve that.

## Applying :focus-within 

`:focus-within` is useful for different use-cases. You can think of using it:

- To highlight an entire form when one of its input fields is in focus.
- Highlight rows of a table and change the background color when a user clicks on it.

Here's an example, for highlighting an entire `<form>` container when the user focuses on one of its `<input>` fields.

{% codepen https://codepen.io/lauragift21/pen/gOppEVP default-tab=css,result %}

## Browser Support
As of 2020, This CSS feature is widely supported only IE browsers don't have support yet. Here's a table of current browser that fully supports `:focus-within`.

![Can I use](https://dev-to-uploads.s3.amazonaws.com/i/nu2usvsjsm47xyraenqe.png)

## Final Thoughts
The `:focus-within` element is an accessibility win for developers and users on the web. We should always keep it in mind while coding it's way better to reach for this than use JavaScript to accomplish the same task. 


## Resources
[CSS Focus Within Spec](https://drafts.csswg.org/selectors-4/#the-focus-within-pseudo)
[MDN Docs](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within)
[CSS Tricks :focus-within](https://css-tricks.com/almanac/selectors/f/focus-within/)

[Originally published on my blog](https://www.giftegwuenu.com/applying-css-focus-within/)
Hot to call this function from another component in react?
Tags: react, javascript
Published: 2020-02-13 12:31:14

Hot to call this function from another component in react?


function uCyr() {


  var entered_text;


  entered_text = document.getElementById('textarea').value;



  entered_text = entered_text.replace(/a/g, 'b');
  
  document.getElementById('textarea').style.color = '#9C27B0';
  document.getElementById('textarea').value = entered_text;



}
Run useEffect Only Once :React

Tags: react, javascript, reactnative
Published: 2020-02-13 12:15:25

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hfmjb0x6ht3oywqs6cvh.png)
If you want to run an effect and clean it up only once (on mount and unmount), you can pass an empty array ([]) as a second argument. This tells React that your effect doesn’t depend on any values from props or state, so it never needs to re-run. This isn’t handled as a special case — it follows directly from how the dependencies array always works.
If you pass an empty array ([]), the props and state inside the effect will always have their initial values. While passing [] as the second argument is closer to the familiar componentDidMount and componentWillUnmount mental model, there are usually better solutions to avoid re-running effects too often. Also, don’t forget that React defers running useEffect until after the browser has painted, so doing extra work is less of a problem.
Playing with the Notifications API
Tags: coding, notificationapi
Published: 2020-02-14 21:50:05

---
title: Playing with the Notifications API
published: true
date: 2020-02-13 12:12:47 UTC
tags: Coding,Notification API
canonical_url: https://blog.jws.app/2020/playing-with-the-notifications-api/
---

Over the years, I have spent a lot of time using modals and toast notifications to provide users with feedback about things that are happening in the background while a web page is active.  These messages could be about an autosave of data or about the expiration of a session.  Something more interesting has come about, though.  We now have the [Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/notification).

**[Click here to test the Notifications API](https://jws.app/experiments/notifications/demo1.html)**

So, how do you implement this magic?

{% codepen https://codepen.io/steinbring/pen/LYYMbrZ %}

While you can read what’s going on via the [CodePen](https://codepen.io/steinbring/pen/LYYMbrZ) embed, I recommend testing via the [demo link](https://jws.app/experiments/notifications/demo1.html).

So, how does [the compatibility picture](https://caniuse.com/#feat=notifications) look?

[![](https://i0.wp.com/blog.jws.app/wp-content/uploads/2020/02/Screen-Shot-2019-11-18-at-9.32.01-PM.png?resize=300%2C129)](https://i0.wp.com/blog.jws.app/wp-content/uploads/2020/02/Screen-Shot-2019-11-18-at-9.32.01-PM.png)

On the desktop, it is pretty good. iOS doesn’t support it at all and Android supports it with caveats, though.

Have questions, comments, etc.  Feel free to drop a comment below.
RPA - Robotic Process Automation Online Training 
Tags: training, automation
Published: 2020-02-13 11:48:11

Learn how to manage the RPA - [Robotic process automation software] (https://trubot.datamatics.com/). Explore various features of the automation software tool TruBot - developed by Datamatics. Improve your RPA learning experience with this online session.

Duration: 3 hours

You can Sign up Here - [Free RPA Training Online](https://trubot.datamatics.com/training/hands-on-webex)

Download Free RPA Software ( Trial Version - 30 Days) - [Download RPA](https://trubot.datamatics.com/trubot-free-trial-download)
This Is How You Can Buy Bitcoin And Other Cryptocurrencies Using Paypal
Tags: blockchain, bitcoin, paypal, cryptocurrencies
Published: 2020-02-13 11:39:57

Cryptocurrencies like Bitcoin and others have taken the world by storm. There are many websites giving the latest news on Bitcoin together with other cryptocurrencies. Apart from these, several payment methods have emerged that could help anyone buy and sell anything using these digital currencies. With cryptocurrencies getting the spotlight nowadays, several questions have emerged. One of the popular questions is how one could buy bitcoin and other cryptocurrencies using Paypal. The payment platform, by itself, is a big name in the payment industry. Paypal has been supporting the use of cryptos on its platform. In this article, I am going to discuss how you can buy Bitcoin and other cryptocurrencies using Paypal.

Read Full News 👉 https://blog.cryptoknowmics.com/this-is-how-you-can-buy-bitcoin-and-other-cryptocurrencies-using-paypal
syndicate: a POSSE way to DEV
Tags: meta, productivity, blog, showdev
Published: 2020-02-13 11:26:00

---
date: 2020-02-13T11:26+00:00
dev_silo_id: 260898
published: true
tags:
- meta
- productivity
- blog
- showdev
title: 'syndicate: a POSSE way to DEV'
---

Until a month ago I had never written a blog post.
<!-- / -->

My recent discovery of DEV has a lot to do with why I started, and indeed, I created [my first post](https://dev.to/daniel13rady/declaring-variables-in-javascript-31ch) right here on DEV.

While educating myself on the art of writing for other people, I came across the term "POSSE", which I had never heard of before but [is apparently kind of a big deal](https://indieweb.org/POSSE). It is a principle that is embraced by DEV itself, according to Ben.

{% devcomment d8pj %}

The idea intrigued me, as do most things that involve "write once and reuse" concepts. I began to imagine how such a thing might be accomplished, and just like P.O.S.S.E. itself, the recipe for its implementation seemed simple on the surface:

1. Create a "source of truth" for your writing.
2. Know where you want to distribute, and how to do it.
3. When your truths change, ensure a process is triggered to ferry your changes to the right places.

I don't know about you, but that sequence of steps strongly reminds me of the basic recipe for deploying software. And so I immediately re-imagined it as such:

1. Create a `git` repo for my writing.
2. Decide on the platforms I want to distribute to, and write scripts to do so via public APIs.
3. Setup `git` hooks to run those scripts when changes are made.

Long story short (the "long story long" will come as a separate post), I took a week of evenings and a weekend, and made this:

{% github dabrady/syndicate %}

As the README describes, it will let you write your content on Github, and distribute it automatically to DEV.to, keeping subsequent changes in the content on Github synced to DEV.

It is designed to be used as [an action in a Github Workflow](https://github.com/features/actions), but technically it is just a simple Python program that can be run with Docker if you want (I include a Dockerfile). To use it as intended, all you need to have is a Github repository, and all you need to do is create a Github workflow in that repository which uses `dabrady/syndicate` in one of its steps.

For now, it only recognizes one silo platform, DEV.to, because that's the only platform I currently publish on. But I made it simple to add plugins/adapters for other silo platforms, so if you'd like to contribute, that's a great way to do so!

Like my first blog post, this is my first project written with the intent to share with other people. It's also my first time using Python in almost a decade, so I used _[The Hitchhiker's Guide to Python](https://docs.python-guide.org/)_ as my main resource for project management and layout. Any and all feedback is greatly appreciated! :pray: I hope it benefits us.