teleren/devto huggingface dataset:
How to handle a price with Ruby-on-Rails
Tags: ruby, rails, database, beginners
Published: 2022-01-27 13:55:23


You surely ever needed to add a price column in a table of your database. But what type to select for the column price? A beginner will try with a float and meet trouble to display the price value.

<h1>Use the type Decimal !</h1>
Let's create a Book table with title, description and price columns. I put the validations aside, it is not the subject of this tiny article.
```
rails g model Book title:string author: string price:decimal{8,2}
```
After making the usual rails db:migrate, launch 'rails c' in the terminal so you can try to create an entry in your database. You can use the next code for convenience : 
```
book = Book.new(
  title: 'La nuit des temps',
  author: 'Barjavel',
  price: 10.99)
book.save
```
No errors right? But your surely see price value like that : 
```
price: 0.1099e2
```
To display the price with decimal formatted number, you can use .to_s, so we get :
```
book.price.to_s # 10.99
```

Done!
Office 365 Backup & Restore Tool
Published: 2022-01-27 13:44:56

The [Office 365 Backup tool](https://www.cloudemailmigration.com/office365-backup.php) to Export Office 365 Mailbox to PST is one of the most powerful and advanced tools available, which is capable to export Office 365 mailbox to PST, EML, MSG and HTML format. This tool is very helpful to export Office 365 mailbox to PST in a secure manner. This tool is very reliable, quick and easy to use. This tool is a best option available to export Office 365 mailbox to PST. If you want to export Office 365 mailbox to PST, then this tool is the best option available.
🎬CSS Loading Animation | HTML & CSS🙌
Tags: html, css, webdev, beginners
Published: 2022-01-27 13:43:10

#Make a CSS Loading Animation using HTML & CSS, step-by-step from SCRATCH…

***
{% youtube BuI2rdl3eJw%}
***

***Web Dev***
https://bit.ly/3oBQbc0

***

###Source Code:

**Markup**

```HTML
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS Loading Animation</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <div class="loader">
    <span></span>
    <span></span>
    <span></span>
    <h2>Loading...</h2>
  </div>

</body>

</html>

```
What Are Relative Locators In Selenium 4🔗| Selenium WebDriver 4 
Tags: testing, webdev, tutorial, beginners
Published: 2022-01-27 13:41:39

{% youtube FwFDA0822T0%}

In this video on Relative Locators in Selenium 4, Anton Angelov (@angelovstanton) - CTO and Co-founder of Automate The Planet Ltd, explains relative locators, their types and how developers can use them while performing Selenium automation testing.

📌Also, you will get answer to these questions📃

🔸 What are relative locators?
🔸 What are the different locators in Selenium?
🔸 What is the purpose of locators in Selenium?
🔸 How do you use relative locators?
🔸 Can we use multiple locators in Selenium?
🔸 Which locator is faster in Selenium?


📣 The “Relative Locator” options available in Selenium automation testing are as follows:
◾ above: Web element to be searched/located appears above the specified element.
◾ below: Web element to be searched/located appears below the specified element.
◾ toLeftOf: Web element to be searched/located appears to the left of the specified element.
◾ toRightOf: Web element to be searched/located appears to the right of the specified element.
◾ near: Web element to be searched/located is at most 50 pixels away from the specified element.
application to prevent shutdown app by mistake
Tags: swift, app, macos, github
Published: 2022-01-27 13:29:57

#Did you accidentally shutdown application by click command + q?
then [here](http://github.com/tkgka/switcher)  is the solution!
this app makes macOS click command + q twice to shutdown app
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yod4r9ekgw171bvpr7ms.gif)
Let's Play with bucket using CP command
Published: 2022-01-27 13:14:38

**Prerequisites:**

1. An AWS Acoount
2. Two bucket one for source and one for destination
3. Aws CLI configured.

For demonstration, I created to new bucket which is publicly accessible.


![bucket created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vkck96sqwf55zdaf0wmx.png)  

**Uploading Individual Files to S3**


To upload a file to S3, you’ll need to provide two arguments (source and destination) to the aws s3 cp command.


![Upload file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ladqincq80qycbjv0hnl.png)

Note: S3 bucket names are always prefixed with S3:// when used with AWS CLI

Use the command below to list the objects at the root of the S3 bucket.
aws s3 ls s3://bucket-name


![list bucket content](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rf987c7x410r8tx7vv1.png)

**Uploading Multiple Files and Folders to S3**

What if you need to upload multiple files from a folder and sub-folders? Surely you wouldn’t want to run the same command multiple times for different filenames, right?


The aws s3 cp command has an option to process files and folders recursively, and this is the --recursive option.


![Upload muliple files and folder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f76ow7o6cdd6o8xj0177.png)

If we don't use --recursive option it shows an  error.

**Uploading Multiple Files and Folders to S3 Selectively
**
In some cases, uploading ALL types of files is not the best option. Like, when you only need to upload files with specific file extensions.

Options available to the cp command is the --include and --exclude.

![--include --exclude](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o4b3my2xkp9qt7npb53y.png)

**Downloading Objects from S3**

Copying from S3 to local would require you to switch the positions of the source and the destination. The source being the S3 location, and the destination is the local path, like the one shown below.

![Download from bucket](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s0tuu8rzavtysuv2p6rm.png)

**You can also use --recursive option for multiple download**.


![Recursive download](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/arl5ukcmd6t5y8kp1run.png)

**Copy from one bucket to oneother bucket**.

aws s3 cp source-bucket destination-bucket

![copy bucket to bucket](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m49u3rqi4wfnhijauq1u.png)
CORS: Explaining with food.
Tags: http, api, laravel, backend
Published: 2022-01-27 13:07:54

CROSS-ORIGIN Resource Sharing is a policy for requesting information from a source different than yours, going against the standart same-origin policy in most of the browsers. Picture yourself having food at your home. That delicious meat that your mother cooks that is, hhhmmm, delicous, and you believe in her hands, because you know she cleans her hands, she bathes: same-origin provides you safety. But I doubt that your mom can cook a milk shake and a Big Mac in less than 5 minutes. So you order food, and unless you live inside a MCdonalds, the delivery will come from a different origin. But you know if the cooker has knowledge of ... soap? If he actually cleans his hands? Not same origin, or shorten, cross-origin is dangerous most of the times. Thats why your browser locks it up.
For further and better reading, have this link: https://web.dev/cross-origin-resource-sharing/
5 Customer Support Tips
Tags: podcast
Published: 2022-01-27 13:04:06

{% spotify spotify:episode:6P2K98EY0Vkpodf9iF9Rdb %}

## What is HTML All The Things

HTML All The Things is a [web development podcast](https://podcast.htmlallthethings.com/) and [discord community](https://discord.com/invite/jweMCx9) which was started by Matt and Mike, developers based in Ontario, Canada. 

The podcast speaks to web development topics as well as running a small business, self-employment and time management. You can join them for both their successes and their struggles as they try to manage expanding their Web Development business without stretching themselves too thin.

## Announcements

The **Svelte for Beginners** Udemy course is now live! Mike took his experience in teaching and learning Svelte and created a course. 

This course will teach you the fundamentals of JavaScript frameworks. 

**Get it now on Udemy!** 👇

[Svelte For Beginners](https://www.udemy.com/course/svelte-for-beginners/?couponCode=HATTSALE)

## What's This One About?

Customer support can be one of the hidden "costs" of doing web development for clients. Without a dedicated support team, the IT support role often falls to the developer or freelancer that created the project. This great investment of time can often be overlooked by web developers that are looking to create more than they are to support. In this episode, Matt and Mike discuss some tips and tricks in 5 different areas of customer support including dealing with angry clients, ensuring that you're caring for yourself during all the stress, and ensuring that you know when to walk away.


## Show Notes

1. Prioritization: Balancing Severity vs Completion
2. Managing Angry Clients
3. Self Care: Managing personal anxiety and anticipation
4. Time Suck: Dealing with hand-holders
5. When to walk away from support


## Thank you!

If you're enjoying the podcast consider giving us a review on [Apple Podcasts](https://podcasts.apple.com/us/podcast/html-all-things-web-development-web-design-small-business/id1412209136) or checking out our Patreon to get a shoutout on the podcast. 

**[Support us on Patreon](https://www.patreon.com/htmlallthethings)**


You can find us on all the podcast platforms out there as well as

[Instagram (@htmlallthethings)](https://www.instagram.com/htmlallthethings/)
[Twitter (@htmleverything)](https://twitter.com/htmleverything)
[TikTok (Html All The Things)](https://www.tiktok.com/@htmlallthethings)
Milliseconds in Ruby
Tags: ruby, rails
Published: 2022-01-27 12:54:41

article originally published here : https://www.bootrails.com/blog/ruby-milliseconds/

How to get milliseconds in Ruby ? Let's explore 3 scenarii.

## 1. Display time, down to milliseconds in Ruby

```ruby
current_time = Time.now
current_time.strftime('%H:%M:%S.%L')
# => "10:52:07.119"
```

If you want more info about `strftime`, please read this article : [https://www.bootrails.com/blog/ruby-strftime-short-and-long-story/](https://www.bootrails.com/blog/ruby-strftime-short-and-long-story/) - milliseconds, however, were not covered at this time :)

## 2. Get current time system in milliseconds 

First possibility is to use `.strftime`, again :

```ruby
current_time = Time.now
current_time.strftime('%s%L')
# => "1643017927119"
```

Please note the result is a String.

The second possibility is the following :

```ruby
(current_time.to_f * 1000).to_i
# => 1643017927119
```

The result is a number.

## 3. Elapsed time in milliseconds in Ruby

### Ruby-on-Rails method

If you are in the Rails environment, the `.in_milliseconds` method already exists.

```ruby
# Assuming Rails is loaded
time_a = Time.now
sleep(2)
time_b = Time.now
# Just call .in_milliseconds method
(time_b - time_a).in_milliseconds
# => 2016.464
```

### Pure Ruby solution

If you just want the number of milliseconds elapsed since Epoch, type

```ruby
DateTime.now.strftime("%Q")
# => "1643018771523"
DateTime.now.strftime("%Q").to_i
# => 1643018771523
```

But if you need a difference between two time, you will have to write your own method :

```ruby
def time_difference_in_milliseconds(start, finish)
   (finish - start) * 1000.0
end
time_a = Time.now
sleep(2)
time_b = Time.now

elapsed_time = time_difference_in_milliseconds(time_a, time_b)
# => 2020.874
```

If you don't mind about Monkey Patching, here is another possibility :

```ruby
class Time
  def to_ms
    (self.to_f * 1000.0).to_i
  end
end

time_a = Time.now
sleep(2)
time_b = Time.now
elapsed_time = time_b.to_ms - time_a.to_ms  
# => 2028

```
##  A word of caution


We found an interesting article [here](https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/) about Ruby's lack of precision with the clock. Whereas we do not very often need a high precision in the web industry, it's always good to know.

Enjoy !
College and Code
Tags: college, codenewbie
Published: 2022-01-27 12:52:09

Are you in college? That is one of the best opportunities that you will ever have... for social skills. College is not a place to learn to code. In fact, is the hotspot for networking. The biggest mistake I made back in 2017 when I entered college was the false notion that I would become the "hackerman" as soon as I entered the college... But for sure I made friends. Still do. If theres a hot tip for college newbies, it would be: learn to be a self-taught, self-sufficient machine of advancements. Then, and only then, college will begin to help you.
How to promote your open source project
Tags: opensource, career, news, github
Published: 2022-01-27 12:41:08

In the previous article _[Financing your open source project](https://dev.to/vorg/financing-your-open-source-project-4i2l)_, I wrote about how to finance your open source project.  That is to use VORG to start your open source community DAO and IPO for it.

VORG is an organization that provides DAO registration and financing services to the open source community.

However, as a service platform for the open source community, it failed to show any features orient to open source projects at that time. So we made improvements to VORG:

1. We have added project information display to the DAO Github link.
2. we have added a magazine section to show a wide variety of open source projects to developers.

In magazines, you can see a lot of interesting open source projects, which may involve various programming languages. I believe there will always be one that will impress your curiosity.

Come to read now. Magazine entrance: [VORG Magazine](https://vorg.io/magazine).

If you have interesting open source projects you would like to recommend to everyone, please leave a message to us on Twitter and we may introduce your projects in the next few issues.
The Kosher Rule of WWW
Published: 2022-01-27 12:33:40

**Always separate the code logic from the data presentation and the data presentation from the presentation styles.**

- Stop mixing PHP with HTML!  → Use [Twig template engine](https://twig.symfony.com/) instead.
- Stop mixing CSS with HTML! → Remove completely `style` attribute from tags in page content and learn to use `class` instead.

Follow this rule if you want to save the World Wide Web.
Striver's SDE Sheet Journey - #19 Two sum
Tags: programming, beginners, java, computerscience
Published: 2022-01-27 12:31:15

> **<u>Problem Statement</u> :-**

_Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target._

> Example


**Input** :  `nums = [2,7,11,15], target = 9`

**Result** : `[0,1]`

**Explanation** : Because nums[0] + nums[1] == 9, we return [0, 1].


##  <u>Solution 1</u>

_we can solve this problem by using two pointer approach_
lets discuss this solution step by step.

**step-1** make a copy `sortArr` array from the `nums` array.

**step-2** sort the copy `sortArr` array.

**step-3** initialise two pointers `start=0`, `end=n`.

**step-4** run a loop from `start` to `end` and then,

 > **1.** calculate the `sum`  from `start` & `end` indices of array.

 > **2.** break the loop if `sum == target`

 > **3.** increase the `start` by 1 if `sum < target`

 > **4.** decrease the `end` by 1 if `sum > target`


**step-5** find the original indices from `nums` array & return it.

> Dry Run
nums = [1,3,5,2,7] , target = 4

**1.** copy the array.
copyArr = [1,3,5,2,7]

**2.** sort the copied array.
copyArr = [1,2,3,5,7]

**3.** run two pointers on sorted array

```
copyArr = [1,2,3,5,7]
           |       |
        start      end

sum = start + end
sum = 1 + 7 => 8
8 > target = 4 ----> end--
```

```
copyArr = [1,2,3,5,7]
           |     |
        start    end

sum = start + end
sum = 1 + 5 => 6
6 > target = 4 ----> end--
```

```
copyArr = [1,2,3,5,7]
           |   |
        start  end

sum = start + end
sum = 1 + 3 => 4
4 == target = 4 --> stop the loop
```
return the original indices of values from the `nums` array.

```
           0 1 2 3 4
copyArr = [1,2,3,5,7]
           |   |
        start  end
        
        0 1 3 4 5
nums = [1,3,5,2,7]

ans = [0,1]
```
## Java

```java
class Solution {
    public int[] twoSum(int[] nums, int target) {
        
        int[] sortArr = nums.clone();
        int[] ans = new int[2];
        
        Arrays.sort(sortArr);
        
        int start =0, end = nums.length-1;
        int n1 = 0,n2 = 0;
        
        while(start < end){
            
            int sum = sortArr[start] + sortArr[end];
            
            if(sum == target) {
                n1 = sortArr[start];
                n2 = sortArr[end];
                break;
            }else
             if(sum > target)
                  end--;
              else
                start++;
        }
        
        for(int i=0; i<nums.length; i++){
            
            if(n1 == nums[i]){
                ans[0] = i;
                n1 = -1;
            }
            else
            if(n2 == nums[i]){
                ans[1] = i;
                n2 = -1;
        }}
        
        
        return ans;
        
        
        
    }
}
```
Improving UI as a developer
Tags: webdev, beginners, tutorial, codenewbie
Published: 2022-01-27 11:57:12

While starting out in web development, one of the issue faced by new learners is that the projects don't look attractive or sometimes they'll use framework like Bootstrap.

As a starting point doing that would be fine but as you get to showcase your projects to a potential employers you might also want your projects to look good and make sure they don't look same as others.

__For that let's see some pointers to keep in mind for UI of your projects:__

## 🌟 Keep it Simple

As beginner you'd be seeing and wanting to apply some really awesome ideas for your projects, but problem occurs when you try to implement many complex ui elements at once.

There are certain style or asthetic every good and professional looking website follows that makes it professional looking.

But if you mixed multiple different styles in a same page then it can make your site a little messy and users might want to leave it after sometime.

## 🌟 Use a colour palette limited colours

On point of a particular style, you might want to use only few colors in your project, you should only use 2/3 colors to make sure it doesn't look overly colourful that is bad to look at

_You can use sites like colourhunt or coolers and use pre made color pallets._

By doing this you make a personal rule for yourself and not use colors randomly that ruins your UI.

## 🌟 Better choice of fonts

You will notice that most of the sites nowadays use sans-serif fonts as they look modern. so you can try them too, it can make your website look modern and professional. 

Sometimes you can try using monospace fonts too, as they are kinda techy and minimal fonts, if used in certain way they could look great too. 

And on some rare occasion you can also try using serif fonts. I'm not saying you shouldn't use serif fonts but they can be used only on certain types of asthetics.

## 🌟 Use Micro Animations

You might want to give some kind of feedback on user actions, like showing message when clicked somewhere, hover effects etc...

It doesn't look good when there is this success message that just comes and hides randomly, you can apply some fade animation quickly using CSS, so why not use it.


## 🌟 Making your site mobile friendly

Most of your users will be coming from mobile devices so you might want to make sure that your website is also looking better at a different screen size. 

That is a whole different section on how you can make your site look better at mobile screen size, so do your research on it too.

*These are just some pointers to reference but there are so many things to make sure of while making or improving UI designs as a developer*

___ 

**If you found the content i share useful than share it with your developer friends and also follow me on [Instagram](https://www.instagram.com/gaurav_vaala/) and [Twitter](https://twitter.com/gaurav_vaala)**
Providing solutions for building smart world
Published: 2022-01-27 11:38:46


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2t70qitl4ke6ypd6zez.gif)
**[Instance IT Solutions](https://instanceit.com/)** is a leading IT company with the best CRM and Mobile Application Development, providing a broad range of services in Strategy, Custom Development, Enterprise Resource Planning and more. Our deep expertise in customized solutions, technology innovation, time-tested processes, proven IT strategies makes us a perfect fit for your niche. We have a team of more than 32 dedicated people who focuses on delivering the best solution to our clients. We have served more than 500 clients and are enthusiastic to serve more clients.
My first first-author paper broke 50 citations. I think I know why and you can do it too
Tags: coding, python, reproducibility, research
Published: 2022-01-31 14:57:13

---
title: My first first-author paper broke 50 citations. I think I know why and you can do it too
published: true
date: 2022-01-27 11:33:00 UTC
tags: coding,python,reproducibility,research
canonical_url: https://dramsch.net/posts/my-first-first-author-paper-broke-50-citations-i-think-i-know-why-and-you-can-do-it-too/
---

![](https://dramsch.net/images/banner/banner-scientist-on-a-computer.thumbnail.jpg)

 

My first first-author paper broke 50 citations. I think I know why and you can do it too.

I shared my code and made it ridiculously easy to use.

I'm lazy myself.

If I find a paper that gives me all its ingredients ready to go,

I'm happy.

But how do you do this?

## 4️⃣ There are four essential files in the repo:

- License file - tell people how they're allowed to use it
- conda\_env.yml - tell people how to install
- Readme - Document everything!
- Jupyter NB - The actual code (with inline documentation)

## 💼©️™️ How do you choose a license for your files?

I like [choosealicense.com](https://choosealicense.com)

Personally, I often go with the MIT license. It's easy, it removes your liability, it gives people the right to use and modify your code.

Modification means new research. That means citations!

## 🤖 Install Stuff.

It's great to provide a requirements.txt for pip

and/or

a conda\_env.yml for conda installation.

I made it terribly hard for people and didn't provide package versions. Rookie mistake.

Step it one up and use poetry for exact reproduction of environments!

## 📝 Write that Readme.md

The readme file magically goes to the forefront of your @github repo.

Do the minimum, tell folks:

- What is this about
- How to install
- How to use (files, commands, etc)
- How to CITE! Put a bibtex file for extra credit.

## 🤷 People love to hate Jupyter Notebooks

But here's the thing.

Jupyter Notebooks are great, if you clean them before publication.

Put stuff into neat functions, organize sections, and make some nice plots.

Above all, use Markdown cells for inline documentation!

## 🏆 For extra credit:

🐳 Use docker to completely freeze the computational environment

🧮 Register your code on zenodo to give it a DOI

📌 Pin the repo to your github profile

## Conclusion

- Choose the right license for your code
- Write amazing documentation
- Make it easy to install, read, and use
- Consider making it incredibly easy to use

[Here's my repo.](https://github.com/JesperDramsch/seismic-transfer-learning)

Not a stellar example, but I give Jesper from 5 years ago a pass.