teleren/devto huggingface dataset:
Pragmatic Functional Programming in JavaScript
Tags: pragmatic, functional, programming, javascript
Published: 2022-01-18 21:03:17

---
series: Pragmatic Functional Programming in JavaScript
---

If you have been following along with my recent posts, it is no surprise that I am an avid fan of functional programming. I [attempted to solve the Advent of Code 2021](https://dev.to/sethcalebweeks/advent-of-code-1-in-javascript-haskell-24in) problems using both Haskell and JavaScript to find an idiomatic functional solution. Unfortunately, I [learned along the way](https://dev.to/sethcalebweeks/lessons-learned-from-aoc-2021-2b3b) that certain approaches and techniques are not practical in JavaScript. This led me to the conclusion that functional programming has different flavors, and it is important to find the right blend for your language of choice.

JavaScript is the language I use the most (whether by choice or not), and fortunately it supports functional programming fairly well. I think the bare minimum requirement needed for a language to claim to support functional programming is ergonomic support for higher order functions. (First-class functions are a requirement for higher order functions). What I mean by ergonomic support is that it has to feel natural, not gimmicky. Higher order functions work very well in JavaScript, particularly with ES6 arrow functions. 

The lack of certain features such as static types (in particular algebraic data types), pattern matching, or immutable data structures limits the techniques we can use without sacrificing ergonomics, but fortunately, you can get pretty far without these features.

I came across two resources recently which have helped me think through pragmatic functional programming in JavaScript. The first is [this talk](https://youtu.be/3n17wHe5wEw) by Richard Feldman that does a great job of explaining the why of functional programming. The second is [this book](https://github.com/getify/Functional-Light-JS) by Kyle Simpson which proposes a flavor of functional programming that is practical in JavaScript. There are certain areas where my opinions differ from Kyle's, but this book introduces pragmatic functional programming from first principals. Also check out the [Mostly Adequate Guide to Functional Programming](https://mostly-adequate.gitbook.io/mostly-adequate-guide/).

Learning functional programming and figuring out how to use it practically has been a very long journey, and I think many people have felt the same frustrations that I did while learning. Although the functional programming paradigm is gaining momentum, practical resources get drowned out in the noise of both dissenters and people just riding the hype train. This is the start of a series where we will try to make sense of the plethora of information and distill it into actionable conclusions.
Aplikasi WebView Pro (Convert Web ke Apk)
Tags: android, webview, java
Published: 2022-07-22 03:42:46

---
title: Aplikasi WebView Pro (Convert Web ke Apk)
published: true
date: 2022-01-18 21:01:30 UTC
tags: Android,Webview,Java
canonical_url: https://mycoding.id/item/88/aplikasi-webview-pro-convert-web-ke-apk
---

Source Code Aplikasi Convert Website ke Apk WebView Pro dibangun dengan Java dan Native Android. Dapat digunakan di Android Studio dan Gradle. Aplikasi WebView Pro menggunakan engine Chromium yang kuat cepat. Ini kompatibel dengan WordPress, Blogger atau CMS dan framework web lainnya... Selengkapnya https://mycoding.id/item/88/aplikasi-webview-pro-convert-web-ke-apk Aplikasi WebView Pro (Convert Web ke Apk) - by MC Project - Produk Digital dan Jasa Freelance
Create and Restore Archived Files in Windows 10
Tags: beginners, testing, tutorial, security
Published: 2022-01-18 20:53:07

Read this article to find out how to archive and extract a file in Windows 10. We will explore both system-integrated and third-party tools, with a closer look at how to restore a deleted archive containing a file or folder. Do you need to extract or archive files, but you don’t like commercial products with loud names like WinZip or WinRAR)? The latest version of Windows features built-in support for ZIP files, to say nothing of the numerous free tools that offer as much functionality as their commercial counterparts.

## How Windows works with ZIP files
As a matter of fact, if you are not looking for a peculiar archiving option, there is no need to install a third-party tool for such purposes.

You can create a ZIP file right from the file manager of your operating system, using the integrated archiving feature. Just right-click on a selected file or group of files and choose Send to / Compressed (zipped) folder.

![Image description](https://hetmanrecovery.com/pic/blog/a159/compressed-folder.jpg)

Doing it will not remove the original file. As a result, you will see the original file and a .zip file containing its archived copy.

If you need to add more files to such archived folder, just drag them to the folder while holding down the left mouse button.

![Image description](https://hetmanrecovery.com/pic/blog/a159/copy.jpg)

Not only can Windows archive files and folders, but also do other things to .zip files. Choose any ZIP archive and double-click on it, and it will open as if it were a regular folder. From there, you can extract files and copy them to any other directory on this computer.

If you need to decompress a folder entirely, click Extract all or right-click on the archive and select Extract all. If you do so, Windows will extract al files into the folder with the name of the archive.

![Image description](https://hetmanrecovery.com/pic/blog/a159/extract-all.jpg)

For most ordinary users, these functions are more than enough to deal with their everyday tasks.

## 7-Zip: if you need to handle archives in various formats
If you want to archive or extract files in other compression formats such as .rar, .7z, .tar.gz, .tar, .bz, or you’d like to protect the archive with encryption or password, it takes a third-party tool to satisfy your needs.

Of course, there are numerous tools with such functionality, but we are not going to describe all of them. Instead, we will focus on the only tool which stands out of the crowd by being free of charge.

7-Zip is a free open-source archiver for Windows. It works both with its own format, 7z, and other popular formats including RAR, ZIP, GZIP, BZIP2, DMG, ISO.

This archiver is as simple to use as the tool integrated with Windows 10: right-click on a file, select 7-Zip in the context menu and the line depending on your task: to add a file to an archive or extract it.

![Image description](https://hetmanrecovery.com/pic/blog/a159/add-to.jpg)
Sort by Permutation
Tags: 100daysofcode, algorithms, java, programming
Published: 2022-01-18 19:59:37

# [Description](https://binarysearch.com/problems/Sort-by-Permutation)

Given a list of strings `lst` and a list of integers `p`, reorder `lst` so that every `lst[i]` gets placed to `p[i]`.

This should be done in \mathcal{O}(1)O(1) space.

**Constraints:** 

- `n ≤ 100,000` where `n` is the length of `lst`

## Example 1

### Input

```
lst = ["a", "b", "c", "d"]
p = [3, 0, 1, 2]
```

### Output

```
["b", "c", "d", "a"]
```

### **Explanation**

```
a goes to index 3
b goes to index 0
c goes to index 1
d goes to index 2
```

---

# Intuition

quick sort

# Implementation

```java
import java.util.*;

class Solution {
    public String[] solve(String[] lst, int[] p) {
        int n = lst.length;
        quickSort(p, 0, n - 1, lst);
        return lst;
    }
    private void quickSort(int[] nums, int l, int r, String[] lst) {
        if (l >= r) {
            return;
        }
        int i = l - 1, j = r + 1, x = nums[i + j >> 1];
        while (i < j) {
            do {
                i++;
            } while (nums[i] < x);
            do {
                j--;
            } while (nums[j] > x);
            if (i < j) {
                swap(nums, i, j, lst);
            }
        }
        quickSort(nums, l, j, lst);
        quickSort(nums, j + 1, r, lst);
    }

    private void swap(int[] nums, int i, int j, String[] lst) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;

        String tempString = lst[i];
        lst[i] = lst[j];
        lst[j] = tempString;
    }
}
```

## Time Complexity

- Time: O(nlogn)
- Space: O(1)

---

```java
import java.util.*;

class Solution {
    public String[] solve(String[] lst, int[] p) {
        int index = 0, n = lst.length;
        while (index < n) {
            // 3 0 1 2
            int originalIndex = p[index]; // originalIndex = 3
            int tempIndex = p[originalIndex]; // tempIndex = 2
            p[originalIndex] = originalIndex; // 3 0 1 3
            p[index] = tempIndex; // 2 0 1 3
            // "a", "b", "c", "d"
            String originalStr = lst[index]; // originalStr = a
            String tempStr = lst[originalIndex]; // tempStr = d
            lst[originalIndex] = originalStr; // a b c a
            lst[index] = tempStr; // d b c a

            if (index == originalIndex) {
                index++;
            }
        }
        return lst;
    }
}
```
Todo List App and a Color Box Maker | Day 13 & 14
Tags: javascript, webdev, beginners, programming
Published: 2022-01-18 19:45:25

### I have made 2 React App 

1) **Todo List**
2) **Color Box Maker**


##To Do List 
![To Do list](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ys7gdyc22psv4l1u5xp.png)

### Components

- App - this component should render the TodoList component

- TodoList - this component should render the NewTodoForm component and should render the list of Todo components. Place your state that contains all of the todos in this component.
- NewTodoForm - this component should render a form with one text input for the task to be created. When this form is submitted, a new Todo component should be created.
- Todo- this component should display a div with the task of the todo.

### For each Todo component, there should also be a button with the text “X” that when clicked, removes the todo.

###Each Todo component should also display a button with the text “edit” that when clicked, displays a form with the task of the todo as an input and a button to submit the form. When the form is submitted, the task of the text should be updated and the form should be hidden.

https://github.com/Developer-io-web/Todo-list


## Color-Box Maker 

https://github.com/Developer-io-web/Color-Box-Maker

###Components

- App - this component should render the BoxList component.
- BoxList - Place your state that contains all of the boxes here. This component should render all of the Box components along with the NewBoxForm component
- Box- this component should display a div with a background color, width and height based on the props passed to it.
NewBoxForm - this component should render a form that when submitted, creates a new Box. You should be able to specify the Box’s width, height, and background color. When the form is submitted, clear the input values.

###When each Box component is displayed, add a button with the text of of “X” next to each Box. When this button is clicked, remove that specific box. This will require you to pass a function down as props - the button should not be a seperate component, it should be included in the Box component.
ES6: JavaScript for...of statement
Tags: javascript, webdev, tutorial, node
Published: 2022-01-18 19:24:39

## Introduction

This tutorial will learn about `for-of` introduced in  `ES6` version of JavaScript.

The `for...of` statement is used for iterating over arrays, maps or sets.

## Looping over an array
Example in code:

```typescript
const fruits = ['Orange', 'Apple', 'banana', 'Lemon']

// looping through
for (fruit of fruits) {
  // do something with fruit
}
```

## Looping over a string
`for...of` can also be used to loop over contents of a string.

```typescript
const words = 'Happy new year!'
for (char of words) {
  console.log(char) // H a p p y n e w y e a r !
}
```

## Looping over a Set
A set is a collection of unique values. 

```typescript
const letters = new Set(['a', 'b', 'c'])

for (letter of letters) {
  console.log(letters) // a, b, c
}
```

## Looping over a map

A map is key-value pair, where key can be of any type. In JavaScript it's common to use object literals as maps

```typescript
const details = new Map( [
  ['name', 'Michael Myers'],
  ['age', 45] // made up
])

// or a cleaner way:
const details = new Map()
details.set('name', 'Michael Myers')

for (detail of details ) {
  console.log(detail)
}
```

## Summary
`for...of` introduces a cleaner way of looping over arrays, sets, strings and maps.

***

Read more about 👉 [Map objects](e)
Installing Font Awesome on Ionic in 3 steps
Tags: ionic, fontawesome
Published: 2022-01-18 19:08:13

### 1. Install it via npm:
  ```sh
  npm i @fortawesome/fontawesome-free
  ```
### 2. Add this to your main.ts:
  ```js
  /* Fontawesome */
  import "@fortawesome/fontawesome-free/css/solid.css";
  import "@fortawesome/fontawesome-free/css/regular.css";
  import "@fortawesome/fontawesome-free/css/fontawesome.css";
  ```
### 3. Done!
Get Python docstring with ast
Tags: python
Published: 2022-01-18 19:06:12

---
canonical_url: https://waylonwalker.com/til/python-docstring-ast/
published: true
tags:
- python
title: Get Python docstring with ast
---

Getting docstrings from python's ast is far simpler and more reliable than any method of regex or brute force searching.  It's also much less intimidating than I originally thought.

## Parsing

First you need to load in some python code as a string, and parse it with
`ast.parse`.  This gives you a tree like object, like an html dom.

``` python
py_file = Path("plugins/auto_publish.py") raw_tree = py_file.read_text() tree = ast.parse(raw_tree)
```

## Getting the Docstring

You can then use `ast.get_docstring` to get the docstring of the node you are currently looking at.  In the case of freshly loading in a file, this will be the module level doctring that is at the very top of a file.

``` python
module_docstring = ast.get_docstring(tree)
```

## Walking for all functions

To get all of the functions docstrings we can use `ast.walk` to look for nodes that are an instance of `ast.FunctionDef`, then run `get_docstring` on those nodes.

```python
functions = [f for f in ast.walk(tree) if isinstance(f, ast.FunctionDef)] function_docs = [ast.get_docstring(f) for f in functions]
```

> ast.walk docs: Recursively yield all descendant nodes in the tree starting at *node*
(including *node* itself), in no specified order.  This is useful if you
only want to modify nodes in place and don't care about the context.

## Example

Here is an image of me running this example through `ipython`.


![getting docstrings from the ast in python](/dev-to-uploads/uploads/articles/az3zhx3xed0isns9996u.png)
Multiple GitHub accounts on one laptop
Tags: github, git, bash
Published: 2022-01-18 18:49:51

Imagine the next situation:

- You have only one laptop
- You have your personal GitHub account
- Your employer stores code on GitHub as well
- You need to commit your personal code to your personal repositories but also work code to the employer`s repositories.
- You can`t do this from your personal account but do not want to create an additional one (with corporate email)

What to do in this situation? There is a way, how you can configure your laptop to commit to work repositories with work credentials, and to personal one with your personal one.

This solution is based on 2 aspects:

- correcting SSH config
- git URL re-writing


The main advantage of this approach is that it doesn't require any additional work to get it right. You will not need to change remote URLs or remember to clone things differently. The second part ( the URL rewriting) will take care of it.

First of all, let's correct our .ssh config. Assuming you have 2 ssh keys, your personal (`github_personal`) and your work (`github_work`). How to create ssh keys you can read in the [GitHub docs](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).

`~/.ssh/config`

```
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/github_personal

# Work GitHub
Host github-work
  HostName github.com
  User git
  IdentityFile ~/.ssh/github_work

Host *
  AddKeysToAgent yes
```

Both this configs have same user and domain, but we will take care about it later. Next - global git config.

`~/.gitconfig`

Here we need to add our default name and email (the one we used in ssh creation for our personal account)

```
[user]
    name = My Name
    email = personal@personal.email

[includeIf "gitdir:~/path/work_dir/"]
    path = ~/path/work_dir/.gitconfig

[url "github-work:work-github-org-name/"]
    insteadOf = git@github.com:work-github-org-name/
```

What happens here? First, set our default name and email. Second, we point to use local `.gitconfig` file for all repositories located by mask `~/path/work_dir/`. And the last, replace `github.com` (default account for Github) with the profile we set under `github-work` in `.ssh/config`.

The last part is modification of local `.gitconfig` for all our working repositories:

`~/path/work_dir/.gitconfig`
It is easy - just replace your email with your corporate one.
```
[user]
    email = work@work.email
```

That is all! As long as you keep all your work repos under `~/path/work_dir/` and personal stuff elsewhere, git will use the correct SSH key when doing pulls/clones/pushes to the server, and it will also attach the correct email address to all of your commits.

**How to check?** Clone repository via SSH, cd to that folder and  execute `git config --get user.email`
Unboxing an iPad Air 4 and Apple Pencil
Tags: ipad, apple, blog, tech
Published: 2022-01-26 20:29:09

---
title: Unboxing an iPad Air 4 and Apple Pencil
published: true
date: 2022-01-18 18:43:42 UTC
tags: ipad,apple,blog,tech
canonical_url: 
---

[![](https://cdn-images-1.medium.com/max/2600/0*zidqo4iz9Ad2mnA5)](https://jmspace.medium.com/unboxing-an-ipad-air-4-and-apple-pencil-f359e03a6b87?source=rss-72cf04af5e24------2)

First Impressions

[Continue reading on Medium »](https://jmspace.medium.com/unboxing-an-ipad-air-4-and-apple-pencil-f359e03a6b87?source=rss-72cf04af5e24------2)
FlightLabs - Get Free Flight Database API
Tags: saas, programming, startup, database
Published: 2022-01-18 18:30:29

FlightLabs provides a simple, efficient way to search for and access global flight status from various airlines and airports. A flight API can be used by a traveler or an agency to get information on current flight deals from multiple airlines. Besides, developers will find it useful because it allows them to simply incorporate all of the data into a platform or application.

You can subscribe to the waiting list here https://goflightlabs.com/.
Learnig and Revising Js , Day 1
Tags: javascript, webdev, beginners, programming
Published: 2022-01-18 18:29:25

Hi guys , just sharing what i have learnt , may be you will find all these informative, 

These are some basic concepts of javascript , I will be sharing everything that i'll be doing here , Like if you like the content , See a have a good day !!

//👉 Objects is known to as "hashmap in java" and in "python it is called as dictionary"

// object is a group of key , value pair

//key: value --> propert
//key: function --> method

// key can be string/integr and same ways value also

let cap={
    name:"Steve",
    lastName:"Rogers",
    address:{
        city:"Manhattan",
        state:"New York"
    },
    age:35,
    isAvenger:true,
    movies:["First Avenger","Winter Soldier","Civil War"],
    sayHi: function() 
    {
    console.log("Cap says HI ");
    }
};
//📌get (getting keys)
// console.log(cap.name);
// console.log(cap.age);
// console.log(cap.movies[1]);
// cap.sayHi();


//📌set /update 
// console.log("cap",cap);
// cap.age =36;
// cap.isAvenger=false;
// cap.friends=["Tony","Bruce","Peter"];
// console.log("---------------------------------------");


//📌delete
// delete cap.address;
// console.log("cap",cap);

//👉diffrence between .(dot) & [](square bracket)  -->(cap.age and cap[propkey] ,where propkey="age")
// (cap.age gives values direcet , but cap[propkey] gives values through varibale )
let propkey="age"
console.log(cap[propkey]);
console.log(cap["age"]);


//📌for in loop
for(let key in cap)
{
    console.log(key," : ",cap[key]);
}

//👉 it basically internally makes its as cap["name"],cap["lastname"],cap["address"] everytime and gives the answer,
// its just the other way of writing ,nothing else

// 📌if we want to print a key , i.e not present in object , then we get undefined  for that 

 console.log(cap.xyz);
Laravel Sanctum API Broken Issues
Tags: laravel, linux, ubuntu, webdev
Published: 2022-01-18 18:23:41

** Hey, Lara devs **

Today I am going to share something with you guys.

> Maybe someday it will help you to resolve.

I was working with Laravel Project with sanctum. 
We were preparing to go live. And I cleaned the full DB and created a new database user and new database at Digital Ocean Droplet with Linux Ubuntu 20.04.

After completing the user & database creation. I imported My Local Fresh SQL to the server new database.

In the meantime somehow id primary key was removed and the data type turn into big-int also auto-increment credentials were removed. 

For that, Records are created without default id increment. ID was 0 for every-rows.

So, whenever I was trying to log in through API. It's successfully generating API Tokens also saving inside personal_access_tokens  with id 0. I was also able to parse tokens.

When, I was passing the token with Bearer  to get my profile information. And, I was getting a wired response like 405 Method Not allowed exception. 

I checked locally more than 10 times , everything is working. Also, I tried to down and up Laravel application at production mood.
Nothing worked at all.

After long period, Once I just dropped the id column and created a new id column with primary index & auto-increment.
It works perfectly now.

#Server : Droplet,  Digital-Ocean
#OS : Ubuntu 20.04
#Version : Laravel 7
#HappyCoding 
#clhg52
How to search through all files in your web application in Google Chrome
Tags: devtools, chrome
Published: 2022-01-18 18:18:53

> I am running Version 97.0.4692.71 (Official Build) (arm64) to date.

## Why?

Use this feature to find text in any resource served by the web server. It's handy for searching for things where the location is sometimes uncertain.

## How

There are two ways I know of:

### Approach 1 
(the simplest)

1. Go to the Developer Tools
2. In the kebab menu to the far right (right next to the close button - on the left)
3. You can then open the Search tab by clicking on Search.

### Approach 2 
(let's you browse through files before hand)

1. Go to the Developer Tools
2. Go to the Sources tab (you can rearrange your tabs by dragging them around)
3. Locate your domain (in my case it's Storybook on localhost:6007)
4. Right-click on the domain name and click on **Search in all files**

![Sources tab in Google Chrome](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qx0b9qkbyxyoe1gs7rsr.png)