teleren/devto huggingface dataset:
Java Frappe: Optional<T>
Tags: java, oop
Published: 2022-08-07 14:10:18

The Optional object in Java (`java.util.Optional`) is a container object which may or may not have a value. Designed specifically to handle the `null` case in a safe and explicit way, the optionals help write more readable code.

## Typical Usage

1) When returning an object that might be `null`
   ```java
   public Optional<Employee> findEmployeeByName(String name) {
     Employee employee = repo.findEmployee(name);
     return Optional.ofNullable(employee);
   }
   ```

2) To fallback upon receiving `null`

   - Return a default object
     ```java
    Employee employee = findEmployeeByName("John")
                          .orElse(new Employee("Unknown", 20));
     ```

   - Return after a pipeline of operators
     ```java
     Integer salary = findEmployeeByName("John")
                          .map(Employee::getSalary)
                          .orElse(30);
     ```
   - Run a callback if value exists
     ```java
     findEmployeeByName("John")
                .ifPresent(employee -> {
                    kafkaTemplate.send("employee-key", employee, "employee-topic");
                });
     ```
   - Return an exception
     ```java
     try {
        value = opDouble.orElseThrow(IOException::new);
     } catch (IOException e) {
        System.out.println("Exception " + e);
     }
     ```
     By default returns `NoSuchElementException`, if no value exists within the Optional.
How to remove the <a></a> tag color and underline
Tags: html, css, webdev, beginners
Published: 2022-08-07 14:05:34

```
a{
all:unset;
text-decoration:none;
}
```

1. `all:unset` this property is used in anchor tag to remove the color from the anchor tag sentence.
2. `text-decoration:none;` this property is used to remove the underline from the sentence.
Custom font on GitHub
Tags: github, font, extension
Published: 2022-08-07 14:18:54

---
title: Custom font on GitHub
published: true
date: 2022-08-07 14:04:03 UTC
tags: github, font, extension
canonical_url: https://krzysztofzuraw.com/2022/custom-font-on-github/
---

To set your favourite font to be on GitHub you need:

