teleren/devto huggingface dataset:
Firestore simple string search
Tags: search, firebase, firestore, angular
Published: 2021-05-02 22:11:50

> This post uses javascript, however you can apply this concept to any firebase client.

You can query firestore (a firebase db) quite easily. But when it comes to string search; they dropped the ball and send you to third party search solutions. There is nothing wrong with that if your project needs a full text search; but what if you just want a simple string starts with search (like*)? hopefully firestore will do something about this.

For now, let me share what I have done for IPster. [IPster app](https://ipster.io) needed a simple search by first name. And for now we didn't wanted to invest in or use systems like Algolia (nothing against Algolia, I love the product and we probably be using it in the future).

So how do you search firestore for something like 'get me all documents where name starts with sam'

## Using firebase javascript client
This should work for most languages.

```javascript
searchTerm = searchTerm.toLowerCase();
strlength = searchTerm.length;
strFrontCode = searchTerm.slice(0, strlength-1);
strEndCode = searchTerm.slice(strlength-1, searchTerm.length);
// This is an important bit..
endCode = strFrontCode + String.fromCharCode(strEndCode.charCodeAt(0) + 1);
```
Query using the start and end codes and you will be able to get the same results as you would in traditional databases LIKE 'a%'
```javascript
db.collection('collectionName').where('fieldName', '>=', searchTerm).where('fieldName', '<', endCode).limit(10);
```
That's it. You should be able to do simple 'starts with' search now. It's a good practice to limit the result set since Firebase will charge you for all documents returned. And if you are using firebase in an open project, you can also setup rules to limit the query results.

## Using Angularfire
For IPster we are using Angular fire which makes dealing with complex queries a little easier. Let me give you an example of how we implemented a simple starts with query together with Observable and switchMap
```javascript
import { Observable, Subject, combineLatest } from 'rxjs';
import { switchMap } from 'rxjs/operators';

startCode = new Subject();
endCode = new Subject();

// Once only, in your constructor or init
searchResults = combineLatest(
   this.startCode,
   this.endCode
 ).pipe(
   switchMap(([startCode, endCode]) =>
     fireStore.collection('collectionName', ref => ref.where('fieldName', '>=', startCode).where('fieldName', '<', endCode).limit(10)).valueChanges()
   )
 );
         
// Prepare endCode and searchTerm as described in the previous section
// Now you can change the query and get the results (search as you type etc..)
this.startCode.next(searchTerm);
this.endCode.next(endCode);
```
There you have it.
Part 5 video of pair programming a Perl web app
Tags: perl, webdev, meetup, mojolicious
Published: 2021-05-02 21:53:27

---
title: Part 5 video of pair programming a Perl web app
published: true
date: 2021-05-02 21:37:43 UTC
tags: Perl,webdev,meetup,Mojolicious
canonical_url: https://phoenixtrap.com/2021/05/02/part-5-video-of-pair-programming-a-perl-web-app/?utm_source=rss&utm_medium=rss&utm_campaign=part-5-video-of-pair-programming-a-perl-web-app
series: Live-coding a web app in Perl and Mojolicious
---

Gábor’s already [posted today’s video](https://perlmaven.com/course-management-app-in-mojolicious-5)!

{% youtube ooxYP38usgs %}

It’s really interesting to see our different development styles work together. Gábor’s all about trying things immediately and searching the entire web for answers, while I like to read the documentation and work out its writers’ intent.

I’m also embarrassed that we ended on a “cliffhanger” with an unresolved error, though Gábor posted that he managed to resolve it.
Welcome to Therapy with Ease!
Published: 2021-05-02 20:03:58

I created a Sinatra web application that will be able to facilitate what many people struggle with and ease them into finding the help they need without feeling the pressure to do so. My web application works like a third party website that focuses on setting appointments to facilitate the needs of the clients and for the company that will use the appointments made to reach the client.

My website is user friendly with a minimalistic style to have a great customer experience. Even with the simplicity of my code, I had challenges trying to find an easy way to format my appointment sheet to assist the user set an appointment quicker.

I came up with this: 
![Alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6kt8hr784lwpneanxuu6.png)

Not only does it require my user to input a date and a time, it won't let them submit it with out it!

I enjoyed myself, (now looking back) to be able to face my challenges head on with our labs assisting me along the way as there are no test to past and try over and over until you see all the green test speeding past you in the terminal.

I have high hopes for my web application to make the new tomorrow a more user friendly one.

Check out my full web application at 
https://github.com/LitatyHQ/01_sinatra_project
LeetCode 122. Best Time to Buy and Sell Stock II (javascript)

Tags: algorithms, javascript
Published: 2021-05-02 20:01:25

###Description:
You are given an array prices where prices[i] is the price of a given stock on the ith day.

Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).

Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

###Solution:
Time Complexity : O(n)
Space Complexity: O(1)

```javascript
 var maxProfit = function(prices) {
        let maxprofit = 0;
        for (let i = 1; i < prices.length; i++) {
            // Add to the max profit total if the current price is greater than previous
            // We "sell" when the the opposite is true because we will not buy on days that dip.
            if (prices[i] > prices[i - 1])
                // Add the increse in price to our profit
                maxprofit += prices[i] - prices[i - 1];
        }
        return maxprofit;
};
```
How to install Anbox on Debian
Tags: linux, android, tutorial
Published: 2021-05-02 20:00:25

While waiting to see how it works on the PinePhone, I've recently tried to install [Anbox](https://anbox.io/) on a Debian (Bullseye), and found out that the official documentation or other online articles don't have proper Debian instructions. Most of those articles are based on Snap, while nowadays everything is present to install it the Debian way.

After digging around, it turns out that most of what I will describe here is properly documented in the dedicated Debian README (`/usr/share/doc/anbox/README.Debian`), but I have to admit that it took me time to find it and I personally often prefer a simple and visual tutorial.

So, here is what I had to do to run Anbox and the F-Droid apk on Debian!

# Core installation

The first thing to do is of course to install Anbox itself:

```
$ sudo apt install anbox
```

Then, as stated in the [official doc](https://docs.anbox.io/userguide/install.html#install-kernel-modules), check that the necessary kernel modules are enabled:
``` 
$ ls -1 /dev/{ashmem,binder}
```

If not:
```
$ sudo modprobe ashmem_linux
$ sudo modprobe binder_linux
```

If like me, `/sbin` is not in your `$PATH` (`modprobe: command not found`), add it or use the full path:
```
$ sudo /sbin/modprobe ashmem_linux
$ sudo /sbin/modprobe binder_linux
```

At that point, if you try to run it (`anbox session-manager`), you will probably get the following error:
```
Failed to connect to socket /run/anbox-container.socket: No such file or directory
```

# Android image

Anbox indeed expect to find an Android image at `/var/lib/anbox/android.img`.
Download the latest image available at https://build.anbox.io/android-images/ and move it there:

`$ sudo mv ~/Downloads/android_amd64.img /var/lib/anbox/android.img`

Restart the service:
```
$ sudo service anbox-container-manager restart
```

You should now be able to run Anbox, either from your Desktop environment launcher, or with the following command:
```
anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
```

![Anbox in XFCE Whisker Menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b7j2ikppgdlcg674g2aj.png)

# Installing and running APKs

This last part is well explained in the [doc](https://docs.anbox.io/userguide/install_apps.html). Start by installing adb:
```
$ sudo apt install android-tools-adb
```

You now have everything needed to install new applications:
- Open the Anbox Application Manager
- Download F-Droid: `$ wget https://f-droid.org/F-Droid.apk`
- Install the apk: `$ adb install F-Droid.apk`

You should now see F-Droid in Anbox Application Manager!
![Anbox Application Manager](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2v2b5ve6566xrbzp0um.png)

---

Refs:
https://superuser.com/a/1464899
https://lists.debian.org/debian-user/2021/01/msg00894.html
https://github.com/anbox/anbox/issues/123
How many hours per day you should spend learning programming
Tags: productivity, devjournal, programming, codenewbie
Published: 2021-05-02 20:00:03

As a Fullstack Software Engineer, I have already walked the path of learning. I wanted to share some of my tips, what I have witnessed from others and what worked for them.

**1. Every number is different for each person:**

   Anyone can sit and start learning to program, but each person will arrive at the destination based on the path they took and if they had any help on the way. I have seen people taking almost a year and some just about 4 months to become web developers and find their first job. People that took a long time to learn had to make a lot of try and error, and unfortunately, no one was there to guide them. So if you are starting in web or software development in general, don't get discouraged because it's taking you a long time to understand a topic. But use this as an opportunity to learn and perhaps try to find a mentor who walked that path and can guide you.

**2. Consistency is the key:**

   If you have decided to become a web developer (or any software developer), give yourself a deadline and how many hours you can allocate a day to work toward that goal. Now, this part is very important, ready? Be honest with yourself. If you say 12 hours a day and your deadline is 6 months from now. Can you study every day for 12 hours consistently for 6 months? Well, first, you shouldn't do that, so be reasonable and very critical of this part as you may discourage or burn yourself out halfway.

**3. Be patient:**

   Like for anything in life, you need to be patient about the process. 4 months or 1 year, and it will take time one way or the other. All you can do is prepare and have fun while doing it. There is nothing much to say about this one, but it is essential to point that out since many of us want to get to the destination fast and forget that it takes time, and you do need patience for this.

These are my top 3 points that should help you predict how many hours you may need before getting that first job. You can subscribe to my channel DevPool as my goal is to help beginners and juniors succeed in the tech industry.

[YouTube - DevPool](youtube.com/channel/UC03vw5F2isFkbJhyEZU5bvg?sub_confirmation=1 "DevPool")
Understanding Django.
Tags: django, webdev
Published: 2021-05-02 18:55:10

#Before heading into the topics we are supposed to focus on the questions on Django that are been listed below.:)

# 1?
#What is Django?✨✨✨✨✨

Django is a ✨free open-source web application Framework.

#✨
#Open source means? #A project for which the original source code is made freely available and may be redistributed and modified according to the requirement of the user.

#Framework means✨? #Framework gives you a basic structure around which you will write your code to have✨e the greater functionality of the system.

✨✨
✨✨ model view template.
✨✨ 


#2? 
#What we can do with Django?

Frontend [looks] : HTML , CSS , JSS
Backend [funcionlity] : Django.
Database [ data storage] : Sqlite3.



#Why Django?


#Fast Development Phase
#fully loaded 
#versatile
#secure
#high demand
#scalable
#python ecosystem
#proper defined structure
#rich django ecosystem.
#maturity
#good number of libraries
#admin panel by default.

Thank you:)
Be a Good Civilian In The Open Source World
Published: 2021-05-02 19:37:08

A year ago, during one of the hottest days at the end of May, I found myself preparing to give a lecture about how to be part of the software community in front of CS students. There were a lot of things I wanted to talk about. One of them was open source, but I didn’t know where this road would lead me to. 
A journey that made the **[Pull Request](https://pullrequest.co.il/?fbclid=IwAR3OFOaKgRgU7GUJ-Rs1X3DhdZEidVtOQg7u4w3luq5fwjt9Dq1vLtId0QA)** community alive.

---

When people talk about contributing to open source, they often think that it means that:
**contribution to open source == merge a PR to project without any profit**.

I'm here to say: **"that’s not true!"**.

You can think about **open source as a** separate **civilization**, and as one, the first thing you should do is to adopt its **code of conduct** and **form of thinking**.

so what are the main ideas behind the code of conduct and the way of thinking? I can think of three.

---

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2vj7do33f0rrk6lnveo8.png)
Don’t wait until someone else finds the bug and fix the problem, if you see a bug and you can fix it - just fix it and open a PR.
<br/>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2yrb5eejgqy2f904afz.png)
If you see a problem that you can't fix, for any reason, open an issue about it in the project’s repository. this is very helpful to the project and its maintainers.
<br/>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/03dwz27tt9qhis427x6q.png)
However, similar to cities, consider your PRs like a change to the city’s side roads, you probably need to let the city’s council (the maintainers) know about the changes you would like to commit into the project before you put all your effort into building something that will not be approved in the end.
<br/>

