teleren/devto huggingface dataset:
Redux-like state container in SwiftUI. Reducer and Actions.
Tags: swift, ios, mobile, programming
Published: 2023-02-11 15:42:58

...about user actions which lead to state mutations. Action is a simple enum or composition of enums describing a change of the state. For example, set loading value during data fetch, assign fetched repositories to the state property. Let’s take a look at the example code for Action enum.

```swift
enum AppAction {
    case search(query: String)
    case setSearchResult(repos: [Repo])
}
```
`Reducer` is a function that takes current state, applies `Action` to the state, and generates a new state. Generally, _reducer or composition of reducers_ is the single place where your app should mutate the state. The fact that the only one function can modify the whole app state is super simple, debuggable, and testable. Here is an example of reduce function.

```swift
typealias Reducer<State, Action> = (inout State, Action) -> Void

func appReducer(state: inout AppState, action: AppAction) {
    switch action {
    case let .setSearchResults(repos):
        state.searchResult = repos
    case let .search(query):
        break
    }
}
```

---

- [Basics](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-basics-single-source-of-truth-2lpc)
- [Reducer and Actions](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-basics-reducer-and-actions-flg)
- [Unidirectional flow](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-basics-unidirectional-flow-3f2p)
- [Side effects](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-side-effects-3l23)
- [Usage](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-usage-k1i)

---

**Contacts**
I have a clear focus on time-to-market and don't prioritize technical debt. And I took part in the Pre-Sale/RFX activity as a System Architect, assessment efforts for Mobile (iOS-Swift, Android-Kotlin), Frontend (React-TypeScript) and Backend (NodeJS-.NET-PHP-Kafka-SQL-NoSQL). And I also formed the work of Pre-Sale as a CTO from Opportunity to Proposal via knowledge transfer to Successful Delivery.

🛩️ #startups #management #cto #swift #typescript #database
📧 Email: sergey.leschev@gmail.com
👋 LinkedIn: https://linkedin.com/in/sergeyleschev/
👋 LeetCode: https://leetcode.com/sergeyleschev/
👋 Twitter: https://twitter.com/sergeyleschev
👋 Github: https://github.com/sergeyleschev
🌎 Website: https://sergeyleschev.github.io
🌎 Reddit: https://reddit.com/user/sergeyleschev
🌎 Quora: https://quora.com/sergey-leschev
🌎 Medium: https://medium.com/@sergeyleschev
Does anyone remember the old Mortbay Library used in Jetty?
Published: 2023-02-11 15:35:06

I believe Mortbay was the first library used by Jetty back in the ninetys. Surprisingly you can still use it to create a Java Servlet Server instead of implementing Tomcat. This would be just for fun of course. I wrote a very old tutorial on this topic. If u are interested you can go to the java tutorial section of my website at https://javasqlweb.org and click on tutorial #3. (please note, this is VERY old school Java)

I wonder if anyone still uses Jetty.....
Redux-like state container in SwiftUI. Basics.
Tags: swift, ios, mobile, programming
Published: 2023-02-11 15:33:51

The main idea here is describing the whole app state by using a single struct or composition of structs. Assume that we are working on a Github repos search app where the state is the repos array that we fetch matching some query using Github API.

```swift
struct AppState {
    var searchResult: [Repo] = []
}
```

Next step is passing the read-only app state to every view inside the app. The best way for doing that is SwiftUI’s Environment feature. We can put an object holding the whole app state in the Environment of the root view. Root view will share its `Environment` with all child views.

```swift
final class Store: ObservableObject {
    @Published private(set) var state: AppState
}
```

We create a store object that stores the app state and provides read-only access to it. State property uses `@Published` property wrapper that notifies SwiftUI during any changes. It allows us to keep up to date the whole app by deriving it from a single source of truth.

---

- [Basics](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-basics-single-source-of-truth-2lpc)
- [Reducer and Actions](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-basics-reducer-and-actions-flg)
- [Unidirectional flow](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-basics-unidirectional-flow-3f2p)
- [Side effects](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-side-effects-3l23)
- [Usage](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-usage-k1i)

---

