teleren/devto huggingface dataset:
Çeviri Yaparak para kazanma
Published: 2022-02-27 08:23:22

Çeviri yapma işi internet üzerinde oldukça fazladır. Dolayısıyla küçük bir internet araştırması onlarca sonuçla karşılaşmanıza yardımcı olur. Bunlara başvurur ve deneme metnini başarıyla çevirirseniz, işe aynı gün içerisinde başlayabilmeniz mümkündür.  Aynı şekilde yaşadığınız yerde bulunan tercüme bürolarına da gidilebilir.

Ancak yabancı dil ile internetten para kazanmak konusunda bilmeniz bazı noktalar da vardır. Bunları bilmeden denerseniz, istediğiniz sonuçları alamamanız muhtemeldir. Özellikle kendinizi dil üzerinde yeteri kadar geliştirmemişseniz, çevirilerin kalitesi düşük olacak, böylece aldığınız şikâyetler çoğalacaktır. Bu hususa dikkat etmeniz gerekir.

Kaynak: [https://kariyerfikri.com/ceviri-yaparak-para-kazanma/](https://kariyerfikri.com/ceviri-yaparak-para-kazanma/)
Solving cache invalidation in 15 lines of code
Tags: javascript, performance, programming
Published: 2022-02-27 08:14:45

Caching lets you manage the trade-off between freshness and speed when dealing with slow asynchronous calls.

If you only care about freshness, it's easy.  Just set a really short cache time (or forego caching entirely). The data will always be up-to-date, but you'll constantly be waiting on the slow calls to finish.

If you only care about speed, it's also easy. Just set a super long cache time. You'll rarely have to wait for the slow calls, but the data may be really out-of-date.

The problem is, developers often want both - fresh data as fast as possible. Cache invalidation is one way to achieve this, but it's incredibly hard to do well.  In fact, there's a [common saying](https://martinfowler.com/bliki/TwoHardThings.html):

> The two hardest problems in Computer Science are naming, cache invalidation, and off-by-one errors.

Stale-while-revalidate (or SWR) is another attempt to solve this problem that is much simpler.

When a stale item is requested from the cache, you immediately return it (maximum speed). You then kick off a background task to update the value (maximum freshness).

In fact, it's so simple, we can implement it in only 15 lines of javascript code:

```ts
const cache = new Map();
async function swr(key, refresh, staleAfter = 5000) {
  let data = cache.get(key) || {ts: 0, val: null, promise: null}
  cache.set(key, data);
  // Item is stale, start refreshing in the background
  if (!data.promise && Date.now() - data.ts > staleAfter) {
    data.promise = refresh()
      .then((val) => { data.ts = Date.now(); data.val = val; })
      .catch((e) => console.error(e))
      .finally(() => (data.promise = null));
  }
  // No data yet, wait for the refresh to finish
  if (data.promise && !data.ts) await data.promise;
  return data.val;
}
```

And this is how you would use it:

```ts
const data = await swr("cache-key", expensiveFuncion, 5000)
```

The first time you run that code, it will wait for the expensive function to finish. Subsequent calls will always return immediately.  If the returned value is stale (more than 5 seconds old), it will refresh it in the background.

You can get a lot fancier with the implementation, but the basics of SWR really are that simple!

If you are building a React App and want to use this method to fetch data for your front-end, I highly recommend the [useSWR React hook](https://swr.vercel.app/) by Vercel.
30 JavaScript Projects for beginners
Tags: javascript, projects, webdev, beginners
Published: 2022-02-27 03:39:29

[30 javascript projects](https://javascript30.com/)

This projects includes :

1. JavaScript Drumkit
2. CSS + JS Clock
3. Playing with CSS Variables and JS
4. Array Cardio Day 1
5. Flex Panels Image Gallery
6. Ajax Type Ahead
7. Array Cardio Day 2
8. Fun with HTML5 Canvas
9. 14 Must Know Dev Tools Tricks
10. Hold Shift to Check Multiple Checkboxes
11. Custom HTML5 Video Player
12. Key Sequence Detection (KONAMI CODE)
13. Slide In on Scroll
14. Object and Arrays - Reference VS Copy
15. LocalStorage and Event Delegation
16. CSS Text Shadow Mouse Move Effect
17. Sorting Band Names without articles
18. Tally String Times with Reduce
19. Unreal Webcam Fun
20. Native Speech Recognition
21. Geolocation based Speedometer and Compass
22. Follow Along Links
23. Speech Synthesis
24. Sticky Nav
25. Event Capture, Propagation, Bubbling and Once
26. Stripe Follow Along Dropdown
27. Click and Drag to Scroll
28. Video Speed Controller UI
29. Countdown Clock
30. Whack A Mole Game

Also, for a better UI for Weather app 
[Better UI for weather app](https://webdesign.tutsplus.com/tutorials/build-a-simple-weather-app-with-vanilla-javascript--cms-33893)
Update your team to be more extreme
Tags: extreme, programming, team, work
Published: 2022-02-27 08:00:43

Our profession is constantly evolving; therefore, it demands a non-stop learning process. Embracing the change is not optional in our software industry.

We need to create spaces to get out of our comfort zone, so our cognitive brain can train and improve how to adapt to our surroundings, which are constantly transforming.

> Continue reading at:
[https://chemaclass.es/blog/update-your-team-to-be-more-extreme/](https://chemaclass.es/blog/update-your-team-to-be-more-extreme/)
A Quick 10-Second Programming Joke For Today
Tags: jokes, dailydeveloperjokes
Published: 2022-02-27 08:00:20

---
title: "A Quick 10-Second Programming Joke For Today"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259582acfe.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_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:___ Why did the developer have to quit smoking?

___A:___ Because they couldn't afford to pay the new syntax.
 -->
Android Jogging App - Part 3
Tags: programming, devjournal, kotlin, android
Published: 2022-02-27 07:58:59

## Introduction

Hello :) and welcome to part 3 of my jogging application side project. 

This time I decided to implement the sensor event listener.

---

## Setting up the sensor event listener

First for logging purposes I added a TAG variable to MainActivity.

```kotlin
private val TAG = "MainActivity"
```

Once the Activity Recognition permission is granted/not needed I then call the following method:

```kotlin
initializeStepCounterListener()
```

This method bascially initializes the listener for the step counter:

```kotlin
 private fun initializeStepCounterListener() {
    val sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager
    val stepCounterSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER)

    stepCounterSensor ?: return


    sensorManager.registerListener(this@MainActivity, stepCounterSensor, SensorManager.SENSOR_DELAY_FASTEST,)
}
```

The above basically gets the manager and the sensor, then if the sensor is not null the listener is registered. Because I want it as close to real time as possible I use "SNSOR_DELAY_FASTEST" to get data as fast as possible.

Next I needed to add the listener to the MainActivity:

```kotlin
class MainActivity : AppCompatActivity(), OnMapReadyCallback, SensorEventListener {
```

Then I had to implement the events which are "onAccuracyChanged" and "onSensorChanged":

```kotlin
 override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
    Log.d(TAG, "onAccuracyChanged: sensor: $sensor; accuracy: $accuracy")
 }
```

onAccuracyChanged is called when the accuracy of the registered sensor has changed.
Here I just log the event.

```kotlin
override fun onSensorChanged(event: SensorEvent?) {
    event ?: return

    event.values.firstOrNull()?.let {
        Log.d(TAG, "Steps: $it")
    }
}
```

onSensorChanged is called when there is a new sensor event. 
Here I check if there is actually an event and then loop the values and log the output.

---

## Conclusion

Short and sweet, still a newb when it comes to Kotlin but it's fun learning as I go along.

---

## Things learnt

### Kotlin

?: - Checks to make sure the variable is not null

firstOrNull - Returns the first element, or null if the array is empty.

---

Like me work? I post about a variety of topics, if you would like to see more please like and follow me.
Also I love coffee. 

[![“Buy Me A Coffee”](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/ethand9999)
How to Send Email in Laravel 9 Example Tutorial
Tags: laravel
Published: 2022-02-27 07:54:29

Hi Dev,

In this quick example, let's see laravel 9 send email example. if you want to see an example of laravel 9 send mail example then you are the right place. This post will give you a simple example of sending an email in laravel 9 smtp. if you have a question about laravel 9 send mail smtp example then I will give a simple example with a solution.

Laravel 9 provides an inbuilt mail configuration for sending emails. you can use several drivers for sending email in laravel 9. you can use smtp, Mailgun, Postmark, Amazon SES, and send email. you have to configure on the env file what driver you want to use.

In this tutorial, I will give you step by step instructions to send emails in laravel 9. you can create blade file design and also with dynamic information for mail layout. so let's see step by step guide and send an email to your requirement.

[How to Send Email in Laravel 9 Example Tutorial](https://www.codecheef.org/article/how-to-send-email-in-laravel-9-example-tutorial)
Laravel Tips: hasMany Relationship
Tags: quicktips
Published: 2023-08-09 03:46:56

---
title: Laravel Tips: hasMany Relationship
published: true
date: 2022-02-27 07:45:27 UTC
tags: QuickTips
canonical_url: 
---

 **Laravel hasMany Relationship** - Dengan menggunakan eloquent pada laravel project, akan sangat membantu sekali dalam menghubungkan antara table A dengan table B, serta dapat mempersingkat penulisan code. Contohnya, jika kamu mempunyai table users yang berelasi dengan table posts.

```
Post::create([
  'user_id' => auth()->user()->id,
  'title' => request('title'),
  'body' => request('body'),
]);
```

Mungkin kamu biasanya menulis code seperti di atas untuk melakukan insert data ke table posts dengan value user\_id yang diambil dari id user yang melakukan action tersebut. Sebenarnya, ada cara penulisan code yang lebih sederhana untuk melakukan hal tersebut, yaitu menggunakan eloquent. Caranya dengan membuat relasi antar model terlebih dahulu seperti contoh di bawah ini.

**User.php**

```
public function posts()
{
    return $this->hasMany(Post::class);
}
```

kamu bisa membuat hasMany relationship pada User model seperti contoh di atas yang mengarah ke Post model.

**Post.php**

```
public function user()
{
    return $this->belongsTo(User::class);
}
```

dan menambahkan method user() yang berelasi dengan User model pada Post model seperti contoh code di atas.

```
auth()->user()->posts()->create([
  'title' => request('title'),
  'body' => request('body'),
]);
```

Nah, selanjutnya kamu hanya perlu menulis code seperti di atas untuk melakukan insert data ke table posts dengan value user\_id yang diambil dari id user yang melakukannya tersebut. Jauh lebih sederhana kan ?
My Second week in Taskforce 5.0 at Awesomity Lab and Code of Africa
Tags: awesomity, codeofafrica, taskforce, bestpractice
Published: 2022-02-27 07:34:00

Hello, everybody? I'm going to tell you about my second week in taskforce. This week was too long because we faced more challenges, but it ended with a smile on our faces because of the important lessons we learned.


![Git workflows](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/agzdgggaymeu05opdmkt.png)We learned the best practices for using [Git](https://en.wikipedia.org/wiki/Git). Before this lesson, I thought I knew it because I had used it for several days, but after digging deeper, I realized that my experience was only 40%.

We also learned how to collaborate on projects using [devOps](https://en.wikipedia.org/wiki/DevOps) tools, where the developer team and the operations team working together to implement a faster and easier way to build, test, and deploy software.

We had a presentation on Friday afternoon where we were supposed to use less than 5 minutes; this seemed impossible because we were a team of three members and we had to cover the lessons we learned throughout the week; the condition was to make it easily understandable because some of our audience were unfamiliar with the topic, so as a team we shared the idea of how the presentation would be made then we came up with a solution, this taught me to use a short time but deliver results.

During my two weeks on taskforce, I discovered that meeting with people who have experience in your field not only teaches you a new thing, but also teaches you the best way to apply what you know.
Laravel 9 Markdown Send Email using Markdown Mailables
Tags: laravel
Published: 2022-02-27 07:31:12

Hi Dev,

This article will give you example of laravel 9 send markdown mail. I would like to show you laravel 9 mail send markdown. We will use laravel 9 send email using markdown. it's a simple example of laravel 9 sending mail using mailable.

Laravel 9 Markdown provides inbuilt pre-define mail templates and components for email. you can use components for tables, email, links, buttons, embed images, etc.

In this tutorial, I will give you step by step instructions to send emails using markdown in laravel 9. so, just follow bellow few steps and make it done.

[Laravel 9 Markdown Send Email using Markdown Mailables](https://www.codecheef.org/article/laravel-9-markdown-send-email-using-markdown-mailables)
Build web scraper REST API using JAVA,SPRING BOOT, and JSOUP
Tags: java, springboot, tutorial, javascript
Published: 2022-02-27 07:30:05

Hello, Today we are going to build a web scraper. Although All of you know the term, I just want to tell you shortly what exactly web scraper?


Web scraping, also known as web harvesting or web data extraction, is a type of data scraping that is used to gather information from websites. Using the Hypertext Transfer Protocol or a web browser, web scraping software can directly access the World Wide Web.
In this project, We are going to use spring boot as a backend service and build a simple UI for the frontend part using HTML and CSS.


We will use the JSOUP library for extracting data from the websites. JSOUP is a Java library that allows you to interact with real-world HTML. It uses the finest of HTML5 DOM techniques and CSS selectors to create a very convenient API for requesting URLs, extracting, and modifying data.

I am sharing the original post to build your web scraper from scratch [live link](https://codesnipeet.com/how-to-build-a-web-scraper-in-java/)
Hope it helps!!!
Why You Should Start Using Listcomps in Python (Say no to map/filter)
Published: 2022-02-27 07:15:45

![Listcomps versus map/filter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fj3ptvmdjcams4j0ww3v.png)

Yesterday, I shared a quick [Python tip](https://dev.to/maupanelo/an-infographic-about-python-list-comprehensions-1k6c) about for-loops versus list comprehensions.

Today, I created another infographic about list comprehensions (listcomps). Listcomps provide a readable alternative to map/filter comprehensions. As you can see from the infographic, the listcomp syntax is shorter and easier to understand.

This syntax isn't limited to lists either.

## You can do dict and set comprehensions too

Here's a short example of a dict comprehension:
```python
country_codes = [
    ("United Kingdom", 44),
    ("United States", 1),
    ("Mexico", 52),
    ("Australia", 61),
]

code_to_country = {code: country for country, code in country_codes}
```

## The tools I use to create the infographic
- I use [Showcode](https://showcode.app/) to generate the code images
  - An alternative you can use https://carbon.now.sh/
- I stitch everything together using [Canva](https://www.canva.com/)
- I use the Dracula [color palette](https://github.com/dracula/dracula-theme)
- If you want to include free usable images, you can use [unsplash](https://unsplash.com/).

And that's it! I encourage you to start creating your own infographic!

---

Thanks for reading! Let me know if you have any feedback.
Going all in
Tags: discuss, personal, improvement, growth
Published: 2022-02-27 06:47:49

---
title: Going all in
published: true
description: Go all in!
tags: discuss, personal, improvement, growth
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a0b99wjmkqxhzbxq0foj.jpg
---

> Don’t expect much from x, if you’re just half-assing your commitment to it. Whatever the x may be. Go all in!

---

_Originally published on [my blog](https://www.nikola-breznjak.com/blog/daily-thoughts/going-all-in/)._

This is [why I write](https://www.nikola-breznjak.com/blog/daily-thoughts/why-do-i-write-these-daily-thoughts-posts/) these 'daily thoughts' posts.
Custom Parser for "pipe" Streams in NodeJS
Tags: node, javascript, efficency, programming
Published: 2022-02-27 05:48:22

This article will show a efficient way to modify data _while_ its being piped, say to a client in [Express](https://expressjs.com/).

Let's get started.

Take a normal [NodeJS](https://nodejs.org) server:
```javascript
const express = require('express');
const server = express();

const fs = require('fs')

server.get('/', (req, res) => {
   fs.createReadStream('/index.html').pipe(res);
});

server.listen(8080)
```

Here, we are using the `fs.createReadStream` function to pipe data without storing much in memory (RAM). This is completly fine. It's better than `fs.readFile`.

**The Problem:** If we want to dynamically make small edits to `index.html` based of say, the HTTP headers, this cute syntax doesn't have that functionality. Now, for anyone that has worked around `streams` in [NodeJS](https://nodejs.org/), they know that the `.pipe`s can be chained. One method that is not to different to the original code, we can use custom streams from the in-built `stream` module, and an awesome module called `new-line` from [NPM](https://npmjs.com/package/new-line).

This module only passes chunks of data to the next `pipe` only line by line. This means that it waits until it finds a `new-line`: `\n`. For example, if we have to replace "hello" with "world", we may get "he" in one chunk and "llo" in the next. This results in our function completely skipping the "hello".

Let's implement it:
```javascript
const newLineStream = require('new-line');

server.get('/', (req, res) => {
   fs.createReadStream('/index.html')
    .pipe(newLineStream())
    .pipe(res);
});
```

Now, the client gets data line by line. We're one step closer!

Time for the lengthy part. Lets implement our custom parser with the `Transform` class from the `stream` module.

```javascript
const newLineStream = require('new-line');
const { Transform } = require('stream');

class MyParser extends Transform {
   constructer() {
      super()
      this._transform = (chunk, encoding, cb) => {
         cb(null, chunk.toString().replace("hello", "world"))
      }
   }
}

server.get('/', (req, res) => {
   fs.createReadStream('/index.html')
    .pipe(newLineStream())
    .pipe(new MyParser())
    .pipe(res);
});
```

Lets break this down:

The `class`, `constructer`, and `super` just make a copy of the `Transform` class and load all the `Transform` functions. 

The `this._transform` is declaring `_transform` for our class because that's what `.pipe` uses for `_transform`ing the data.

The `chunk` parameter is the chunk of data that is of encoding specified by the `encoding` parameter. The `cb` parameter is a callback function. I pass `null` meaning that there is no error and the modified chunk data.

We can use this principle with chained `.replace`s and using the `g` flag with `RegExp` to manipulate data while keeping up our performance. After all, IO is the strong set of NodeJS.

That's it for this article. I hope this helped someone. I can be contacted at humanfriend22@gmail.com. Check out my [github](https://github.com/humanfriend22/) profile.
macOS Monterey DNS
Tags: monterey, macos, dns
Published: 2022-02-27 05:28:22

เข้าใจเสมอว่าแก้ DNS ของ macOS สามารถแก้ใน /etc/resolv.conf ได้เลย แต่ล่าสุดพบว่ามันไม่ได้ให้ความสำคัญแล้ว ถ้าให้ได้ผลต้องตั้งใน UI ให้เรียบร้อย แต่ถ้ายังอยากใช้ command line เราก็ยังใช้ได้ดังนี้

## ตรวจสอบอุปกรณ์

ก่อนที่เราจะตั้งต่าต้องรู้ก่อนว่าปัจจุบันเราต่อ network ผ่านอุปกรณ์ไหน และ มีอุปกรณ์อะไรบ้างในระบบ

```bash
networksetup -listallnetworkservices
```
ผลที่ได้จะประมาณนี้

```bash
Ethernet
USB 10/100/1000 LAN
Thunderbolt Bridge
Wi-Fi
```

## เรียกดูค่าปัจจุบัน

ถ้าต่อ WiFi ก็แสดงดังนี้

```bash
networksetup -getdnsservers Wi-Fi
```
หรือ ถ้าใช้สายแลน

```bash
networksetup -getdnsservers Ethernet
```
ผลที่ได้จะประมาณนี้

```bash
networksetup -getdnsservers Ethernet
10.222.21.14
10.222.21.15
10.18.12.222
10.18.12.223
```
## การตั้งค่า

หากต้องการล้มกระดานแล้วใช้ DNS ที่ต้องการตั้งครั้งนี้ก็ใช้คำสั่ง

```bash
networksetup -setdnsservers Ethernet 10.26.21.14 10.26.21.15
```

แต่ถ้าต้องการเพิ่มเข้าไปก็ให้ get ค่าเดิม แล้วต่อท้ายเข้าไป เช่น

```bash
networksetup -getdnsservers Ethernet
10.222.21.14
10.222.21.15

networksetup -setdnsservers Ethernet 10.222.21.14 10.222.21.15 10.18.12.222 10.18.12.223
```

หรือถ้าต้องการ clear ไปเลยก็

```bash
networksetup -setdnsservers Ethernet Emty
```

ลองเอาไปประยุกต์ใช้กันดูครับ
Generate Self-signed certificate
Published: 2022-02-27 04:40:08

---
title: Generate Self-signed certificate
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
---


#### Create a CA key
```
openssl genpkey -algorithm RSA -aes128 -out private-ca.key -outform PEM -pkeyopt rsa_keygen_bits:2048
```

#### Create a CA certificate
```
openssl req -x509 -new -nodes -sha256 -days 3650 -key private-ca.key -out self-signed-ca-cert.crt
```
#### Create a certificate key
```
openssl genpkey -algorithm RSA -out self.key -outform PEM -pkeyopt rsa_keygen_bits:2048
```

#### Create the self certificate request file
```
openssl req -new -key self.key -out self.csr
```

#### Sign Our CSR With Root CA 
##### Create a text file cert.ext
 
```
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names

[alt_names]
IP.1=192.168.100.14
DNS.1=localhost
```
#### Create the self certificate, signed from the root CA:
```
openssl x509 -req -in self.csr -CA self-signed-ca-cert.crt -CAkey private-ca.key -CAcreateserial -out self.crt -days 365 -sha256 -extfile cert.ext
```
Only Numbers validation in JS
Tags: javascript, beginners, codenewbie, regex
Published: 2022-02-27 04:30:12

```js
public numberOnlyValidation(event: any) {
    const pattern = /[0-9]/;
    let inputChar = String.fromCharCode(event.charCode);
    if (!pattern.test(inputChar)) {
        event.preventDefault();
    }
}
```