teleren/devto huggingface dataset:
Navigating the Depths of Log Analysis: Unleashing the Power of Lnav
Tags: logs, cli, systems, linux
Published: 2023-09-17 03:56:22

## Introduction

Navigating through log files can be quite cumbersome, particularly when you're unsure about what you're looking for. However, with the appropriate tools at your disposal, this process can become significantly more manageable. Before discovering Lnav, I relied on a variety of tools and a series of piped commands to extract the information I needed from logs. Lnav, on the other hand, is an all-encompassing tool that simplifies log navigation and greatly enhances efficiency.

## How to use Lnav:

### Start Lnav: 
To begin using Lnav, open your terminal and run the following command, replacing `logfile.log` with the path to your log file:
```bash
lnav logfile.log
```

### Basic Navigation:
Once you have your log file open in Lnav, you can navigate through the log entries using the following keys:

- `j` and `k` or arrow keys: Move up and down through the log entries.
- `Ctrl-u` and `Ctrl-d`: Scroll up and down one page at a time.
- `g`: Go to the beginning of the log file.
- `G`: Go to the end of the log file.
- `:q` : To quit Lnav, yes the same way you quit Vim.

### Goto:
The `goto` command in Lnav allows you to navigate log entries based on timestamps or line numbers.
Running goto is similar to running a command within Vim, where you essentially use '':'' followed by goto.

Let's jump to the examples:

**1. Jump to a Specific Timestamp:**
```bash
:goto 2023-09-15 15:30:00
```

**2. Navigate Relative to the Current Time:**
```bash
:goto 1 hour ago
```
Or
```bash
:goto 2 days ago
```
These relative time expressions are helpful for quickly reviewing recent log entries or identifying issues that occurred in the past.

**3. Go to a Specific Line Number:**

```bash
:goto 5000
```

**4. Find the First or Last Log Entry:**
```bash
:goto first
```

```bash
:goto last
```

**5. The Offset Keyword:**
You can also use the `offset` keyword with the `goto` command to move forward or backward by a specific number of log entries. For example:

To move forward by 100 log entries:

```bash
:goto offset 100
```

To move backward by 50 log entries:
```shell
:goto offset -50
```

### Searching and Filtering:
Lnav's search and filtering capabilities help you find specific log entries quickly:

- `/`: Start a text search. For example, `/error` will highlight all lines containing the word "error."
- `n` and `N`: Move to the next and previous search results.
- :filter-in: can be used the same way as a regular search, matches are highlighted in green in the text view.
```shell
:filter-in 404
```

## Conclusion:
In conclusion, Lnav's user-friendly interface, coupled with its rich feature set, positions it as an invaluable tool for log analysis and management. Whether you're an experienced system administrator or a developer seeking to streamline log-related tasks, Lnav's versatility and efficiency make it an essential addition to your toolkit.