**Contacts**
I have a clear focus on time-to-market and don't prioritize technical debt. And I took part in the Pre-Sale/RFX activity as a System Architect, assessment efforts for Mobile (iOS-Swift, Android-Kotlin), Frontend (React-TypeScript) and Backend (NodeJS-.NET-PHP-Kafka-SQL-NoSQL). And I also formed the work of Pre-Sale as a CTO from Opportunity to Proposal via knowledge transfer to Successful Delivery.

🛩️ #startups #management #cto #swift #typescript #database
📧 Email: sergey.leschev@gmail.com
👋 LinkedIn: https://linkedin.com/in/sergeyleschev/
👋 LeetCode: https://leetcode.com/sergeyleschev/
👋 Twitter: https://twitter.com/sergeyleschev
👋 Github: https://github.com/sergeyleschev
🌎 Website: https://sergeyleschev.github.io
🌎 Reddit: https://reddit.com/user/sergeyleschev
🌎 Quora: https://quora.com/sergey-leschev
🌎 Medium: https://medium.com/@sergeyleschev
CodePen Designs - 36 : Kill The King - Vue / HTML game
Tags: codepen, css, webdev, design
Published: 2023-02-11 15:07:00

### We are excited to introduce our new series that will explore the best design ideas from the Codepen community. 

We will be publishing these each day and hope you find them insightful and inspiring as we showcase some of the most talented designers in this space.

---


#### Codepen Design - 36

