teleren/devto huggingface dataset:
Fun to use state management for your React
Tags: javascript, react, immerjs, immutable
Published: 2019-08-03 05:42:00

---
title: Fun to use state management for your React
published: true
description: Managing your React state must be fun and easy!
tags: javascript, react, immerjs, immutable
---

When managing your React state, your state manager should only give you simple works to do the job even though that you are maintaining huge state. **small is the new big**. Yes indeed! It must only give you small utilities to manage it and will be sufficed. It means that it must have minimal API.

`easy-react-state` gives you this kind of features and use it in fun and easy way. It is like bigger version of `React.useState` hook but managing different state. It also has smaller API surface so you don't need to learn many stuffs just to make it right.

Let's take a look on how we can use the awesome library:

#### 1 - Configuring your store

NOTE: `easy-react-state` uses `immerjs`. So when updating a state, you can use any syntax. This is very handy especially if you change nested property's value. You can use mutator syntax just like `state.user.name = 'Zion'`.

```jsx
const configAppStore = {
  todos: {
    initialState: [],
    setters: state => ({
      addTodo(todo) {
        state.push(todo)
        return state
      },
    }),
  },
}
```

#### 2 - Creating state manager based on your store

NOTE: The returned `useSelector` will subscribe to the store based on the data which user need and will only re-render the Consumer Component if and only if the subscribed data will change even though the root state gets updated.

```jsx
const [useAppSelector, appSetters] = createStateManager(configAppStore)
```

#### 3 - Consume to your React Component

NOTE: We don't need a `Provider` to consume the store. Just create a manager, then you can use it directly.

```jsx
const App = () => {
  const todos = useAppSelector(state => state.todos)
  console.log('todos', todos)
  return (
    <div>
      <h3>Todos Control</h3>
      <button
        onClick={() => {
          const todo = {
            id: `todo-${Date.now()}`,
            label: `Todo ${Date.now()}`,
          }
          appSetters.todos.addTodo(todo)
        }}
      >
        Add todo
      </button>
    </div>
  )
}
```

Pretty simple right? How about async updates? This is easy.

Because the `setters` are just object which are created outside the `Component`, then you can call it wherever you want. For an instance, call it inside `async` function:

```jsx
const [useAppSelector, appSetters] = createStateManager(configAppStore)

async function fetchUsers() {
  appSetters.users.loading()
  try {
    const res = await apiUsers()
    appSetters.users.setUsers(res)
  } catch (err) {
    appSetters.users.setError(err)
  }
}
```

And thats it! If you are interested and want to try, [you can check its github repo for more info](https://github.com/ombori/easy-react-state). Of course, it is open-source and feel free to give feedbacks and contribute!
Work Coding Is Boring!
Tags: javascript, vanilla, games, webdev
Published: 2019-08-03 03:11:02

---
title: Work Coding Is Boring!
published: true
description: A little game coding to impress my kid.
tags: javascript,vanilla,games,webdev
---

My son sees me working from home from time-to-time. I sit there at my desk writing lines of code, mostly pretty mundane stuff like web forms. I can admit that there's nothing particularly exciting about it. But I showed my son what I was working on and he totally got turned off. I get that, but it still kinda hurt.

So, when I finally had a little down time, I decided to write something a little more interesting to him. What guy doesn't want to impress his kid?

I did a little planning and started attacking a "<a href='https://codepen.io/edlinkiii/details/ZgKgMe'>Tic-Tac-Toe</a>" game - using only Vanilla JavaScript. It turned out pretty well, if I do say so myself.

It has logic and does what it is supposed to do. But I wanted a little more of a challenge... Something more interactive. A "<a href='https://codepen.io/edlinkiii/details/zgdvdQ'>Simon Says!</a>" game seemed perfect for this. Once again, only using Vanilla JS.

There's a lot more I could do with these games, but if I do, it will be much later. (This stuff doesn't pay the bills, folks.) Either way, I had fun and my boy got to see that I am capable of more than "boring" work projects.

What have you done to impress your kids using your day job skills?
Mirroring or Archiving an Entire Website
Tags: archive
Published: 2023-01-06 01:59:56

---
title: Mirroring or Archiving an Entire Website
published: true
date: 2019-08-03 02:42:16 UTC
tags: Archive
canonical_url: https://brandonrozek.com/blog/archivingsites/
---

I have several old Wordpress sites lying around that I would like to archive but not maintain anymore. Since I don’t intend to create any more content on these sites, we can use tools like `wget` to scrape an existing site and provide a somewhat _read-only_ copy of it. I say read-only not because we can’t edit it, but because it’s not in the original source format of the website.

