teleren/devto huggingface dataset:
iOS — Designing Data Layer For Offline-first Apps
Tags: mobile, ios, android, offline
Published: 2022-06-17 11:39:19


Ever wondered how note-taking apps like Evernote or chatting apps like Whatsapp keep working without the internet?

Not only you can use the existing data, but you can also send a message or add a note and it will sync when the internet becomes available.

That’s not magic! Those apps are designed in such a way.

OK, let’s start with the concept offline-first apps.

Offline first apps are architected in a way that they will continue working normally even during the time when you have bad internet or no internet at all.

In the generation of the Internet, why do you need offline first apps? 

Let’s discuss its importance and implementation with an example.

Offline-first apps are very pleasant to use and certainly delight the users as they are never blocked by the internet when they want to take action, especially in a world where everybody has very limited time!

As we now understand the concept and its importance, let’s see how we can start creating those types of apps. To read full article, [visit our blog](https://blog.canopas.com/ios-designing-data-layer-for-offline-first-apps-f929c83bb195).
Applying neural search while labelling your data
Tags: ai, showdev, datascience, design
Published: 2022-06-17 11:37:55

Hey there everyone ! Today we’ll be talking about applying neural search while labelling your data. When neural search has been activated, it enables you to find the closest text based on transformer embeddings. This helps users to quickly identify common patterns and understand their data better. We believe in a platform where users have a higher degree of freedom when it comes to customising the data. User’s can now apply any embedding without any limitations which offers maximised customisability. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ar6ymily6zxnzhj7eo8u.png)