To learn more about Lnav 
- [Features | The Logfile Navigator](https://lnav.org/features)
- [Welcome to lnav’s documentation!](https://docs.lnav.org/en/v0.11.2/index.html)
FUZZY FINDING YOUR BOOKMARKS
Tags: fzf, terminal, productivity, cli
Published: 2023-09-17 03:08:19

Have you ever felt overwhelmed by your bookmarks, desperately trying to find
that one elusive link? If so, you're not alone. Many people struggle to keep
their bookmarks organized and accessible.

Major browsers like Brave and Chrome offer a folder-based organization system,
which can quickly become unwieldy. Even when resorting to searching through
browser-specific URLs like `brave://bookmarks/?q=<your keyword>`, it often falls
short because you may not remember the exact title or link.

## Bookmark's data structure

At its core, a bookmark is quite straightforward. It consists of three elements:
a title, a link to the webpage, and the action of opening that link. Here's a
simple breakdown:

- Title: The name you've given to the bookmark (e.g., Google).
- Link: The web address associated with the bookmark (e.g., http://google.com).
- Open action: The action you want to perform when you click on the bookmark,
  which is usually to open the link.

## Why not store your bookmarks in a text file instead ?

This may seem like a simple solution, but it offers several advantages over
traditional bookmark managers:

- **Simplified Search**: It's much easier to search a text file for a specific
  keyword than it is to search through a tree-like structure like a folder
  hierarchy. You can use a variety of tools to search and filter your bookmarks,
  including regular expressions and fuzzy search.
- **Version control**: A text file can be easily tracked by version control.
  This means that you can easily recover your bookmarks if something goes wrong,
  or if you want to revert to a previous version.
- **Direct Editing in Your Editor**: You can modify your bookmarks directly in
  your text editor, such as Vim. This makes it incredibly convenient to update
  and organize your bookmarks with the tools you are already familiar with.
- **Fuzzy Finding for Titles and Links**: With this method, you can search for
  your bookmarks using either the title or the link. This is a significant
  improvement over traditional bookmark managers, which typically only allow you
  to search by title.

Here's a simple representation of how it looks:

```txt
Google |https://google.com
Youtube |https://youtube.com
```

We use the pipe character (`|`) as our delimiter because it's not part of URI standards (RFC 3986). Thus, it doesn't clash with bookmark titles or URLs, and improves readability. While it's not an official URI standard delimiter, its adoption in this context is a convention that enhances bookmark management.


By storing this content in a file `$HOME/.bookmarks`, you gain the ability to
track and search for bookmarks by title or link. Additionally, macOS supports
opening links in your default browser by default. And to make things even
simpler, you can achieve all this with a single-line solution:

```sh
alias bm="cat ~/.bookmarks |fzf | cut -d '|' -f 2 | awk '{\$1=\$1;print}' |xargs open"
```

If you need a practical solution for better bookmark management, give it a try.
91 berufliches Vorwärtskommen: Geld allein ist nicht alles.
Tags: deutsch, career, motivation, discuss
Published: 2023-09-17 03:30:00

Moin Moin,

wir sprachen ja bereits über [den Elefanten im Raum Deutschland – Geld→](https://dev.to/amustafa16421/88-berufliches-vorwartskommen-geld-ein-elefant-im-raum-deutschland-3em4). Es stellt sich die Frage, ob auf Grund dieser weitverbreiteten Ansicht, auch der Spruch „Geld allein ist nicht alles“ ebenfalls weitverbreitet ist, bzw. ob die eine Ansicht, die andere fördert. Wenn wir uns mal vor Augen führen würden wie viel Zeit wir in einer gewöhnlichen Woche mit Geld verbringen, so scheint es mir, sähen die meisten von uns, dass „Geld“ einen der oberen Plätze in ihrer Zeitaufwandsliste belegen würde (1). Vielleicht möchte jemand mal genauer nachrechnen…

Abgesehen davon verbringen wir auch viel Zeit mit den Tätigkeiten für die wir Geld verlangen und den Menschen mit denen wir diese Tätigkeiten ausüben. Also Geld, Tätigkeit, Menschen. Ich lenke das Augenmerk bewusst auf diese drei, denn ich denke es braucht unter anderem gute Menschen, eine gute Tätigkeit und eine gute Bezahlung als Grundlage, um dem was „alles“ ist näher zu kommen.

1) Wie wichtig ist dir Geld im Bezug auf Karriere und Beruf?
2) Hast du schon mal ein Unternehmen verlassen aufgrund der Arbeitskollegen oder der Tätigkeit?


Lass uns mittels Kommentaren austauschen.

Beste Grüße,
Mustafa

Oder auch mittels E-Mail: mustafa.kevin.dwenger@posteo.de
Betreff: Austausch

(1) absteigend sortiert ;-)
Balancing the Art of Clean Code and Meeting Deadlines in Software Development
Tags: cleancode, react, softwaredevelopment, nextjs
Published: 2023-09-17 03:28:29

Clean code, much like a beautifully maintained garden, is a testament to a developer's commitment, determination, and effort. It's an ideal we all strive for, but the reality of deadlines often forces us to navigate a delicate balance between code cleanliness and project timelines. In this blog, we explore the challenges and strategies for harmonizing these two critical aspects of software development.

1. **Deadlines First - The Crucial Trade-off:** There are instances when the pressure to meet a project deadline becomes paramount. During such moments, the primary focus shifts from pristine code to code functionality. It's a challenging scenario, but sometimes, it's the reality we face.

2. **Extra Effort Required:** Striking a balance between clean code and tight deadlines demands going the extra mile. It necessitates putting in additional effort to ensure that your code is not only functional but also maintainable. While it may require more time upfront, the long-term benefits are invaluable.

3. **The "After It Works" Mindset:** It's a common pitfall among developers to defer code cleanup until later, once it works. Unfortunately, in the fast-paced world of software development, 'later' often never arrives. New projects continually demand attention, leaving behind a trail of less-than-ideal code. Commitment is the solution; allocate time to refactor and enhance your codebase regularly.

4. **The Stress of Clean Code:** Writing clean code can be an arduous task, particularly for those unaccustomed to it. The added stress of incorporating comments, using descriptive variable names, and adhering to best practices can be daunting. However, it's a skill worth cultivating as it ultimately leads to more efficient, maintainable, and high-quality code.

**Conclusion:** The Art of Balancing Balancing clean code and meeting deadlines is an art form. It requires unwavering determination, effort, and a commitment to excellence. While deadlines are pivotal in the software development landscape, it's essential to remember that clean code pays dividends in the long run. It simplifies maintenance, reduces technical debt, and enhances the overall quality of your work.

In the dynamic world of software development, the ability to navigate the fine line between these two facets is a valuable skill. By acknowledging the challenges and adopting strategies to address them, developers can achieve the delicate equilibrium of delivering both clean code and meeting project deadlines effectively.

> _“Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control.”_
_ **Robert C. Martin**_

[LinkedIn](https://www.linkedin.com/posts/adefam_balancing-clean-code-and-deadlines-in-activity-7109009946184200192-xwAO?utm_source=share&utm_medium=member_desktop)
[Portfolio](http://adegbitefamosa.com.ng/)
How to get logged User in Next.js app directly in Redux store? Example using iron-session
Tags: ironsession, nextjs, redux, react
Published: 2023-09-17 03:19:24

---
title: How to get logged User in Next.js app directly in Redux store? Example using iron-session
published: true
description: 
tags: ironsession, nextjs, redux, react 
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qzli7ox3pkmjy536uzi5.jpg
# Use a ratio of 100:42 for best results.
---

I am trying to find a simple way to pass stateless session data (**iron-session/JWT**) to `redux` store. There is a lot of solutions out there, but all of them do extra request. Obviously, decryption of cookie takes place on server side thus we can use it to pass the `user` data as initial state. Here is my attempt:

```typescript
// _app.tsx
function MyApp({
  Component,
  pageProps
}: AppProps
) {
  store.dispatch(update(pageProps.user));

  return (
    <Provider store={store}>
      <Component {...pageProps} />
    </Provider>
  );
}

MyApp.getInitialProps = async function (appContext: AppContext) {
  const req = appContext.ctx.req
  const res = appContext.ctx.res;
  const session = await getIronSession(req, res, sessionOptions);

  return {
    pageProps: {
      user: session.user
    },
  }
}

export default MyApp;
```
Of course, using `getInitialProps` on `_app.tsx` block Next to do any static site generation, but that is not the crucial part for me.

We need to handle also the logging process on client side. 
To make request, I use great [react-toolkit queries](https://redux-toolkit.js.org/rtk-query/overview), however to fill the same "redux slice" as on server side we will need to use some extra code.
Following, is my React hook, which basically pass the user data from "RTQ store" to defined and fully controlled Redux slice.

```typescript
import { update } from "../../store/features/userSlice";

export function useLogIn() {
  const [
    login, {
      // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
      data,
      isLoading,
      isSuccess,
      isError
    }
  ] = useLoginMutation();

  const dispatch = useDispatch();

  useEffect(() => {
    if (data?.user) {
      dispatch(update(data?.user));
    }
  }, [ data ]);

  return {
    login,
    isLoading,
    isSuccess,
    isError,
  } as const;
}
```

and the log-in usage:

```typescript

  const { login, isLoading, error, isError, isSuccess, isUninitialized } = useLogIn();
```

retrieving the data:
```typescript
  const user = useSelector(selectUser);
```

... and that is all folks!

PS. I might over-engineered it, let me know if there is simpler way.
Stable Audio
Tags: ai, beginners, web3
Published: 2023-09-17 02:34:50

[Stable Audio](https://www.stableaudioweb.com/) is Stability AI’s first product for music and sound effect generation. Users can create original audio by entering a text prompt and a duration, generating audio in high-quality, 44.1 kHz stereo. It uses a latent diffusion for audio model, trained on data from AudioSparx, a leading music library.
Navigating the HNG Odyssey: Triumphs, Trials, and Transformations in a Virtual Landscape
Tags: hnginternship, productivity, learning, motivation
Published: 2023-09-17 01:26:11


I am embarking on a unique 10-stage journey through the HNG internship, with each stage representing progress, growth, and transformation. As I navigate through Stage 3, the virtual learning experience feels real and tangible. Join me as I recount my milestones and experiences on this digital odyssey.

I have completed two projects so far, and I am thrilled with my progress. I have demonstrated discipline, adaptability, and zeal, and the sense of accomplishment is amplified by the fact that I finished before the deadline.

The HNG digital world is not only about codes and screens, but also about interactions, mutual support, and shared triumphs. My fellow interns have been pillars of encouragement and sources of insight.

Moving from one stage to the next represents the transformation that comes with each step. I am growing, adapting, and evolving both as a coder and as an individual.

Mastering virtual communication requires patience and precision. There may be occasional miscommunications, fleeting moments of disconnect, or a lack of in-person interactions.

Working from home, while a boon in a virtual internship, can also be a battlefield of distractions. Staying focused becomes the sword to ward off interruptions.

As I advance through each stage, the challenges become larger, and the waters seem deeper. The mix of excitement and apprehension keeps me eager yet cautious about what lies ahead.

Balancing a full-time job alongside the HNG internship feels like a dance on a tightrope. Every step must be measured, and every move calculated.

Three stages deep into the HNG internship, and I am already filled with learning, reflections, and personal growth. I look forward to Stage 4 and beyond, feeling eager and prepared for the adventures and challenges that the next chapter promises.
Java remote debugging (IntelliJ + Docker)
Tags: java, docker, programming
Published: 2023-09-17 01:25:54

If you ever need to debug a running application inside a docker container, I'm here to help you!

---

### Youtube video

If you prefer a practical example, I create this video to help: 

{% embed https://www.youtube.com/watch?v=Aam-XZbIuJ4 %}

> In this article we're going to use IntelliJ IDE as the debugger connector.

---

### JDWP

To enable a debug port in the application, we're going to use the **Java Debug Wire Protocol (JDWP)** that is the communication  between our IntelliJ and the JVM running inside the docker container.

---

### Solution


> The JDWP command below will work only for Java version **9+**. For other versions, check the links in the end of the article.


In the command we need to set the port that will enable the debug. In this example we're using the **8000**.

Using the docker scenario, lets put the JDWP command inside a **.sh** file:

{% embed https://gist.github.com/ArturoBatistute/12323321bc559cc639ae991208254bb3 %}



> In the JDWP command we use the the app .jar file, so don't forget to add the right .jar name here!
You can generate the .jar file using the **mvn package** command for example. See the link for examples: https://www.baeldung.com/java-create-jar

Call the .sh file from the docker file:

{% embed https://gist.github.com/ArturoBatistute/aaac9d84d27b1a8effc7caad8b7048dc %}


Create a docker image from the app and run a container exposing the desired ports for your application and don't forget to expose the debugger port **8000**.

`docker build -t java-docker:1.0 . `
`docker run -d -p 8080:8080 -p 8000:8000 java-docker:1.0`

---

#### IntelliJ

In the IDE, add a new debugger configuration. In the **Run/Debug configurations** add a **Remote JVM Debug**:

![IntelliJ IDE image of the run/debug configurations with the Remote JVM debug option](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c6g4b9vfpqfl249j66sl.png)

Set host and the debugger port:


![IntelliJ IDE image showing where to put the host and the port](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ott1re9yd0bqdyqilmxu.png)

All done, now you can click in the debug button and see the magic happen.

Any problems or suggestions, feel free to get in touch.

All the best!


Links:

https://docs.oracle.com/en/java/javase/17/docs/specs/jdwp/jdwp-spec.html

https://www.baeldung.com/java-application-remote-debugging
Optimise OpenAI Whisper API: Audio Format, Sampling Rate and Quality
Tags: openai, whisper, programming, audio
Published: 2023-09-17 00:47:40


While experimenting with OpenAI's Whisper model via API, I discovered it could sometimes seem slow when recognising vocal commands sent from [a tool I have developed](https://github.com/mxro/autohotkey-chatgpt-voice). I originally put this down to the inherent constraints of using this API, attributing it to the size of the data needing to be sent to the server - in this instance, somewhat large audio files.

However, tinkering with the format of the audio files sent to OpenAI led me to discover that response times could be optimised considerably - by over 50%, in fact. The main culprit for lag was the file size I sent through the API; i.e., the recordings requiring transcription.

By adjusting the sampling rate and quality of the content I sent to the OpenAI API, I managed to cut the file size significantly.

## tldr;

It seems you can reduce latency considerably by lowering quality settings without detriment to transcription precision. Here are the settings I suggest:

- **Format**: MP3
- **Bit Rate**: 16 kbps
- **Sample Rate**: 12 kHz
- **Channels**: mono

## Experiment!

I conducted a series of tests, each time recording the same command, 'Open Firefox'. The table below shows the correlated file sizes once I adjusted MP3 quality from 16 kbps through to 128 kbps and switched the sampling rate from 12k to 24k.

![Recording Sizes](https://maxrohde.com/_goldstack/static/img/attachments/2023/09/17/optimise-openai-whisper-api-sampling-rate-quality/Pasted%20image%2020230917084039.png)

(Note: most microphones sample at 16 kHz)

I generated these recordings using [fmedia](https://stsaz.github.io/fmedia/) with variations of the following command:

```
./bin/fmedia-1.31-windows-x64/fmedia/fmedia.exe --record --overwrite --mpeg-q-mpeg-quality=16 --rate=24000 --out=rec_16_24k.mp3
```

The results for transcription and GPT4 parsing times are as follows:


| File | Size | Time |
|-|-|-|
| rec_16_12k.mp3 | 5KB | 1.8 s |
| rec_32_12k.mp3 | 9KB | 1.8 s |
| rec_128_24k.mp3 | 33KB | 2.6 s |

I obtained these measurements via this command:

```
time ./bin/whisper-autohotkey/whisper-autohotkey.exe rec_16_24k.mp3
```

Regardless of the quality settings, the accuracy of transcription did not vary.

## Conclusion

Even though my experiments are not perfect - Whisper and ChatGPT APIs are, after all, [notoriously unpredictable for consumer grade accounts](https://community.openai.com/t/openai-why-are-the-api-calls-so-slow-when-will-it-be-fixed/148339) - the results suggest that reducing audio recording quality sent to Whisper's API can cut latency significantly without sacrificing transcription accuracy.

There seems to be little to no advantage in reducing the quality below 32 kbps and 12 kHz, possibly because of the characteristics of MP3 compression.
Who wants to be a Millionaire? - Basic Starter Game
Published: 2023-09-17 00:35:32

Hey everyone, 

I created a basic starter game based off the game show "Who wants to be a millionaire?" for my python project to finish off the course on Codeacademy. 

I went with this because it seemed fun to do while at the same time it felt like a good way to utilize a lot of the crucial parts that were taught throughout the course. 

The game only has a total of 15 questions and shows the value of each question just like the game show. 

Here is a link for for my code in 
github: 
https://github.com/jmgarci9/Questions/blob/main/Increase%20Space%20under%20Money%20class


As you'll see I created a class for the questions, as well as  seperate classes for the different answer options, the answer input and the level value for each question. After all the classes section,  I created a while loop that loops 15 times or less based off the 15 questions that are inserted into the code. 

Inside the loop, a random number generator was created from 1 to 15 to randomly select one of the 15 questions from the code. That's where I also call all of the classes starting with the money class to display the value of the question. Then calling the Question class, followed by the AnswerChoices class. And last the code for the input from the user which is used for an argument within the the PlayerAnswer class. 


All questions and answers in the classes used a dictionary to store the information and pull out the information. The count variable towards the end of the code is used to determine what level of question the user is on and used only for Money Class to indicate the value of the question. 

In conclusion, even though the python project could be created in any way, my main focus was to used a lot of classes depicting the necessary portions for each code. That way it could become easier to understand for the code user.
Facebook API integration
Tags: facebook, php
Published: 2023-09-17 00:16:51

I want to use facebook api to get clients information such as profile, photo, hightlights, followers, posts and comments from my site.
I'll use PHP/Laravel to implement that, input username of facebook and get data with that name.
The purpose of this site is see facebook profile without signin.
Is this possible?
If so, I want your help!
I want to build this site and if you help, I'll pay you.
This is my telegram id.
hades255
Let's build my site together!
Thanks.