There have been several tackles to the problem:

- [https://stackoverflow.com/questions/538865/how-do-you-archive-an-entire-website-for-offline-viewing#538878](https://stackoverflow.com/questions/538865/how-do-you-archive-an-entire-website-for-offline-viewing#538878)
- [https://letswp.io/download-an-entire-website-wget-windows/](https://web.archive.org/web/20190915143432/https://letswp.io/download-an-entire-website-wget-windows/)

And ultimately after consulting these resources I’ve came to the following command:

```
wget --mirror \
     --convert-links \
     --adjust-extension \
     --page-requisites \
     --no-verbose \
     https://url/of/web/site

```

There were other solutions in that stack overflow post, but something about the simplicity of `wget` appealed to me.

[Example site I archived with this.](https://sentenceworthy.com)
Copy to RAM Please: Linux Distributions that Allow Running from RAM
Tags: linux
Published: 2023-01-06 02:00:26

---
title: Copy to RAM Please: Linux Distributions that Allow Running from RAM
published: true
date: 2019-08-03 02:37:12 UTC
tags: Linux
canonical_url: https://brandonrozek.com/blog/copytoram/
---

I bought a 1U server recently, and I forgot to purchase a SSD to actually hold data. Since I couldn’t hold my excitement to play with the server, I decided to load an operating system entirely into RAM and never turn it off for the meantime.

I browsed [List of Linux Distributoins that run from RAM](https://en.wikipedia.org/wiki/List_of_Linux_distributions_that_run_from_RAM) and found [Slax](https://www.slax.org/) a [debian](https://www.debian.org/) derivative.

It’s not what I would use for my daily driver but in terms of doing this task its perfect. It loads up quickly and lets me perform nice basic user functions. It’s also based on debian so I have a whole repository of packages available I can install.

Now by default, if you’re on a USB it’ll try to run in a persistent mode, just press ESC in the boot splash to have the option to copy to ram.
How to land my first developer job?
Tags: html, css, javascript, rails
Published: 2019-08-03 01:47:41

---
title: How to land my first developer job?
published: true
description: Career advice
tags: HTML, CSS, JavaScript, RubyOnRails
---

Hi Everyone,

So I've been on the job hunt for an entry level position as a developer for quite some time now, but have not had any luck. I have experience in back-end and front-end languages, but I personally prefer the front-end. I would greatly appreciate some tips and advice on how to be more successful when it comes to the job hunt. Any stories on how long it took you to land your first job and and how to stay motivated will also help.

Thanks!
Chunked Iterator: Python Riddle
Tags: python, discuss
Published: 2019-08-03 01:22:30

I really like this python riddle. And it is (almost) a practical problem. 

Say you have an iterator (stream of objects of unknown length). And you want to separate it to equal size chunks. An example: splitting a file to multiple smaller sized files.

Doing the same with lists is much easier because the length of the list is known:

```python
from typing import List, TypeVar

T = TypeVar('T')


def chunks(l: List[T], n: int) -> List[List[T]]:
    return [l[i:i + n]
            for i in range(0, len(l), n)]


items = list(range(10))
print(chunks(items, 3))
# [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
print(chunks(items, 4))
# [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9]]

```

The riddle is: write `chunks` where the input is an iterator. And the output is an iterator of iterators

```python

def chunks(l: Iterator[T], n: int) -> Iterator[Iterator[T]]:
    ????

```

I will add the solution later today or tomorrow.

Extra points for run-time performance

Followup question: What problem can you spot in the solution to this problem?

Enjoy

Edit: Solution is [here](https://dev.to/orenovadia/solution-chunked-iterator-python-riddle-3ple)
VIDEO 📺 📽️    Practical Web Scraping | Auto-Upload to DEV | Part 2 - Pushing a Blog Post
Tags: python, tutorial, webscraping, learntocode
Published: 2019-08-02 22:11:22

---
title: VIDEO 📺 📽️    Practical Web Scraping | Auto-Upload to DEV | Part 2 - Pushing a Blog Post
description: The next chapter in the Auto-Upload to Dev series! By the end of this video, you'll be able to upload blog posts to Dev with the simple running of a script!
published: true
tags: #python #tutorial #webscraping #learntocode
---

{% youtube qFDU4DbFGV0 %}

# What we've learned

We've covered the basics of logging in to DEV with a script, and you've learned the basic skills necessary to reproduce these efforts on any site you wish! 

# So, what's next?

Boy, am I glad you asked! In the video above, we're going to learn how to use environment variables and .env files (so as not to store passwords in the code itself), use selenium webdriver and cleverly placed `input()` functions to defeat oAuth device confirmations, and upload and puslih our post on DEV!

# Anything else?

Of course! At the end, you'll learn where this project is going next. And throughout the video, you can see my quintissential typos, some music, a creepy turn-to-the-camera, and see what happens when I leave the editing of the video to the in-house riffer!! I really hope you enjoy it!

(by the way, this post was uploaded and published to dev using the script we'll be writing in this video!)
JAMstack Roundup for August 2nd 2019
Tags: graphql, takeshape, jamstack, headlesscms
Published: 2019-08-02 21:15:25

# Here are 5 great reads we're bringing to you this week! #

1. [This simple guide will help you understand why JAMstack exists and how to get started.](https://jamstack.wtf/)
More than just a modern web development architecture based on client-side JavaScript, reusable APIs, and prebuilt Markup, JAMstack is revolutionising the way we think about workflow by providing a simpler developer experience, better performance, lower cost and greater scalability. 🤟

2. [Everything you need to know about GraphQL](https://hackernoon.com/everything-you-need-to-know-about-graphql-a5bc3622e54)
GraphQL is making your data more easily accessible for two reasons: 🌝It lets the client specify exactly what data it needs. 🌚It makes it easier to collect data from multiple servers.

3. [How to Leverage GraphQL with a Headless CMS [Takeshape Tutorial]](https://snipcart.com/blog/headless-cms-graphql-takeshape-tutorial)
📊GraphQL is great! And [TakeShape](https://www.takeshape.io/) is your groundwork, providing a better API to retrieve data, the possibility to insert data from external applications, great performance, and ease of delivery to multiple channels.

4. [Static vs Dynamic Website — What’s the Difference in 2019?](https://hackernoon.com/static-vs-dynamic-website-whats-the-difference-in-2019-327064bfd4a9)
(🍇JAMstack > 🤬MEANstack > 🛋LAMPstack) && (🏠Static Sites > 🚗Dynamic Sites)

5. [Multiple Ways of API Integration in your JAMStack](https://www.raymondcamden.com/2019/07/25/multiple-ways-of-api-integration-in-your-jamstack)
Static sites are better than your dynamic site, and the JAMstack is why. And yes, it takes more work to integrate all your tools… unless you’re using TakeShape’s new [Mesh](https://www.takeshape.io/signup/). 🤩
What steps are you taking TODAY to prevent today's code from becoming tomorrow's LEGACY APP?
Tags: discuss
Published: 2019-08-02 20:48:25

---
title: What steps are you taking TODAY to prevent today's code from becoming tomorrow's LEGACY APP?
published: true
description: 
tags: discuss
---

Every MONOLITH and LEGACY APPLICATION started out, just like today, as "the new technology".

The growth and decay is often slow and unnoticed. The pull to become an unmaintainable app is constant and unrelenting.

Without persistent intervention, today's tech WILL grow into tomorrow's LEGACY.

What steps are you taking TODAY to prevent today's code from becoming tomorrow's LEGACY APP?

=======

One thing that I am doing is creating CI/CD pipelines that enforce test coverage levels. I set a coverage level to prevent laziness in the future. If you add new code, you must also add new tests.

Sure the tests help, but writing code that is testable is the real benefit!
Super-simple Jira API wrapper for bash/zsh
Published: 2019-08-02 20:27:59

Often I need some very simple bits of automation of Jira-related tasks without heavy external dependencies like Python version & packages, Groovy classes or even more exotic stuff. Scripts provided below depend only on Bash v4+ or Zsh v5+ (or even earlier versions which I didn't test).

*(Ups... on __curl__ as well. __[jq](https://stedolan.github.io/jq/)__ is used for fancy output only)*


## Examples
<!-- {% gist https://gist.github.com/turboBasic/ee8cf68f78f9367c90b6afd38d82c05d %} -->

```bash
$ echo '{
    "fields": {
      "project": { "key": "BOOM" }, 
      "summary": "Foo", 
      "description": "Bar", 
      "labels": ["test"], 
      "issuetype": { "name": "Issue" } 
    }
  }' | jiraPost issue
{"id":"3162226", "key":"BOOM-666", "self":"https://example.com/jira/rest/api/2/issue/3162226"}


$ jiraGet issue/BOOM-666 | jq
{
  "id": "3162226",
  "self": "https://example.com/jira/rest/api/2/issue/3162226",
  "key": "BOOM-666",
  "fields": {
    "summary": "Foo",
    ...
}


$ jiraPut issue/BOOM-666 '{"fields": {"summary": "Bar"}}'

```


## Script `jira.sh`

this should be sourced into your shell profile

```bash
function jiraApi() {
    DATA_PARAM='-'

    if [[ PUT == ${1} || POST == ${1} ]]
    then
        DATA_PARAM='@-'
    fi

    if [[ -z ${3} ]]
    then
        curl  --user "${JIRA}" \
              --cert "${JIRA_CERT}" \
              --key "${JIRA_KEY}" \
              --cacert "${JIRA_CA}" \
              --header 'Content-Type: application/json' \
              --request "${1}" \
              --data "${DATA_PARAM}" \
              --silent \
              "${JIRA_API}/${2}"
    else
        echo "${3}" |
        curl  --user "${JIRA}" \
              --cert "${JIRA_CERT}" \
              --key "${JIRA_KEY}" \
              --cacert "${JIRA_CA}" \
              --header 'Content-Type: application/json' \
              --request "${1}" \
              --data "${DATA_PARAM}" \
              --silent \
              "${JIRA_API}/${2}"
    fi
}

function jiraGet() {
    jiraApi GET "${@}"
}

function jiraPost() {
    jiraApi POST "${@}"
}

function jiraPut() {
    jiraApi PUT "${@}"
}
```


## Environment variables

If you ask *‘What are all those JIRA_\* variables?’* &mdash; you get the point: this is where all sensitive access details are kept. Source them into your shell profile as well:

```bash
export JIRA='login:password'
export JIRA_API=https://example.com/jira/rest/api/2
export JIRA_CERT=/full/path/to/certificate/file
export JIRA_KEY=/full/path/to/private/key/file
export JIRA_CA=/full/path/to/certificate/authority/file
```
Open-sourcing our new employee onboarding process
Tags: culture, team, onboarding
Published: 2019-08-02 19:37:49

---
title: Open-sourcing our new employee onboarding process
published: true
description: 
tags: #culture, #team, #onboarding
---

The thoughtful onboarding process at Cockroach Labs is the best I have ever experienced. I am thrilled that the PeopleOps team decided to open-source the process and now I can share the process with everyone! 

![CRL Onboarding](https://thepracticaldev.s3.amazonaws.com/i/ci5bcu2e7oxihfdvijmx.png)

And here's the detailed blog post explaining the rationale behind the process:

https://www.cockroachlabs.com/blog/onboarding-as-a-team-sport/
Introducing 🥁: The Cloud Native Software Engineering Newsletter! 🎉 
Tags: cloudnative, devops, aws, infrastructure
Published: 2019-08-02 18:11:38

---
title: Introducing 🥁: The Cloud Native Software Engineering Newsletter! 🎉 
published: true
description: Do you wanna be a Cloud Native pro? 
tags: Cloud Native, DevOps, AWS, Infrastructure
---

I've been writing online for a long time. But recently I've decided to dial in everything I do to help others learn Cloud Native Software Engineering.

I know how much of a pain it can be to try and keep up with everything you need to know. I've seen it first-hand! Cloud Native is the future of software engineering and I want to help you all be a part of it. 

Cloud Native covers everything from: Containers, Serverless, Cloud setup, Testing, Networking, Security, Monitoring and deployment strategies. All focused on building apps leveraging the power of cloud engineering. 

It's not always easy — but it's incredibly fun. And if learning and keeping up to date with these technologies is something that interests you, you can join many other engineers on the newsletter here...

[The Cloud Native Software Engineering Newsletter](http://thedevcoach.co.uk/newsletter)

I look forward to hearing about the neat problems you're trying to solve with the cloud! 

Speak soon, 

Lou!
Why do you love your job?
Tags: discuss, career
Published: 2019-08-02 19:05:17

---
title: Why do you love your job?
published: true
description: Jobs aren't all frustration and misery. What does you job do for you that makes you happy to stay where you are?
tags: discuss, career
---

Jobs aren't all frustration and misery. What does you job do for you that makes you happy to stay where you are? The benefits, a great perk, your coworkers, the projects?
What mailing lists do you subscribe to?
Tags: discuss, education
Published: 2019-08-02 18:54:39

---
title: What mailing lists do you subscribe to?
published: true
description: What mailing lists do you subscribe to, and why? 🤔
tags: #discuss, #education
cover_image: https://images.unsplash.com/photo-1516321497487-e288fb19713f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80
---

For years I used Unroll.me to manage my email newsletters and tuck them away so I don't see them, and with the advent of Gmail's Promotions tab, I got even less noise every week. Still, I really wanted to stop getting most of these altogether. And it seems like I'm not the only one on DEV.to making this effort lately: 

{% link https://dev.to/yvonnickfrin/save-the-planet-clean-your-mailbox-3e92 %}

There are a handful of newsletters that I do actually read every week, and I wanted to share my "never unsubscribed" lists!

[Juniors in Tech](https://juniorsintech.com/): Keziyah has built Juniors in Tech into such a valuable resource, whether it's the newsletter (FILLED with articles for beginners and mid-level employees both), or the website with its job board, it's clear that she wants to be a resource to help newbies learn and grow. 

[Diversify Tech](https://www.diversifytech.co/): @venikunche's newsletter is invaluable for many of the same reasons as Juniors in Tech, with a broader experience set. She's also a fantastic follow on DEV or Twitter - I've learned a lot from her. 

[Bizarro Devs](http://bizzarodevs.com): I love seeing creative projects or weird code. This week's newsletter introduced me to my new summer love, [poolside.fm](https://poolside.fm)!

[Developer Avocados](https://developeravocados.net/): This curated reading list also includes CFPs and upcoming conference info. I continue to be very interested in advocacy the more I learn about it, and it's really great to have hand-picked articles to further knowledge on it!

[Codepen Spark](https://codepen.io/spark/): More examples of fun, creative code projects!

[The Byte](https://lesbianswhotech.org/signup): The newsletter for [Lesbians Who Tech](https://lesbianswhotech.org). They often include scholarship or travel grant information for minority groups among industry news.

As far as non-tech newsletters, I look forward to [Girls Night In](https://girlsnightinclub.com/) every week, but I've unsubscribed from all the other "lifestyle"-type newsletters. For writing, I've been getting [Reedsy's Friday challenge prompts](https://blog.reedsy.com/creative-writing-prompts) for a few years. I've only submitted pieces twice, but I really enjoy having a cache of writing prompts to reference if I feel inspired to write but have a block. 

# What are your must-read newsletters?
Do you use CSS frameworks or create your own (frameworks, toolkits)?
Tags: discuss, css, webdev
Published: 2019-08-02 18:47:49

---
title: Do you use CSS frameworks or create your own (frameworks, toolkits)?
published: true
description: During my career, I've seen a lot of approaches when styling a website: using a popular framework (Bootstrap, Tailwind, Skeleton), combining a popular framework with a custom toolkit, using your own custom-built framework, etc. What are your thoughts behind this? 
tags: #discuss, #css, #webdev
cover_image: https://thepracticaldev.s3.amazonaws.com/i/elytski1o23ybosxmors.jpg
---

During my career, I've seen a lot of approaches when styling a website: using a popular framework (Bootstrap, Tailwind, Skeleton), combining a popular framework with a custom toolkit, using your own custom-built framework, etc.

What are your thoughts behind this? When to use one, and when to use the other?

Personally, I've not been using frameworks lately at all, as I've become more experienced and proficient with CSS. But I try to keep it as simple and maintainable as possible, so I do not build a complicated build chain (with Gulp) and I use npm handle the updates.
Hellp Guys please
Tags: laravel
Published: 2019-08-02 18:26:04

Hellp, I host my app on cpanal and now I am having this error, I used to send emails but now is giving this error

"proc_open() has been disabled for security reasons"

    private function establishProcessConnection()
    {
        $command = $this->params['command'];
        $descriptorSpec = [
            0 => ['pipe', 'r'],
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w'],
            ];
        $pipes = [];
        $this->stream = proc_open($command, $descriptorSpec, $pipes);
        stream_set_blocking($pipes[2], 0);
        if ($err = stream_get_contents($pipes[2])) {
            throw new Swift_TransportException(
                'Process could not be started ['.$err.']'
                );
        }
        $this->in = &$pipes[0];
        $this->out = &$pipes[1];
    }
 
    private function getReadConnectionDescription()
    {
        switch ($this->params['type']) {
            case self::TYPE_PROCESS:
                return 'Process '.$this->params['command'];
Link: String.prototype.replace supports replacement patterns
Published: 2019-08-02 17:51:02

---
title: Link: String.prototype.replace supports replacement patterns
published: true
description: Article about using string.prototype.replace
tags: 
---

https://www.stefanjudis.com/today-i-learned/string-prototype-replace-supports-replacement-patterns/

This is a very interesting article about an obscure JS feature that lets you use patterns to replace text easily.