Subscribe to our newsletter 👉🏼 [kern.ai](https://www.kern.ai/pages/open-source) and stay up to date with the release so you don’t miss out on the chance to win a GeForce RTX 3090 Ti for our launch!
Python exercise 12: find the hidden ball
Tags: python, beginners, challenge
Published: 2022-06-17 08:47:54

## Question
- Create a function that returns the letter position where the ball final position is once the swapping is finish.

### description
- There are three cups on a table, at positions **A, B, and C.** At the start, there is a ball hidden under the cup at **position B**.



![Three red cups facedown](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j47rnydh4b7185830ske.png)
- There will be several swap perform, represented by two letters.
- For example, if I swap the cups at positions **A and B**, this can be represented as `AB` or `BA`.

### Examples

```
cup_swapping(["AB", "CA"]) ➞ "C"

cup_swapping(["AC", "CA", "CA", "AC"]) ➞ "B"

cup_swapping(["BA", "AC", "CA", "BC"]) ➞ "A"
```


## My solution
- 1. initialise a current position "B"
- 2. iterate over the list of swap combination
 - 2.1 iterate over each swap combination
- 3. check the ball have been swap
 - 3.1 if current position is exist in the swap combination, it is swapped
 - 3.2 update the current position 
 - 3.2.1 if current_position equals to the first letter
 - 3.2.2 then final letter is the current position
 - 3.3.1 if current_position not equal the first letter
 - 3.3.2 then first letter is the current position
- 4. print the final position

```python
def cup_swapping(swaps):  
    current_position = "B"  
    for move in swaps:  
        if current_position in move:  
            if current_position == move[0]:  
                current_position = move[1]  
            else:  
                current_position = move[0]  
    return current_position 
```
## Solution by others
### Method 1
- shorten version of my answer

```python
def cup_swapping(swaps):  
    current_position = "B"  
    for move in swaps:  
        if current_position in move:  
            current_position = move[1] if move[0] == current_position else move[0]  
    return current_position
```
### Method 2

```python
def cup_swapping(swaps, current_position="B"):  
    for move in swaps:  
        current_position = move.replace(current_position, "") if current_position in move else current_position  
    return current_position
```
- key point
- iterate over each swap
	- in the swap, there is two letter
	- if the current position appear in the swap, replace that letter with empty string 
		- i.e. replace "AB" to "A" if current position is "A"
		- and also update the current position to the remaining single letter
	- if the current position do not appear in the swap, keep the current position

## My reflection
- It is a good feeling to solve a problem without hint. First I got stuck when just write the code, then I try to solve the question by writing the algorithm down, it sudden feel much easier to think. Thus, I will make the habit the write down the algorithm first rather coding at first. Beside, I learn new way to shorten the if else statement

## Credit
challenge found on [edabit](https://edabit.com/challenge/M47FDJLjfNoZ6k6gF)
Your most productive terminal with Oh My Zsh and spaceship
Tags: ohmyzsh, spaceship
Published: 2022-06-17 11:22:55

Install Zsh
```bash
sudo apt-get install zsh
```

Clone the zsh
```bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
```

Install Spaceship
```bash
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"
```

Create a symbolic link
```bash
ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
```

Set Spaceship Theme, enter in ~/.zshrc
```
sudo nano ~/.zshrc
```

Within ~/.zshrc, find the line 
```bash
ZSH_THEME and change it to > ZSH_THEME="spaceship"
```

Configure Spaceship

At the end of the ~/.zshrc file I add the following content
```bash
SPACESHIP_PROMPT_ORDER=(
  user          # Username section
  dir           # Current directory section
  host          # Hostname section
  git           # Git section (git_branch + git_status)
  hg            # Mercurial section (hg_branch  + hg_status)
  exec_time     # Execution time
  line_sep      # Line break
  jobs          # Background jobs indicator
  exit_code     # Exit code section
  char          # Prompt character
)
SPACESHIP_USER_SHOW=always
SPACESHIP_PROMPT_ADD_NEWLINE=false
SPACESHIP_CHAR_SYMBOL="❯"
SPACESHIP_CHAR_SUFFIX=" "
```

Plugins

To configure a plugin, we also have to edit the ~/.zshrc file by adding or removing the plugin names in the variable array:
```bash
plugins=(git)
```

zsh-history-substring-search
- Includes history features
```bash
git clone https://github.com/zsh-users/zsh-history-substring-search.git ~/.oh-my-zsh/custom/plugins/zsh-history-substring-search
```

zsh-syntax-highlighting
- Highlight the command pack as they are typed
```bash
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
```
zsh-autosuggestions
- Suggest commands based on history based on your typing
```bash
git clone https://github.com/zsh-users/zsh-autosuggestions.git ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
```

fzf locator
- ctrl+t will allow you to search any file/directory on the system
```bash
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install
```
i'm stuck in creating a kivy app
Tags: python, sql, mysql
Published: 2022-06-17 11:12:49

hello, am trying to build an kivy app ,so that i can sell my products on it ,the question is, how to and where to store products in the app and when i can update them anytime ,

i really need the soloution coz am puzzled i dont know what to do
am just a self teaching programer, i really need help please!
Instagram Private API WEB- Node
Published: 2022-06-17 11:12:13

Simple, easy implementation of the Instagram private web API.
Some API reference from [jlobos/instagram-web-api](https://github.com/jlobos/instagram-web-api)
Send DM using client from [dilame/instagram-private-api](https://github.com/dilame/instagram-private-api)

## How to install

```
npm i instagram-web-api-node
```

## How to use

```
const { IgApiClient } = require("instagram-web-api-node");
function save(data){
  let cookie = JSON.stringify(data); 
  //save cookie to file or database after 
  //code save
  return cookie;
}
(async () => { 
  try {
      const instagram = new IgApiClient();
      // This function executes after every request
      instagram.request.end$.subscribe(async () => {
        const serialized = await instagram.state.serialize();
        save(serialized); 
      });
      //set login account
      const { username, password } = process.env; 
      await instagram.state.generateDevice(); 
      //login use account username and password
      await instagram.ig.login(username, password);
  } catch (error){
      console.log(error.name)
  }
})();
```

## How to login without username and password

```
const { IgApiClient } = require("instagram-web-api-node");
(async () => { 
  try {
      const instagram = new IgApiClient();
      await instagram.state.deserialize(cookie); //cookiejson
      
      const follow = instagram.ig.follow(userid);
  } catch (error){
      console.log(error.name)
  }
```

An example of a website that uses this API: [Auto Followers Instagram](https://www.gooo.blog/)
Talk to random strangers with webcam?
Published: 2022-06-17 11:07:52

The [Omegle tv](https://omegle.net.co/) webcam is possibly the highest rated technique that has been noticed by customers across the world. These webcam factory live video trips were taken from 2009 to 2009. The possibility of an inconsistent video chat office. In addition, this phase of change from the largest in the main square, where many days, countless unknown guests. Sporadic video calls. Likewise, the [Chatstep](https://chatstep.onl/) Webcam Free Calls scheme works without a data negotiation framework. Also, admission to data collection is not required.

This page only requires part of the customer's information for the camera to talk to the ideal co-cement date. So in that specific situation, ask for customer review as channels. Define a channel as essential general information, e.g. customer gender, customer country, etc. Also, the body never returns this information with an assertion. This information is simply welcomed because of the Talk camcorder's relationship to your information.
Break a Palindrome
Tags: leetcode, dsa, theabbie
Published: 2022-06-17 11:00:46

Given a palindromic string of lowercase English letters `palindrome`, replace **exactly one** character with any lowercase English letter so that the resulting string is **not** a palindrome and that it is the **lexicographically smallest** one possible.

Return _the resulting string. If there is no way to replace a character to make it not a palindrome, return an **empty string**._

A string `a` is lexicographically smaller than a string `b` (of the same length) if in the first position where `a` and `b` differ, `a` has a character strictly smaller than the corresponding character in `b`. For example, `"abcc"` is lexicographically smaller than `"abcd"` because the first position they differ is at the fourth character, and `'c'` is smaller than `'d'`.

**Example 1:**

**Input:** palindrome = "abccba"
**Output:** "aaccba"
**Explanation:** There are many ways to make "abccba" not a palindrome, such as "zbccba", "aaccba", and "abacba".
Of all the ways, "aaccba" is the lexicographically smallest.

**Example 2:**

**Input:** palindrome = "a"
**Output:** ""
**Explanation:** There is no way to replace a single character to make "a" not a palindrome, so return an empty string.

**Constraints:**

*   `1 <= palindrome.length <= 1000`
*   `palindrome` consists of only lowercase English letters.

**SOLUTION:**

    class Solution:
        def breakPalindrome(self, palindrome: str) -> str:
            n = len(palindrome)
            if n == 1:
                return ""
            isNotA = False
            minstr = ""
            for i in range(n):
                if palindrome[i] > 'a' and 2 * i + 1 != n:
                    minstr = palindrome[:i] + 'a' + palindrome[i+1:]
                    isNotA = True
                    break
            if not isNotA:
                return palindrome[:-1] + 'b'
            return minstr
Situação do GraphQL em 2022
Tags: graphql, survey, stateofgraphql
Published: 2022-06-17 10:51:23

Está aberta a primeira pesquisa da comunidade sobre a situação do GraphQL em 2022 ! [#StateOfGraphQL](https://twitter.com/hashtag/StateOfGraphQL)

O formulário com as questões está disponível em português [https://www.stateofgraphql.com/pt-br/](https://www.stateofgraphql.com/pt-br/) e visa responder **quais ferramentas e recursos estão realmente sendo utilizados**.

Você desenvolvedor não deixe de participar, juntos vamos entender a real situação do GraphQL em 2022 e ajudar a construir o futuro dessa tecnologia incrível !
How to use background-size in CSS
Tags: css, html, webdev, jetthoughts
Published: 2022-06-17 10:49:34

The CSS background-size property sets the size of the background image of the element. Images can be left to full size, stretched or limited to fit the available space.
```css
background-image: url('some-example-image.jpg');
```

## Cover
```css
background-size: cover;
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9tp2oo2eh7x79k9i2q6t.png)


## Size in pixels or percentage
```css
background-size: 300px;
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zoedgqjpigh1n1vgbebb.png)

```css
background-size: 15%;
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mdv5e1u4lyaz98gcu5j9.png)


## Contain
```css
background-size: contain;
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/88nmgv0d07t1yef3t1v7.png)


## Background-Repeat
If the container is larger than the image, this will mosaic the image if the background-repeat property is not set to `no-repeat`.
```css
background-repeat: no-repeat;
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o4fhm79iozsmjugpge53.png)


## Background-Position
The `background-position` CSS property sets the initial position for each background image. 
```css
background-position: center;
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gz5e2wt308q4te7w2dr8.png)


## Background-Color
Spaces not covered by the background image are filled with the `background-color` property, and the background color will be visible on background images that have transparency.
```css
background-color: lightgreen;
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vkbfnnhywj1ub9yji02m.png)
Laravel & Vue | Perfect Stack for Web App Development
Tags: laravel, vue, perfectstack, webappdevelopment
Published: 2022-06-17 10:43:22

Laravel & Vue possess their own unique functionalities that has made each one of them the most in demand frameworks. Individually both of these frameworks have the potential to help developers build robust solutions. Then just give a thought to it- what miracles these two can make when they are combined for a project. To drive you through this topic, here is an article that will help you understand the potent solutions that can be developed by using both Laravel and Vue in a single project. Read the full article - https://www.codesnail.com/how-laravel-vue-is-the-perfect-stack-for-single-page-web-apps/
Delete Leaves With a Given Value
Tags: leetcode, dsa, theabbie
Published: 2022-06-17 10:30:43

Given a binary tree `root` and an integer `target`, delete all the **leaf nodes** with value `target`.

Note that once you delete a leaf node with value `target`**,** if its parent node becomes a leaf node and has the value `target`, it should also be deleted (you need to continue doing that until you cannot).

**Example 1:**

**![](https://assets.leetcode.com/uploads/2020/01/09/sample_1_1684.png)**

**Input:** root = \[1,2,3,2,null,2,4\], target = 2
**Output:** \[1,null,3,null,4\]
**Explanation:** Leaf nodes in green with value (target = 2) are removed (Picture in left). 
After removing, new nodes become leaf nodes with value (target = 2) (Picture in center).

**Example 2:**

**![](https://assets.leetcode.com/uploads/2020/01/09/sample_2_1684.png)**

**Input:** root = \[1,3,3,3,2\], target = 3
**Output:** \[1,3,null,null,2\]

**Example 3:**

**![](https://assets.leetcode.com/uploads/2020/01/15/sample_3_1684.png)**

**Input:** root = \[1,2,null,2,null,2\], target = 2
**Output:** \[1\]
**Explanation:** Leaf nodes in green with value (target = 2) are removed at each step.

**Constraints:**

*   The number of nodes in the tree is in the range `[1, 3000]`.
*   `1 <= Node.val, target <= 1000`

**SOLUTION:**

    # Definition for a binary tree node.
    # class TreeNode:
    #     def __init__(self, val=0, left=None, right=None):
    #         self.val = val
    #         self.left = left
    #         self.right = right
    class Solution:
        def removeLeafNodes(self, root: Optional[TreeNode], target: int) -> Optional[TreeNode]:
            if root:
                if not root.left and not root.right and root.val == target:
                    return None
                root.left = self.removeLeafNodes(root.left, target)
                root.right = self.removeLeafNodes(root.right, target)
                if not root.left and not root.right and root.val == target:
                    return None
            return root
Metricks | Made with Next JS
Published: 2022-06-17 10:21:26

![Metricks | Made with Javascript | Next JS](https://res.cloudinary.com/madewithjavascript/image/upload/v1654097469/large_metricks_made_with_next_js_f22687948f.png "Metricks | Made with Javascript | Next JS")


### Metricks is the best affiliate marketing program tracking software- It allows you to easily create, track and manage your affiliate program

> Metricks is an affiliate marketing tracking software developed to help SaaS, eCommerce, and Small Businesses across the world scale through cutting-edge affiliate programs and a seamless tracking experience.
> 
> ### Launch and manage your affiliate program
> Providing eCommerce, SaaS and small and medium scale enterprises with the solution they need to grow and scale their affiliate marketing- Create your affiliate program today in five minutes or less.
> 
> #### Keep Up With Your Affiliates
> Set up multiple campaigns with different commission structures and enable your affiliates to earn override commissions from their referrals.
> 
> #### Multiple Access With One Sign-Up
> Your affiliates can now access all your active campaigns when they join your affiliate network with one sign up.
> 
> #### Manage Multiple Commission Structures
> Set up multiple campaigns with different commission structures and enable your affiliates to earn override commissions from their referrals.

## Check out more such amazing projects on our website

[Made with Javascript](https://madewithjavascript.club)

## Want us to feature your project

[Submit your Project to Made with Javascript](https://madewithjavascript.club/submit-project)

You can also write to us for any of your queries at:

[Email Made with Javascript](mailto:madewithjavascript@gmail.com)

## Project already shared on our social media handles.

| SocialMedia | SharedLink |
| ----------- | ---------- |
| Twitter | [Metricks on Twitter](https://twitter.com/withjavascript/status/1537740664418582528?s=20&t=mgwFjPoUtmZ5d7vx6Auvvw)
 |
| Medium | [Metricks on Medium](https://medium.com/@madewithjavascript/metricks-made-with-next-js-28f2fca5a36f)
 |
| Facebook | [Metricks on Facebook](https://www.facebook.com/madewithjavascript/posts/pfbid027dAWoe3Q1xYiidFki8UX4b7RqY83yLswmVsFGstggRa9tVsqhQiLfU7uM89gRdUJl)
 |
| Tumblr | [Metricks on Tumblr](https://www.tumblr.com/blog/view/madewithjavascript/687300758314614784?source=share)
 |
| LinkedIn | [Metricks on LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:6943506787216093184)
 |
| Pinterest | [Metricks on Pinterest](https://pin.it/54WZ5US)
 |

Filled Under:
 - [Made with Javascript](https://madewithjavascript.club)
 - [Made with Next JS](https://madewithjavascript.club/categories/next-js)

Make sure to give this post ❤ 50 ❤ hearts, click the 🦄 unicorns 🦄 and follow 👉 @madewithjavascript 👈 for more such awesome showcases. Show you love for the people who have worked so hard!
Python Word Split Algorithm, Coderbyte
Tags: python, code, algorithms, coderbyte
Published: 2022-06-17 10:17:43


---
title: Python Word Split Algorithm, Coderbyte
published: true
description:
tags: python, code, algorithm, coderbyte
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eja1nlfzav2ipuxmtpoi.jpg
# 
---
## Problem Definition:
Have the function *WordSplit(strArr)* read the array of strings stored in *strArr*, which will contain 2 elements: the first element will be a sequence of characters, and the second element will be a long string of comma-seperated words, in alphabetical order, that represents a dictionary of some arbitrary length. For example: strArr can be:
["hellocat", "apple, bat, cat, goodbye, hello, yellow, why"].
Your goal is to determine if the first element in the input can be split into two words, where both words in the dictionary that is provided in the second input.
In this example, the firs element can be split into two words:
**hello** and **cat** because both of those words are in the dictionary.

Your program should return the two words that exist in the dictionary separated by a comma. So for the example above, your program should return hello, cat. There will only be one correct way to split the first element of characters into two words. If there is no way to split string into two words that exist in the dictionary, return the string not possible. The first element itself will never exist in the dictionary as a real word.


```python
# define the function to manipulate string

def WordSplit(strArr):
  for i, j in enumerate(strArr[1].split(',')):
    '''subtract a string from the main string'''

    new = strArr[0].replace(j.strip(),'')  

    '''then search through the other strings and compare with the remainder after subtraction'''

    for x in strArr[1].split(','):
      if new == x.strip():
        if strArr[0] == j.strip() + new:
          return f'{j.strip()},{new}'

  return 'not possible'

strArr = ['baseball', 'a, all, b, ball,base,  bas,  cat, code, d, e, quit, z'] #test case

response = WordSplit(strArr)    
'''intersperse this code with the ouput of the function'''
code = 'fg23klq6r9'

print(response )
intersperse = ''.join(i+j for i, j in zip(response, code))
print(intersperse )
```