---
{% codepen https://codepen.io/jcoulterdesign/pen/MWeZWxQ %}



---
## For more information

1. Check my GitHub profile
[https://github.com/amitSharma7741](https://github.com/amitSharma7741)

2. Check out my Fiver profile if you need any freelancing work
[https://www.fiverr.com/amit_sharma77](https://www.fiverr.com/amit_sharma77)

3. Check out my Instagram
[https://www.instagram.com/fromgoodthings/](https://www.instagram.com/fromgoodthings/)

4. Linktree
[https://linktr.ee/jonSnow77](https://linktr.ee/jonSnow77)

5. Check my project

- EVSTART: Electric Vehicle is the Future
[https://evstart.netlify.app/](https://evstart.netlify.app/)
-  News Website in react
 [https://newsmon.netlify.app/](https://newsmon.netlify.app/)
-  Hindi jokes API
 [https://hindi-jokes-api.onrender.com/](https://hindi-jokes-api.onrender.com/)


---
---
I Switched To Flutter From Native Android Development- My Story
Published: 2023-02-11 15:00:58

After a few years a web developer, I delved fully into mobile development(specifically native android development) in 2016. For more than three years, I worked on five projects that opened me up into the world of Java and android. Mid-way, I delved into core Java coding too. It was fun and cool, I landed a job that payed me well. I loved java, I loved the structure, the rules, the way it forced me to observe standard coding patterns. Well until… my friend came to me with a job from a client.

The client wanted an iOS and Android versions of a mini-banking app. Prior to this moment, I had experience building just for android. I hadn’t written enough of Swift/Objective-C to take on such a project. Well, once, I converted java code from an android app into platform specific, code for iOS (in Objective-C) using Multi-Engine OS. The experience was fairly immersing, but not too deep.

So I took the job, and immediately I just knew, my only option was flutter. I’m not a big fan of Javascript and excessive usage of command terminals, so I didn’t go for React Native. I had 15 days to deliver the job, meaning, I had 15 days to learn dart, flutter framework, plugins, resources, layouts, structures, build the app, debug and test on both platforms and deploy. I was in for it, but I was excited. I delved in. Long story cut short — After a lot of hours spent perusing Stackoverflow, and Github pages, I delivered the apps within 18 days. Damn! But the experience was amazing. Everything was clicking, responsive. I didn’t have to struggle with separating layouts from classes. I didn’t have to struggle with creating over three classes just to implement something similar to a recyclerview. By the time I was done, I was hooked on flutter and I stuck with it.

Till date, I haven’t been writing much of Java, I’ve rebuilt my company’s mobile apps in flutter, I’ve rebuilt selected features of past projects in flutter, and I’m currently working on a bunch flutter apps. I’ve come across several tools and I’ve met a lot of amazing people within the flutter community.

Flutter is a powerful framework, that absolves you away from the roughest aspects of mobile development . Of course cross-platform development isn’t without its own issues and no matter how good a programmer you are, the app might not give you the 100% performance compared to native apps. All the same, flutter offers you speed, high level efficiency, out of the box animations, responsive material design, flutter apps are already optimized by default and there is also a lossless compression feature that removes all unused classes and dead code within your flutter app. Its called “tree shaking”.

Flutter is still new, and the community is grown and active, you’re guaranteed support and continuity. No worries, your project is safe with flutter. Flutter developers, who don’t have access to a mac, can build once on windows, and build iOS versions of the app using a free platform like Codemagic.io .

As long as flutter remains effective, I think I’ll stay with it!
Ternary if in javaScript
Tags: javascript, is, stament, ternary
Published: 2023-02-11 14:57:24

The ternary if in JavaScript is a shortened way of writing an if/else conditional structure in a single line. It is often used to assign a value to a variable based on a condition, in a more concise and readable way.

Syntax:
The basic syntax of the ternary if is as follows:

condition ? value if true : value if false

Explanation:
The condition is the expression that will be evaluated to check whether it is true or false. If the condition is true, the value to the left of the colon (":") will be assigned to the variable. If the condition is false, the value to the right of the colon (":") will be assigned to the variable.

Example:
An example of using the ternary if in JavaScript would be to check if a number is even or odd and assign a corresponding message to the "message" variable:

let number = 5;
let message = (number % 2 == 0) ? "The number is even" : "The number is odd";
console.log(message);

In the example above, the condition checks if the remainder of the number divided by 2 is equal to zero (if the number is even). If it is true, the message "The number is even" will be assigned to the "message" variable. If the condition is false, the message "The number is odd" will be assigned. The corresponding message is then printed to the console.

The ternary if can be useful in situations where a decision needs to be made based on a simple condition, without the need to write a longer and verbose if/else control structure. However, it is important to use it in moderation and only in situations where the resulting code is clear and readable.
My Journey Into Tech
Published: 2023-02-11 14:55:02

I can't really remember how I started my journey into tech. It has been a while. But I know what brought me here - passion . That passion will keep me here till I age and can't move anymore.

I love coding... scratch that. I'm crazy about coding. I love building software and I have a passion for building software that work. 

I'm a full stack dev, a mobile dev and I believe joining this community will make me a better developer.
An Architecture Proposal!
Tags: programming, opensource, kubernetes, devops
Published: 2023-02-11 14:35:12

I am creating an architecture proposal for e-commerce!

This post will be a little different from the others I’ve published on Medium ; recently, in one of the MBA classes in solution architecture at FIAP, I was challenged to present a proposal for the architecture of a solution for e-commerce that would have millions of simultaneous customers.

to know more:

[https://medium.com/@jlgjosue/an-architecture-proposal-666444c30f9c](https://medium.com/@jlgjosue/an-architecture-proposal-666444c30f9c)
Dart Fundamentals: Variables
Tags: dart, programming, beginners, flutter
Published: 2023-02-11 14:28:33

Variables are the building blocks to know when you learn a new programming language. In today's article we are going to talk about variables in Dart.

Dart has built-in types like other programming language:
- int for integers
- double for floating numbers
- boolean for boolean value
- String for text

To declare a variable in Dart, we define the variable type followed by the variable name
```dart
int currentYear = 2023;
double pi = 3.14;
bool isAdult = true;
String name = "Lionel Messi"
```
## Type inference: var & dynamic
Although, you are not forced to specify the variable type thanks to a mechanism called "type inference". It means that Dart can infer (or simply guess) the type of the variable
```dart
var myAge = 27;
var country = "Madagascar"
```
In the example above, Dart will assume that the variable myAge is an integer and the variable country is a string due to the presence of the double quotes. When declared with the var keyword, the type of the variable can't be changed throughout the execution of the program.

The dynamic keyword can also be used to declare a variable. The difference with var is that the type of the variable can change during the execution of the code.
```dart
dynamic myVar = "Hello"
print(myVar.runtimeType) // String 
myVar = 123
print(myVar.runtimeType) // int 
```
The important thing to remember is:
- var can't change the TYPE of the variable, but can change the VALUE of the variable later in code
- dynamic can change the TYPE of the variable and can change the VALUE of the variable later in code
- final can’t change TYPE of the variable, and can’t change VALUE of the variable later in code.

For example
```dart
var myVar = "Hello"
dynamic myDynamicVar = "Hello"
myVar = 123 // not possible
myDynamicVar = 123 // possible
```

Note: If you state a var without intializing, it becomes a dynamic
```dart
var myVar;
myVar = "abc";
print(myVar.runtimeType) // String
myVar = 1245;
print(myVar) //1245
print(myVar.runtimeType) // int
```
That's all for today's article. If you want to deep dive into the fundamentals of Dart, check out the [official documentation](https://dart.dev/guides).
Navigating the World of Optimization: Separating Fact from Fiction in Software Engineering
Published: 2023-02-11 14:03:26

The art of software engineering often involves navigating through a sea of lies and misconceptions. Among the many pitfalls, there are four types of falsehoods that engineers must be wary of: lies, damned lies, statistics, and **blind belief** in optimization tricks that haven't been proven in practice.

It's all too common to believe that you've made your app faster by implementing certain optimization techniques, only to find out later that they haven't made a difference. This is often due to the human factor - the tendency to rely on experts and ignore the importance of hard data.

As engineers, we're comfortable debating design decisions, APIs, and naming conventions, but when it comes to performance optimizations, we often fall into the trap of **blindly following the advice of supposed experts**. These experts, who may work at prestigious tech companies, spread information about how to optimize code, and their ideas are often widely adopted without being critically evaluated. It's important to keep in mind that when it comes to optimization, what works for others may not necessarily work for you. Experts may offer well-intentioned advice, but it's always crucial to evaluate the unique context of your project and to approach optimization with a critical eye. Remember, even experts can change their minds, and it's always a good idea to **base decisions on data and metrics**, not just on hearsay.

The challenge of fact-checking and debating these optimizations is that it can be time-consuming and complex, and many engineers may feel intimidated by the thought of challenging well-known industry leaders.

To avoid falling into this trap, it's important to approach optimization decisions with a critical eye and rely on hard data and metrics to make informed choices. Your code should not be a platform for self-expression or impressing others with your cleverness. Instead, it should be a precise and well-documented solution to a specific problem.

In the end, our job as software engineers is to **simplify complexity**, and this includes being mindful of the falsehoods and misconceptions that can cloud our judgement. Always question assumptions and **rely on data**, not belief, when optimizing your code.
I blundered.
Published: 2023-02-11 14:01:01

Blogs on dev.to, are starting to get to clickbaity and unoriginal ie.10 ways to make money through blogging, 2 ways to, 30 things too. Its all the same thing over and over again. 

And I thought I could change that, by bring in original blogs, and still grow at the same time. 

But everything need to be SEO optimized, and its only those unoriginal, information blogs that look good. 

I don't know if there is really any point in continuing this blog, if I have to do things like that for SEO optimization. 

I don't know what I am going to do.
Longest Word JavaScript challenge
Tags: javascript, programming
Published: 2023-02-11 13:41:25

**[Coderbyte ](https://coderbyte.com/)** has this challenge among the free ones:

_Have the function LongestWord(sen) take the sen parameter being passed and return the longest word in the string. If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will not be empty. Words may also contain numbers, for example "Hello world123 567"._

Here is my solution, with explanations in the form of  comments:

```
function LongestWord(sen) { 
  // An aray of words made up of letters only
  let cleanWords = [];

  let words = sen.split(' ');
  words.forEach(word => {
    // Clean up the words and push them into "cleanWords"
    cleanWords.push(word.replace(/[^a-zA-Z0-9]/g, ''));
  });

  // Order by size
  let cleanWordsBySize = cleanWords.sort((a, b) => b.length - a.length);
  
  // Get the first
  return cleanWordsBySize[0];
}
```

It passed all the tests. :)
Hey , I need help
Tags: help
Published: 2023-02-11 13:23:46

When I write 
<head>
<link rel="stylesheet" href="style4.css>
</head>
 But I can't locate my css file here. It always show error but when I pasted the whole css content in between the <head> element then it's working properly. Style code is
<style>
a:link, a:visited {
background: red;
color: white;
padding: 15px 25px;
text-align: center;
display: inline-block;
}
a:hover, a:active {
background-color: red;
}
</style>
Meet Brave CMS 2.0
Tags: laravel, php, cms
Published: 2023-02-11 13:15:06

**[Brave CMS 2.0](https://github.com/Ajax30/BraveCMS-2.0)** is fresh out of the oven.

### What it offers 

It offers UI/UX developers and designers the possibility easily turn their static templates into websites powered by *MySQL and Laravel*.

### What makes it so great

It is great for several reasons:

1. It's written in Laravel 8.
2. It's scalable.
3. The code is DRY and easy-to-follow, so contributors will have no headaches.
4. The newsletter form is integrated with Mailchimp.
5. It's Admin is designed with Bootstrap 5 SASS and very easy to customize.
6. It is free (but patrons will be appreciated).

### Video demo

{% embed https://www.youtube.com/watch?v=AEMUFTxO4uc %}

It has an _easy-to-follow installation guide_ so try it out. It is free on GitHub. If you like it, give it a star.
case / when
Published: 2023-02-11 10:49:30

```rb 
class Ticket
    attr_accessor :venue, :date
    def initialize(venue, date)
        self.venue = venue
        self.date = date
    end

    def ===(other_ticket)
        self.venue == other_ticket.venue
    end
end

ticket1 = Ticket.new("town hall", "01/01/2022")
ticket2 = Ticket.new("conference", "01/01/2022")
ticket3 = Ticket.new("town hall", "08/05/2000")
puts "ticket1 is for an event at : #{ticket1.venue}"

case ticket1 
when ticket2
    puts "same location as ticket2"
when ticket3
    puts "same location as ticket3"
else 
    puts "no match!"
end
```
Devgym Retro Janeiro 2023
Tags: devgym, startup, webdev
Published: 2023-02-11 12:27:19

Hey! Como foi seu começo de ano? O primeiro mês de vida da Devgym foi muito legal, depois de lançarmos os [cinco desafios](https://app.devgym.com.br/challenges) iniciais na plataforma tivemos alguns devs que não só treinaram como completaram vários desses desafios 😱. Parabéns [Rafael Ribeiro](https://github.com/rafaelmgr12), [Juliano Silva](https://github.com/julianojj) e [lu-css](https://github.com/lu-css/). Monstros!

Confesso que as implementações vieram mais rápido que (pessoalmente) minha velocidade de revisão 😅, por isso lançamos uma [página](https://app.devgym.com.br/solutions) que lista as soluções recentes, e mandei um review para [alguma](https://github.com/julianojj/desafio_encurtador_url/issues/1) delas que [espero](https://github.com/rafaelmgr12/moviesgo-cli/issues/1) ter ajudado. 

Ainda vamos trabalhar mais em como notificar outros devs para ajudar no review (central de notificações no site? servidor no Discord? O que você acha?), mas por enquanto nossos esforços estão focados em lançar o Devgym Pro, pra que alguns desafios tenham uma solução oficial com código fonte e vídeo aula. Imagino que isso já funcione como uma forma de auto code review.   

Além disso espero ter novos desafios em breve na plataforma, estava pensando em um baseado num certo reality show de sucesso, mas isso é assunto para outro post. Qualquer dúvida ou até sugestão de tech challenge, entre em contato aqui ou em devgymbr@gmail.com. Tchau!
Run Commands on an EC2 Instance with AWS Systems Manager
Tags: aws, cloud, awscommunity, 100daysofcloud
Published: 2023-02-11 12:15:37

[42/100] #100DaysOfCloud Today, I created an EC2 instance and remotely run a command using AWS Systems Manager.

Amazon Systems Manager is a management service that helps you automatically collect software inventory, apply OS patches, create system images, and configure Windows and Linux operating systems. These capabilities help you define and track system configurations, prevent drift, and maintain software compliance of your EC2 and on-premises configurations. By providing a management approach that is designed for the scale and agility of the cloud but extends into your on-premises data center, Systems Manager makes it easier for you to seamlessly bridge your existing infrastructure with Amazon Web Services.

Systems Manager is easy to use. Simply access Systems Manager from the EC2 Management Console, select the instances you want to manage, and define the management tasks you want to perform. Systems Manager is available now at no cost to manage both your EC2 and on-premises resources.

Use AWS Systems Manager to remotely run commands on your Amazon EC2 instances. Systems Manager is a management tool that enables you to gain operational insights and take action on AWS resources safely and at scale. Using the run command, one of the automation features of Systems Manager, you can simplify management tasks by eliminating the need to use bastion hosts, SSH, or remote PowerShell.

You can try do it by yourself by following the steps from the link below: [GitHub](https://github.com/aaditunni/100DaysOfCloud/blob/main/Journey/042/Readme.md)