---

In the open source civilization, the libraries and projects are our cities, the maintainers are the municipalities, and the Github issues pages are the call centers. Like in real cities, you can just live there, or you can take part in the community.

It's your choice. 🙂
Making API requests in Laravel
Tags: laravel
Published: 2021-05-02 19:28:21

---
title: Making API requests in Laravel
published: true
description: How to make simple API requests in Laravel
tags: Laravel
//cover_image: https://direct_url_to_image.jpg
---
Laravel has a very simple way to make APIs. This article will show you how to make these simple requests.
#Get requests
To create a basic request, open `routes/api.php` and create get request, the syntax looks like that
```
Route::get('/articles', function() {
    return 'Articles';
});
```
This code will return a page with "Articles".
#Return JSON
To return a simple JSON response simply use `response()->json` 
```
Route::get('/user', function() {
    return response()->json([ 'name' => 'John', ]);
});
```
FOUR USEFUL PYTHON LIBRARIES YOU DON'T KNOW ABOUT
Tags: python, tutorial
Published: 2021-05-02 19:27:42

# I Introduce 4 Python Libraries And Make A Mini Project
In [this post](https://www.iceorfire.com/post/four-useful-python-libraries-you-dont-know-about), I teach you how to use Delorean, FuzzyWuzzy, Emoji and Inflect.

## Delorean
It's more than just a time-traveling car! Delorean makes using Datetime objects simple.

## FuzzyWuzzy
He may be a bear with no hair but he's also a powerful fuzzy matching library.

## Emoji
You can easily use all of your favorite emojis in your Python code with this library.

## Inflect
Inflect is an amazing library that will help you write better messages/output for your users as well as a boatload of other things.

# Show Me The Code
[View the code and build our small MadLibs project](https://www.iceorfire.com/post/four-useful-python-libraries-you-dont-know-about).

# Support Me
If you find these tutorials helpful, please consider [buying me a coffee](https://www.buymeacoffee.com/z4F8QVS6w). Thanks!
Setting Up My New Box
Tags: devops
Published: 2021-05-02 19:26:27

Bio
25 Yr Gen IT/IS,10 MED IT/IS,20 Yr Buis Workflow Analyst, 15 Advanced Fin and Econ
Spec. TCO, TCSP, Custom Data Mining and Analysis
Hobbies:Photography, Species Observation, Cross Relational Learning, Tech, Hiking Camping, Reading, Journaling.
Education BA CS MA Research
Currently Involved Education: Masters DataScience, MPub Health, Vet Medicine
Pets:Two Cats Kola and Pan
“Users” Auth0? 
Tags: react, help, javascript, mongodb
Published: 2021-05-02 19:21:32

What’s the best way to create a “sign up” login”, or well just “users - PROFILES” for your site? 

I was thinking Django, but it’s proving to be a bit annoying. Then I’m thinking maybe Apollo GraphQL, but... I’m not sure. 

Tho


I have just found “Auth0”? Is that good? 

I want people to be able to bid on products, then the profile to be placed as the “highest bidder” on a list. 

Currently I’m using React + Airtable.
deep q learning from scratch project
Tags: deeplearning, machinelearning, python
Published: 2021-05-02 19:14:29

I'm trying to make a proejct for school, a deep q learning project from scratch, obviously in a dev container enviroment, with an Agent class and a NeuralNetwork abstract class.
It use gradient discent for optimization, e-greedy algorithm for exploration vs exploitation.
https://github.com/LorenzoTinfena/deep-q-learning-itt-final-project
sample: https://drive.google.com/file/d/1rpj_q0yWhHk19fWHck_IgzEuirXwNQaJ/view?usp=sharing
Key takeaways from the taskforce Bootcamp
Tags: bootcamp, softskills, hardskills
Published: 2021-05-02 19:12:12

The Taskforce Bootcamp is an [Awesomity Lab](https://awesomity.rw/) program (in partnership with [Code of Africa](https://codeofafrica.com/)) that has the vision of upskilling talented software engineers in Rwanda. 

In a period of two months I spent in this Bootcamp, I acquired a lot of skills that will assist me in my career of software engineering. In this journal, I will highlight a few of the many key takeaways I acquired in soft and hard skills during this period.

Starting from hard skills, I’m going to explain strong skills I acquired in a few bullets below:

* **TypeScript:** a strict syntactical superset of JavaScript and adds optional static typing to the language.

* **NestJS:** a framework for building efficient, scalable Node. js server-side applications, built with and fully supports TypeScript. As a backend engineer during this Bootcamp, I collaborated on different projects built in NestJS and TypeScript.

* **DevOps** is a set of practices that combines software development and IT operations. It aims to shorten the systems development life cycle and provide continuous delivery with high software quality.

While I’m talking about the hard skills I can’t forget the Data structure and Algorithm challenges that we used to do to sharpen our skills in JavaScript.

Soft skills are another important skill I can’t skip. In the following bullets, I summarised many keys and knowledge I learned through this Bootcamp.

* **Teamwork:** Due to the team's projects I collaborated on, I acquired the skills of collaboration and professional communication.

* **Project management:** During the Bootcamp through sessions I learned how to manage projects without getting stressed by managing time wisely.

* **Professional writing:** during the Bootcamp every week you write a journal explaining what you learned. This writing taught me to organize and write professionally.

I humbly thank [Awesomity Lab](https://awesomity.rw/) and [Code of Africa](https://codeofafrica.com/) for their invaluable support and assistance they show in this program.

Thank you for reading!
LeetCode 337. House Robber III
(javascript solution)
Tags: algorithms, javascript
Published: 2021-05-02 19:07:00

###Description:
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called root.

Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will automatically contact the police if two directly-linked houses were broken into on the same night.

Given the root of the binary tree, return the maximum amount of money the thief can rob without alerting the police.

###Solution:
Time Complexity : O(n)
Space Complexity: O(n)

```javascript
 var rob = function(root) {
    // Choose between using values at root + grandchildren (current) or using values from children (next)
    const { current, next } = traverse(root);

    return Math.max(current, next);
};

function traverse(root) {
    // If there is not root ther is no root value or grandchildren values (current) and there are also no children values (next)
    if (!root) {
        return { current: 0, next: 0 };
    }
    
    // Get values for children
    const left = traverse(root.left);
    const right = traverse(root.right);
    
    // Value if we include the root node in our robbing path
    const current = root.val + left.next + right.next;
    
    // Max Value if we include the children in our robbing path
    const next = Math.max(left.current, left.next) + Math.max(right.current, right.next);

    return { current, next };
}
```