1. [Refined GitHub](https://github.com/refined-github/refined-github) extension
2. Go to options of this extension. For Chrome: click on 3 dots on installed extension on `Extensions` list and select `Options`
3. Paste following CSS into `Custom CSS` text-area

```css
pre,
code,
.blob-code,
.blob-code-marker,
.input-monospace,
.markdown-body code {
  font-family: MonoLisa;
}
```

1. You can change fonts/colours for other parts of GitHub using `Custom CSS` option
What If Animals Could Code...
Tags: jokes, discuss, webdev, programming
Published: 2022-08-07 13:56:36


Okay, here we go again! In the last article in this series you came up with amazingly 40 hilarious comments on the topic [celebrities who code](https://dev.to/perssondennis/top-10-celebrities-who-code-7g7). I look forward to see what you geniuses may come up with this time.

So here's today's topic. When YouTube goes down, highly trained monkeys join up to fix the problem as fast as possible. Monkeys may be the only non-human animal that codes, but what would other animals do if they were developers?

![YouTube monkey business](https://www.perssondennis.com/images/articles/what-if-animals-could-code/youtube-code-monkeys.webp)
_I believe them, why would they lie?_

**Use your imagination and comment funny suggestions of what it could be like to hire an animal as a developer**. Here's some suggestions of mine, feel free to reuse the same animals if you want to.

1. **Pandas** _- would be pandastic programmers!_
1. **Snails** _- would always be working from home_
1. **Snakes** _- do I need to mention Python?_
1. **Bugs** _- I have a feeling they would struggle finding a workplace who wants them_
1. **Cows** _- they are more into hardware, they follow mooooores law_
1. **Lions** _- strong partners for a startup, but expect them to take the lion share of the profit_
1. **Sloths** _- would probably benefit using Copilot_
1. **Sheep** _- may be sheep to hire, but is it worth it?_
1. **Cats** _- wouldn't touch code, they would promote themselves to managers_
1. **Pigs** _- dirty code, but they are actually pretty clever_
1. **Moles** _- they would love to C#_
1. **Bats** _- as long as you are fine with putting your screen upside down, they could maybe be worth hiring_
1. **Dogs** _- would probably be their best. day. ever._
1. **Whales** _- hire one and you boss will call you in to talk about office expenses_

![Developer animal meme](https://www.perssondennis.com/images/articles/what-if-animals-could-code/koalificated-meme.webp)
_I'm sorry Mr. Koala, but you always do the bear minimum of work_

&nbsp;

{% embed https://dev.to/perssondennis %}
Redis x Dev Hackathon 2022 - A newbie's proclamation 📢
Tags: redishackathon, beginners, showdev
Published: 2022-08-07 13:48:00

Since May 2022, I started skilling myself as a Backend developer. My tech stack, for now, is - Python, Flask, and MongoDB. I see this hackathon as an opportunity to explore & learn new technologies that can complement my existing tech stack.

---

### Project Idea: 
A music library app that’s built using Python-Django framework and uses Redis alongside MongoDB; as a frontend database in front of MongoDB. I will implement it using the Microservices architecture framework.

#### Why a music library app?
Because there are too many eCommerce apps out there.

### Intentions vs. Outcomes:
#### Intentions:
By the end of the Hackathon, I intend to familiarize myself with 

- the Django framework, 
- Redis, 
- MongoDB, 
- the Microservices architecture, 

and **most importantly**, submit a _Minimum Viable Project_ for this hackathon.

#### Outcomes:

- ???

---

Declaring the project on a community forum will help me stay motivated throughout the hackathon. Also, it keeps me accountable.

My best wishes to all participants.
GSoC 2022 CircuitVerse | Week 7 and 8 Report
Tags: javascript, webdev, programming, opensource
Published: 2022-08-07 13:16:00

## Description

This week I worked on completing the Noticed Integration into CircuitVerse, this was one of the challenging and most productive weeks ever as I have learned:
- Rails console effective usage.
- ActiveRecords
- Migration.
- Controllers.
- Views rails.

So in the last meeting, I showed the demo of the notification functionality to the mentors and they stated that there are some minor changes in the UI and to migrate the old data of Activity Notification.

I completed the task for helper methods, UI, and some cleanups. But the most challenging task for me was to migrate data from one table to another table with different configurations. Aboobacker shared a migration file that contains `SQL` the query for the migration but that was comparatively simpler than what I needed to do in this task!

So I have comeup with many solutions to render old notifications:
1. I thought we can just add a `before_action` filter with method `load_old_notifications` for `user`.So I create a new column in `old_notification` table called `migrated` with default `false`, so whenever the user signin, the `load_old_notifications` will run and will check in the `old_notification` if the `migrated` field is `false`, it will create a new data for `notification` table and mark `migrated` as `true` in `old_notification` table.

2. But I find this as very complex as we are thinking of removing `ActivityNotification` gem and while migrating there is model method needed to get the path of the notification, so I drop this solution and jump into next and next, I failed and finally come up with the solution to use `ActiveRecords` in `migration` (it worked but not preferable) so here is my migration file look like:

```rb
class PopulateNotificationData < ActiveRecord::Migration[7.0]
  include ActivityNotification
  def change
    Notification.find_each do |data|
      newnotification = NoticedNotification.first_or_initialize(
        :recipient_type => data.target_type,
        :recipient_id => data.target_id,
        :type => "PreviousNotification",
        :params => {
          user_id: data.notifier_id,
          path: data.notifiable_path,
          message: data.notifiable.printable_notifiable_name(data.target),
          type: data.notifiable_type
        },
        :read_at => data.opened_at
      )
      newnotification.save!
    end
  end
end
```
> I need to change it in SQL query.

So that took me around 4 days but it was worth it, I learned a lot from failures.

This 2 weeks I also :
- Passed Mid-term Evaluation
- Post my first blog on CircuitVerse/Blog regarding first phase of GSoC.
- Attended my first offline hackathon and meet awesome peoples.

## Next week plan:
- Complete spec testcases
- Complete migration
- Start working on `push notification` in mobile app.
How to fix 'Uncaught SyntaxError: Cannot use import statement outside a module'
Tags: javascript, node, webdev, tutorial
Published: 2022-08-07 13:14:52

In this quick guide we'll look at how you can solve the very common error, "Uncaught SyntaxError: Cannot use import statement outside a module". This error arises when we try to use `import` inside of a project which is not set up for modules - so let's look at how you can resolve it.

## Resolving the import statement outside a module error
The reason why this error occurs is because we have to explicitly tell Javascript that the file in question is a `module`, in order to use the `import` statement. For example, if you are using the line below, and you have not told Javascript that the file is a module, it will throw an error:
```javascript
import fs from 'fs'
```

Depending on where you are getting the error, there are a few different ways to resolve it.

### Resolving the import module error in Node.js
If you are using Node.js, this error can be resolved in two ways. The first is to update your package.json to tell Node.js that this entire project is a module. Open up your package.json, and at the top level, add `"type": "module"`. For example, my `package.json` will look like this:
```javascript
{
    // ... other package.json stuff
    "type": "module"
    // ... other package.json stuff
}
```
This will resolve the issue immediately. However, in some edge cases, you may find you have issues with this, and other parts of your code may start throwing errors. If you only want one file in your project to support `import`, then change the file extension to `.mjs`. For example, if your `import` was in `index.js`, rename `index.js` to `index.mjs`. Now your issue will be resolved.

### Resolving the import module error in script tags

The second place this error can occur is in a script tag, like this:
```html
<script src="mymodule.js"></script>
```

In this case, if `mymodule.js` contains an `import` statement, it won't work. To resolve this, add `type="module"` to your script tag:
```html
<script type="module" src="mymodule.js"></script>
```

Now you'll never have issues with `import` again.
How to check if localStorage item exists
Tags: beginners, webdev, javascript
Published: 2022-08-07 13:07:27

Let's make this short. Since `localStorage.getItem("item")` returns a `null` if it is missing, we simply need to check if the return value is not `null`

```
if (localStorage.getItem("item") !== null) {
  console.log("Item exists")
  //Do stuff
} else {
  console.log("Item does not exist")
  //Do other stuff
}
```
How to Build a Gym Website Using HTML CSS JavaScript
Published: 2022-08-07 12:56:27

{% youtube dmif_yP7cZw %}

How to Build a Gym Website Using HTML CSS JavaScript

This video will show you how to build a gym website using html css javascript

[Live Website](https://codewithsadee.github.io/fitlife)
[Github Repo](https://github.com/codewithsadee/fitlife)

---

HI 👋
I'm Sadee (webdev)
In this channel I make videos about Complete Responsive website.
You can checkout my channel 👇

📺 My Channel : [codewithsadee](https://www.youtube.com/channel/UC1PZHWV6VvICTL1LgFUZq6g)
🔔 Subscribe : [subscribe now](https://www.youtube.com/channel/UC1PZHWV6VvICTL1LgFUZq6g?sub_confirmation=1)

---

🔗 Essential links
-----------------------------
[Download the starter file to practice]( https://drive.google.com/file/d/10ZSaWJ28AfMXn_rEEc5ZSkXHUa_6ZhV2/view?usp=sharing)

---

⏱️ Timestamps
-----------------------------
0:00 - Demo
3:32 - File structure
5:03 - Project initial
10:49 - Header
23:17 - Hero section
39:22 - About section
47:42 - Video section
53:36 - Class section
1:07:07 - Blog section
1:14:38 - Footer
1:35:29 - Media queries

---

[![Become a patreon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fnjl14kdm5qf08hu5lop.png)](https://www.patreon.com/bePatron?u=62535867)
How to install nvm, the Node Version Manager
Tags: webdev, tutorial, javascript, linux
Published: 2022-08-07 12:28:00

`nvm` stands for **Node Version Management**. If you don't have it installed already, in this quick guide we'll show you how to. `nvm` is used to manage the versions of Node.js installed on your computer, so it's a really useful tool. Using it, you can upgrade and change which version of Node.js you're running on your computer, [and change Node.js version](https://fjolt.com/article/javascript-change-nodejs-version).

## How to install nvm
On Linux or Mac, to install `nvm`, you can use the `curl` command:
```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
```

If you want to install a different version of `nvm`, you can replace the `v0.39.1` with whatever version you'd like to use. Alternatively, you can use `wget` to install `nvm`:
```
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
```

After running one of these commands, you need to add `nvm` to your bash profile. So run this command next, so that you can get started using it immediately:
```
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
```

## How to install nvm on Windows
As with most things, **windows** is a little different. If you want to use an `nvm`-like functionality on windows, you'll need to use a package like `nvm-windows`. [You can learn more about nvm-windows here](https://github.com/coreybutler/nvm-windows), [and for the latest install instructions, check out this link](https://github.com/coreybutler/nvm-windows/wiki#manual-installation).


## Conclusion
I hope you've enjoyed this quick guide. [If you want to connect with me, I'm on twitter](https://twitter.com/smpnjn) and [LinkedIn](https://www.linkedin.com/in/jonathon-simpson-464278a3/).
Reverse Linked List Solution
Tags: reverselinkedlistsolution, reverse, linkedlist, linkedlistpython
Published: 2022-08-07 12:23:14


We are going to share the Reverse Linked List Solution today. If you are applying to any software company 30% of the time you are going to have this question to solve.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3ek1pyzwhrrduf8mx23.png)
Read Full Story at https://hecodesit.com/reverse-linked-list-solution/
How to Recover Data After Windows 10 Update to Version 1809 Dated 2 October 2018
Tags: beginners, testing, test, tutorial
Published: 2022-08-07 12:13:47

On 2 October 2018, Microsoft announced a new October build, Windows 10 October 2018 Update (version 1809). This update has become automatically available for millions of users who were looking forward to it. Read how to recover data after upgrading Windows 10 to version 1809. What problems you may encounter and how to fix them.

Everything would be fine, but… social media, theme blogs as well as the official website of the Microsoft community were overwhelmed by questions and complaints from users who lost their data due to their operating systems update to the latest version.

Here are some of them:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qml388ipw8xdua8xrmrc.png)

Summing up all posts and messages, users complained that they had lost their personal files from such folders as Documents, Pictures, Music etc, and sometimes even installed apps and programs. That is, their data was gone after Windows had updated to October’s build 1809.

Because of the problems with removal of files from user accounts after update, Microsoft decided to recall the final build Windows 10 October 2018 Update (1809). Since 6 October, the build is no longer distributed via Windows Update service. If you downloaded an ISO image on your own — don’t install it and wait for a new build.

For those who haven’t managed to download an image of the new Windows 10 build yet, the update function is blocked. They are not going to receive any updates via Windows Update, and the official website lists Windows 10 April 2018 Update as the latest version available.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j4ktmd5kordy59oduxuo.png)

The link to the page:
[https://www.microsoft.com/en-us/software-download/windows10](https://www.microsoft.com/en-us/software-download/windows10)

In the page of the new build, you can only find the user information warning the people from hurrying to install the October update until the issue with data loss is cleared up and the bugs are fixed. There is also the contact information to use if your data was lost after the update.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bfqkbb11ibile1i7dsvy.png)

We are expecting a fixed version of Windows 10 October 2018 Update. Still, if you are among the unfortunate whose files were deleted by the operating system’s build 1809, you can restore them using the methods researched by Hetman Software long before that.
I am writing a freelance guide e-book for programmers, I need your suggestions
Published: 2022-08-07 11:59:00

Hi, my name is Saifullah Usmani. I am a  freelance Programmer. I have been programming for almost 5 years now. And I make websites (SaaS commonly) for my clients.

I have made several posts related to freelancing and you guys have seemed to love it. So I decided to write an E-Book explaining the mindset needed for freelancing in much more detail. I am merging all of my experience into that e-book and I have covered topics such as communication skill, networking etc.
I want you guys to participate and help me understand what kind of things I should be covering in that e-book. Any question you ask matters. Because I will use that data to create the chapters and stuff you want to/have to learn in order to become a freelancer and keep growing as one.

I would love to hear your thoughts. 



[![DigitalOcean Referral Badge](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/00rcc3tqicv68383vo0r.png)](https://www.digitalocean.com/?refcode=9d6f3f71c1b4&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge)
Affiliate Link☝



##Follow me:
Hire me: https://www.fiverr.com/saifullah02 (For web development Purposes)
My New Blog: [saifullahusmani.com](https://saifullahusmani.blogspot.com/)
*Follow me here:* https://dev.to/saifullahusmani
*YouTube:* http://bit.ly/saifullahusmani (Programming Tutorials Coming Soon).
*Discord:* https://discord.gg/AKyvy8Y
*Facebook*: [https://www.facebook.com/SaifullahUsmani693](https://www.facebook.com/SaifullahUsmani693)
DALLE-E Mini redesign 🎨
Tags: design, ai, sideprojects, showdev
Published: 2022-08-07 11:56:02

Hi there! 👋

Craiyon (Formerly DALLE-E Mini), made by [Boris](https://twitter.com/borisdayma), is a text-to-image AI tool that outputs an artwork from a text prompt and it's free! This kind of mass-market tool has to be very clear and accessible. Let's show you how I used design to make  it more accessible, trustable, and explainable.

   

![Homepage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sa0yxvx5taqvdem6l933.png)
> Trigger creativity ➡️ Show what's possible at the first glance.

   

![Tips to write a good prompt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v8ovih34jlpvy1cpszyg.png)
![Prompt input](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8cimror2nzm1942iuts.png)
> Help user writing a great prompt ➡️ Give tips on how to write for text-to-image generation.

   

![Loading state](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0w988gjum68qxr5svhyw.png)
> Show what's going on ➡️ Inform the user on the remaining time and give the option to cancel.

   

![Result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rzqh74dvfdu3kjiy9m4.png)
> Make it easy to grab the result ➡️ Show up a expressive "Download" button and give the option for a better resolution with an upscale.

   

You can find the quick breakdown of the design [here](https://www.hugoduprez.com/dalleeMiniRedesign) :)
Let me know your feedback! You can also play around the [Craiyon](https://www.craiyon.com/)app.

I'm also on [Twitter](https://twitter.com/HugoDuprez), say hello ✌️

Enjoy your week! 🔥
Big number, small numbers
Tags: perl, python, theweeklychallenge
Published: 2022-08-07 11:47:28

## Weekly Challenge 176

[Challenge](https://theweeklychallenge.org/blog/perl-weekly-challenge-176/), [My solutions](https://github.com/manwar/perlweeklychallenge-club/tree/master/challenge-176/sgreen)

## Task 1: Permuted Multiples

### Task

Write a script to find the smallest positive integer `x` such that `x`, `2x`, `3x`, `4x`, `5x` and `6x` are permuted multiples of each other.

### My solution

This is one challenge where we could over-engineer it to make it faster. Given that the solution can be found in a fraction of a second, this won't be necessary.

For example after 1,666, the next possible solution is 100,000. 1667 × 6 will result in a five digit number which can't possibly be a permutation of the original number.

The easiest way to work out if a number is a permutation is simply to sort the numbers numerically. In Python, we can do this by `''.join(sorted(str(num)))`. While `join '', sort split //, $num` will do a similar thing in Perl.

Like a lot of the challenges, I have a counter that starts at one, and increments until we have a solution. For each number, we figure out if the number multiplied 2 to 6 are a permutation of the original number, and exit the inner loop if it isn't. 

Finally when I do find a solution, I print it out, and exit the `main()` function.

Did you know? The solution (142,857) has its own [Wikipedia page](https://en.wikipedia.org/wiki/142,857).

### Examples

```
$ ./ch-1.py 
142857

$ ./ch-1.pl
142857
```

## Task 2: Reversible Numbers

### Task

Write a script to find out all Reversible Numbers below 100. A number is said to be a reversible if sum of the number and its reverse had only odd digits.

### My solution

This is relatively straight forward challenge. Count from 1 to 99, and add to a `solutions` list if the number is a reversible number.

As python doesn't have an easy way to reverse an integer, I convert it to a string and back to an integer with `int(str(num)[::-1])`. In Perl, this simply done with the `reverse` method. To see if the number is odd, I compare it with the regular expression `^[13579]+$`.

I then print all the numbers in a `solutions` list.

### Examples

```
$ ./ch-2.py 
10, 12, 14, 16, 18, 21, 23, 25, 27, 30, 32, 34, 36, 41, 43, 45, 50, 52, 54, 61, 63, 70, 72, 81, 90

$ ./ch-2.pl 
10, 12, 14, 16, 18, 21, 23, 25, 27, 30, 32, 34, 36, 41, 43, 45, 50, 52, 54, 61, 63, 70, 72, 81, 90
```