teleren/devto huggingface dataset:
Recovering Symfony 1.* API docs with Wayback Machine
Published: 2020-03-30 20:44:28

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

Unfortunately some of us still have to support complex legacy apps that are running a business. 

If your legacy project is running on Symfony 1.* then you should know (or you know already) that documentation for Symfony 1.* API is gone. It was available here http://www.symfony-project.org/api/ but it’s currently redirecting to the legacy documentation, not the API.

The API documentation was a developer savior, because you no more can find a useful information in the internet for the 1.* version.  

The solution is Wayback Machine! 
There are many snapshots when you go to https://web.archive.org and search for 'http://www.symfony-project.org/api/'. 

Also you can scrape content from Wayback Machine using tool - https://github.com/hartator/wayback-machine-downloader

For 1_4 version I have already downloaded and uploaded pages to github - https://github.com/c0d3b0t/symfony_1_4_api_docs
You can download and run it on some web server, or simply run it with `php -S localhost:8000`

Happy coding! And always Upgrade! :)
Do You Want to Learn How I Built my Website from Scratch? 🛠 
Tags: webdev, design
Published: 2020-03-30 20:41:37

It happened to me, too. Two weeks ago, I accidentally deleted the directory that contained all of the files of [francoscarpa.com](https://francoscarpa.com), my website. How? Using [Eleventy](https://www.11ty.dev/), I ran the `rm -r _site/` command, while I wanted to run the `rm -r source/` one to compile the source directory (this was the [sad post I wrote](https://twitter.com/franco_scarpa92/status/1236235937841115137?s=20) of that tragic day). Having made no backup copy, I was screwed. There was only one thing left for me to do: start over. This event, however, was not entirely a disaster; on the contrary: it gave me the chance to build a new version of the site, a version I really like.

I have always been proud of my website, in all of its multiple versions. At the same time, I tend to get soon tired to see again and again the same layout, even when I spent hours working on it. I’m not talking about content, which, of course, must be updated continuously. I’m talking about changes to aesthetics: layout, fonts, color palette, etc. This time I can say that the appearance of the new francoscarpa.com site has come to a version that I can consider stable.

So, I’d like to take this opportunity to inaugurate a series of articles that describe my whole website: from structure to functionality! I really wanted to do such a thing. Before embarking on this adventure, however, you wanted to have feedbacks from other web enthusiasts like me. Each article could take me a fair amount of time due to my perfection craze, so I’d like to have opinions from other web developers.

In the case of positive feedback, several exciting chapters await you, among which I will touch topics like:

- layout;
- typography;
- offline behaviour;
- color palette.

The dev.to site seems to be a place full of people who love to learn, study, give ideas, advise, and instruct. Therefore, it appears to be a great place to try to gather feedback before embarking on this new adventure! Let me know what you think and I encourage you to share this post so I get more feedback!
Setting up Storybook for Preact with TypeScript
Tags: preact, typescript, storybook
Published: 2020-03-30 20:22:36

---
title: Setting up Storybook for Preact with TypeScript
published: true
date: 2020-03-30 20:21:00 UTC
tags: preact, typescript, storybook
canonical_url: https://www.emgoto.com/preact-typescript-storybook/
cover_image: https://www.emgoto.com/preact-typescript-storybook-dev.png/
---

[Storybook](https://storybook.js.org/) is a useful tool for visualising what your app's front-end components will look like across different scenarios. 

This guide will cover how you can add Storybook to your TypeScript Preact app. 

## Creating a Preact app using TypeScript

If you don't already have a Preact app using TypeScript, you can easily create one using the [preact-cli](https://github.com/preactjs/preact-cli) tool:

```bash
npm install -g preact-cli
preact create typescript app-name-here
```

Remember to `cd` into your app's folder after you've created it!

## Installing and setting up Storybook
Install Storybook for Preact:

```bash
npm install @storybook/preact --save-dev
```

Then create a `.storybook/main.js` file, and add the following:

```js
module.exports = {
    stories: ['../src/**/story.tsx'],
    webpackFinal: async config => {
        config.module.rules.push({
            test: /\.(ts|tsx)$/,
            use: [{
                loader: require.resolve('ts-loader'),
            }],
    });
    config.resolve.extensions.push('.ts', '.tsx');
    return config;
    },
};
```

> Note that you will have to modify the above code if you are not using `ts-loader`

Then you can add a new script to your `package.json` file:

```json
"scripts": {
    "storybook": "start-storybook"
}
```

## (Optional) delete the declaration.d.ts file

If you created your app using the preact-cli tool, I found that deleting the `declaration.d.ts` file in your `src` folder was required to get Storybook working. I'm not too sure why, but give it a go if things are breaking for you.

## Write your first story

Create a file called `story.tsx` and import in one of your components:

```jsx
import { h } from 'preact';
import Component from './index';

export default { title: 'Component' }

export const coolComponent = () => <Component/>;
```

Now if you run the command:

```bash
npm run storybook
```

You will be able to see your storybooks in action.

Happy coding!

## References

[Storybook for Preact](https://storybook.js.org/docs/guides/guide-preact/)
Welcoming Arit Amana to the DEV Team ✨
Tags: meta
Published: 2020-03-30 20:10:30

---
title: Welcoming Arit Amana to the DEV Team ✨
published: true
description: 
tags: meta
cover_image: https://thepracticaldev.s3.amazonaws.com/i/97a2sge9bgapcn6szuep.png
---

We are so excited to welcome Arit to the DEV team! She is joining us as an Associate Software Engineer, and will be focusing on the support and moderation tools that keep DEV the constructive community we strive to be.

Arit has been a big part of the community since 2018, both on the platform and in our codebase. She has over 35 published posts and has left comments on hundreds more. To get to know Arit and why she's excited to join DEV, check out her post:

{% link https://dev.to/msarit/somebody-pinch-me-i-m-joining-dev-93d %}


![welcome-baby-gif](https://media.giphy.com/media/h4gD4ZcfBZcJ9NjkSg/giphy.gif)

Please give Arit a warm welcome!
Do you have a remote work, or remote co-working space horror story to tell? Call us with your answer!
Tags: discuss
Published: 2020-03-30 20:08:54

---
title: Do you have a remote work, or remote co-working space horror story to tell? Call us with your answer!
published: true
description: 
tags: discuss
---

DEV is in the process of launching a podcast and we'd love for you to be involved! We're recording most of the episodes in advance, and this week we'd like to know: 

“Do you have a remote work, or remote co-working space horror story to tell?”

If you'd like to participate, please :

- Call our Google Voice at +1 (929)500-1513 and leave a message 📞
- Send a voice memo to pod@dev.to 🎙
- OR, if you don't want your voice recorded...just leave a comment here and we'll read it aloud for you 🗣

Thank you!
Somebody pinch me - I'm joining DEV! 🎉
Tags: womenintech, webdev
Published: 2020-03-30 20:08:06

A dream I didn't even know I had has come true: I'm joining the DEV team as an Associate Software Engineer! 💃🏾

DEV has played a special, significant role in my journey breaking into Tech. After my bootcamp, I sought to continue developing with other engineers (just like I had during bootcamp). So I decided to [join an opensource project](https://dev.to/msarit/my-first-frustration-free-opensource-pull-request--3ni4) with Rails as part of their stack. DEV's was the only opensource project that I managed to successfully configure on my local machine. Their code community warmly welcomed my PR contributions.

I switched my blogging platform from Medium to DEV, and later ran an engaging DEV Ask-Me-Anything about my developer journey. That's when I experienced DEV's rich, diverse, respectful and empowering community.

{% link https://dev.to/msarit/i-switched-careers-to-software-engineering-in-my-late-30s-while-nursing-a-newborn-ask-me-anything-1bbe %}

When DEV asked me to be one of their community moderators, I got to know some of their core and auxiliary team members. I later applied to my current position, and in full transparency, didn't expect to get far in the process (that's how intimidated I was by their talent). So yes, I was BLOWN to receive their offer.

I'm so excited to seriously level up - as much in humility and empathy as in technical prowess, to serve the DEV community, and to further DEV's purpose however I'm graced to.

Thanks for reading! 😃
App don't work on Emulator.
Tags: app, problem, emulator, android
Published: 2020-03-30 20:04:43

Hi guys, I have the following problem. I have a mobile app, developed in React-Native. The app works on my Moto S5 Plus cell phone, but when I try to test in the emulator the app opens and closes automatically.
I don't know if you keep any error logs, if you can help me I will be very grateful with you.
Regards.
Javier.
Settings kvm
Tags: android, sdk, avd, emulator
Published: 2020-03-30 19:59:56

---
title: Settings kvm
published: true
description: Settings emulator
tags: Android,SDK, AVD, Emulator
---

kvm-ok enter

``INFO: /dev/kvm does not exist
HINT:   sudo modprobe kvm_intel
INFO: For more detailed results, you should run this as root``

``sudo modprobe kvm_intel``

To create directory /dev/kvm to settings and run emulator AVD to Android
Steps of Codeigniter Processing
Tags: codeigniter, backend, php, tips
Published: 2020-03-30 19:44:22

The designing of the MVC based Codeigniter has enabled it to have a fast performance. It is possible thanks to the simplicity of the framework. And to go further into explanation, it has component singularity, dynamic installation and loose coupling.
As you have a glance at the model,the data flow seems simple indeed.
1.index.php is your php file that comes as default.In fact, php is the most widespread of all the backend languages, which helps developing e-commerce(online purchases, [loans](shinyloans.com), etc.) and social media platforms.
2.<b>Router</b> decides the steps of document manipulation.
3.<b>Cache</b> file is the previously loaded info from the same source. When caching is enabled, there might be no need for further data loading.
4.If it's the time to pass to Application Controller, a security check is a must.
5.The last of the redirection process is the View. After the data goes through view it appears back in cache and then in your browser page.
The broadest of the components is the application controller, which includes scripts,helpers, libraries and plugins.
Two Sum Problem
Tags: codenewbie, career, interview, beginners
Published: 2020-03-30 19:43:57

Here is a classic problem that has been given on plenty of interviews.

__Given an array of integers, return indices of the two numbers such that they add up to a specific target.__

__You may assume that each input would have exactly one solution, and you may not use the same element twice.
Given nums = [2, 7, 11, 15], target = 9,__

__Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].__

Now there are a couple of ways to solve this problem. The first way you might think is to look at it and approach it through a brute force method.

##Brute Force Method 👊
I see that I need two different indexes so I could use two for loops and propagate through this list comparing every possible combination to see if I have a pair that hits the target.

{% gist https://gist.github.com/austinmsuarez/8ea8e7d3ac0968f69f4f7294c129cbc9 %} 

Code for two for loops a brute force method to solve this problem
In this scenario, we are going to loop through the array with both for loops allowing you to compare every single possible combination. This is obviously not the most efficient way as it will yield a big O of (n²) due to both for loops. In the event that there is a long list of numbers it can be less likely that your code will pass in the given time it needs.

##Dictionary Approach:
Now looking at how to better improve this solution there is one data structure called a dictionary that will definitely assist us. A dictionary makes use of a key-value pair, this is can be extremely useful given that the search of a Dictionary is big o(1).

{% gist https://gist.github.com/austinmsuarez/af3424417af9d240bdaa931923f4a811 %}

Code for two sum problem dictionary creation then search for pair
Here we are building a dictionary with the key being the number and the value being the index the number exists. Creating a dictionary allows us to search for the value as we go. In our next for loop as we search for the other number to complete the sum that hits the target we only have to iterate through the array ones at a time giving us a big-O (n). That being said all though we were able to reduce the big-O in time by not using a double for loop we increased the space complexity from the creation of the dictionary.

##Better Dictionary Approach:
Now how can we make this a bit more efficient? Well, we can remove the need to have a separate loop for creating the dictionary by using a if-else block.

{% gist https://gist.github.com/austinmsuarez/efa1d2c799ebcea9aa134bd6bafa7a4c %}

Code for two sum problem dictionary creation and search for pair
Hope you liked this post, please follow and clap for more! 🙃
Local Storage (and JWT)! Browser Storage Part 3
Tags: rails, beginners, ruby, react
Published: 2020-03-30 19:39:25

This is part 3 of my browser storage series, so please take a look at part 1 and 2 if you have not seen them yet! 

As covered earlier in the series, local storage is a way to store information about a user. The information is stored in the user's browser storage on their computer. Local storage differs from cookies by not being sent in the HTTP request. Instead, the frontend can request it by calling on the localStorage object, which is a child of the window. I've written out what the basic local storage methods are in javascript:

```Javascript
localStorage.setItem('currentUser', 'Dawn');
var user = localStorage.getItem('currentUser');
localStorage.removeItem('currentUser');

```

With just setItem, getItem and removeItem, you can save information about a user that will persist between sessions. A user can come back the next day, and anything saved by that site in the local storage will remain. This is incredibly useful for staying logged in. It moves the burden of holding the information about the user's session from the backend and server, to the local storage. This can work because instead of the user holding onto a session id, they hold all the information that authorizes them to be using the site. This means that there doesn't need to be a look up of the user for every new http request sent.

Can't a user just fake this information?

They could, but that's where signatures come in. We can use JWT (json web tokens) to include a signature from our server based on a secret that only our servers know. This signature is stored in the JWT in the local storage, and can be accessed, sent to the server, and verified without any database calls. The server knows that unless someone else has the secret, the JWT is accurate and this user has certain authorizations. 

Using local storage can be faster than using cookies. Not only does it not need a sessions database, but it also works on different servers. If all of your servers have the same secret, then they can all authorize the user for access of all the other servers. This is especially useful for large, distributed sites, as well as sites with multiple services, such as a bank.

To learn more about JWT, [JWT.io](JWT.io) is the perfect site. Additionally, here is a [walkthrough](https://levelup.gitconnected.com/jwt-auth-in-a-react-rails-app-8a7e6ba1ac0) on how to implement this yourself in a rails and react environment.
Developer Collaborative Project Platform
Tags: webdev, discuss, beginners
Published: 2020-03-30 19:35:06

https://sketch.cloud/s/gRDWM/a/n2Lv10/play

I'm working on creating a developer collaborative project platform. The value created is inexperienced devs (project seekers) are able to work on real-life projects to gain experience, while experienced devs (project creators) are able to bring their passion projects to life with a team.

I've created four different business model prototypes around this idea. In the link, there are four different homepages for each one. Looking forward to any feedback from the community. Thanks!
Optimal way to store/consume scheduled/recurring events
Tags: discuss
Published: 2020-03-30 19:32:20

I am working on best way to store the scheduled and recurring events. I am taking inspiration from here - https://github.com/bmoeskau/Extensible/blob/master/recurrence-overview.md.

I will be storing any events as RRule(iCal Events - **https://tools.ietf.org/html/rfc5545**) and duration of the event as separate properties. 
The structure will look like this. 
```
class Schedule {
    String rRule; //Varchar
    String startTime; //DateTime
    String endTime; //DateTime
} 
```

With this structure the clients can show the events on calendar without querying the API.

It gets interesting when the events can be modified.
For Ex: Schedule = 'Daily at 10:00, duration 2 Hours' creates an event for everyday. But the user can modify(disable) any particular event. and this change should be stored. For this the above article suggests to use `EventException`(https://github.com/bmoeskau/Extensible/blob/master/recurrence-overview.md#eventexception)  where the modified events are stored.

But in my use case I want to store if the event was successfully completed. (I can mitigate this by saying any event by default is successful, if there was some modification I store it in `EventException` and need to be fetched from here) 


----------
So I would like your opinion if this is the best way to do it? Did you have similar experience and how it was solved.
I am working on it to design a solution which reduces the work for both frontend and backend.

Also is it wise to store the RRule as a separate entity instead of a string?
# of ways to loop Array in JavaScipt
Tags: javascript, node
Published: 2020-03-30 18:29:24

Hello, World!
Here is a challenge, tell me the no of ways in which we can loop over the given arrays below?
```
//Array one

let letters = ['j','a','v','a','s','c','r','i','p','t']

//Array Two

let javaScipt = [
 {
   name:'Angular',
   by:'Google'
 },
 {
   name:'React',
   by:'Facebook'
 },
 {
   name:'Vue',
   by:'Evan'
 }
]
```
You Need to Know About Git Worktree
Tags: git, tips
Published: 2020-04-04 19:51:08

---
title: You Need to Know About Git Worktree
published: true
date: 2020-03-30 18:24:06 UTC
tags: git,tips
canonical_url: http://blog.jonstodle.com/you-need-to-know-about-git-worktree/
---

I’ve been using Git for source control for many years, but there’s still lots of things you can do in Git that I haven’t even discovered yet. `git-worktree` was one of those things. Thanks to [codingblocks.net](https://www.codingblocks.net/) for mentioning this in one of their episodes.

# The problem

I often find it’s useful to explain the problem before describing the solution; so here goes:

If you are working in a team or on an open source project with multiple contributers, you might get the need to check out another branch. This is easily done, but it becomes a bit of a hassle if you have a lot of uncomitted changes. You could put all those changes in a stash, but then you usually end up with a huge pile of stashes over time because you never take the time to clean up. What you really want is the ability to check out two (or maybe more) branches at the same time.

# The solution

**Enter git-worktree!**

With this simple command you’ll be able to check out a different branch in your repository, in a seperate directory. It looks like and is used like a regular git repository, but it allows you to have multiple active working trees in the same repository at the same time. Here’s how to get going:

```
git worktree add ../another-directory

```

This will create a new worktree in `another-directory`, which is a sibling of the current directory. At the same time it will also create a new branch with the same name as the directory.

If you’d like to specify the branch name, you can use the `-b <branch-name>` option:

```
git worktree add -b new-branch ../another-directory

```

It’s also easy to check out an existing branch in the new directory by specifying the name of the branch:

```
git worktree add ../another-directory existing-branch

```

In this case `existing-branch` already exists in the repository. You can actually specify anything _commit-ish_ (as it’s called in the documentation) as the last argument, be that a branch name or a commit hash for example.

If you want to remove the worktree you call… eh, remove:

```
git worktree remove ../another-directory

```

All your commited changes will be present in the main repository, as if you had done the work there.

* * *

For me, this has been a life saver in hassle when checking out branches for code review, or for doing a quick fix on a branch that’s been reviewed. Hope it helps you too.

Happy coding!
Play around with AWK language!
Tags: linux, macos, ubuntu, hacking
Published: 2020-03-30 16:40:15

---
title: Play around with AWK language!
published: true
description: Learning how to use `awk` 
tags: linux, macos, ubuntu, hacking
---

In this tutorial, we're gonna use AWK programming language to play around with files in Unix-like OS.

Let's see what we can do by this Language, first open up your terminal.

# Basic

Obviously, we'll start with Hello World! as it essential for every programming language,

`awk 'BEGIN { print "Hello World!" }'`

`BEGIN` is for generating header information, and the Curly braces the `print` will print something.

Print content from file:

`awk ' { print } ' /etc/passwd`

this is `/etc/passwd`, but you can specify your own file.


# Real Examples

now let's filter the file.

`awk 'BEGIN { FS=":" } { print $1 }' /etc/passwd`

`FS` option for the input field separator which is `:` (colon), it means we'll split lines by colon like `user:pass`.

in the second curly braces we print the first field `$1`, you can specify `$n` n is number.


Count Lines in File:

`awk 'BEGIN { FS=":" } { print NR, $1 }' /etc/passwd`

`NR` the total number of lines. you will get each line with numbers.

Specifying Lines:

I want to get the content from line `1` to `10`
`awk 'NR <= 10' /etc/passwd`


printin' from the line `10` to `20` will be same
`awk 'NR == 10, NR == 20' /etc/passwd`


I'm sorry in advance, If I made a mistake, Don't hesitate to fix me, please! Learn more about this https://gumroad.com/learnbyexample, just download awk book from there, and start learning, automate your daily task.