teleren/devto huggingface dataset:
Counter Examples
Tags: programming, beginners
Published: 2023-01-03 14:10:51

---
title: Counter Examples
published: true
description: A counter example can show you several aspects of a programming environment and can help you get started writing your own applications.
tags: programming, beginners
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-01-03 14:07 +0000
canonical_url: https://code-maven.com/counter
series: counter
---

I love experimenting with programming languages, databases, frameworks, etc.

The standard example of a "Hello World" program is nice to get started, but usually way too simple. So I started to create a slightly more complex example. A counter example.

In each example we are going to create a counter. A simple counter will just increment a single number. A multi-counter will handle several counters. e.g. one per client, one per user, or one per  some arbitrary string.

**I think these counter example can show you several aspects of a programming environment and can help you get started writing your own applications.**

In this project we are going to implement a counter with various front-ends and back-ends. Sometimes these two parts will be in one program.
Some of the solution will be web based. Some will be command line based. Some might be GUI-based.

The counters might be stored in some kind of a "database". It can be a plain text file, some data serialization format, a relational database, a NoSQL database and who knows what else.

The simpler version of the counter handles a single counter. Every time we run the counter it will show a number one higher than the previous one.

An interaction with a command-line tool might look like this:

```
$ count
  1
$ count
  2
$ count
  3
```

The multi-counter is slightly more complex. It will be able to maintain several counters at once.
So an interaction with a command-line tool might look like this:

```
$ count foo
  foo: 1
$ count foo
  foo: 2
$ count bar
  bar: 1
$ count foo
  foo: 3
```

This is going to be a long project, but it might help understand various techniques for data serialization.

## Series

This is the beginning of a series. Soon I am going to publish the first entry.
Discover the ultimate non-technical skills for software developers: Boost your career today!
Tags: javascript, beginners, programming, career
Published: 2023-01-03 13:54:34

As a software developer, it's important to have a solid foundation in technical skills like programming languages, frameworks, problem-solving skills etc, as well as an understanding of computer science concepts and principles.

But there are also several non-technical skills that can give you a huge advantage early in your career and help you succeed.

𝑯𝒆𝒓𝒆 𝒂𝒓𝒆 𝒇𝒊𝒗𝒆 𝒆𝒔𝒔𝒆𝒏𝒕𝒊𝒂𝒍 𝒏𝒐𝒏-𝒕𝒆𝒄𝒉𝒏𝒊𝒄𝒂𝒍 𝒔𝒌𝒊𝒍𝒍𝒔 𝒇𝒐𝒓 𝒔𝒐𝒇𝒕𝒘𝒂𝒓𝒆 𝒅𝒆𝒗𝒆𝒍𝒐𝒑𝒆𝒓𝒔:

1️⃣ 𝐒𝐭𝐨𝐫𝐲𝐭𝐞𝐥𝐥𝐢𝐧𝐠: Being able to clearly and persuasively communicate your ideas is crucial for working on projects, collaborating with team members, and presenting to clients.

2️⃣ 𝐂𝐨𝐦𝐦𝐮𝐧𝐢𝐜𝐚𝐭𝐢𝐨𝐧: Strong communication skills are a must for effective teamwork and communicating with stakeholders.

3️⃣ 𝐋𝐞𝐚𝐝𝐞𝐫𝐬𝐡𝐢𝐩: Leadership skills are important for managing projects and teams, as well as guiding the direction of a project.

4️⃣ 𝐒𝐞𝐥𝐥𝐢𝐧𝐠: The ability to sell your ideas and solutions can be valuable when working with clients or stakeholders, or seeking funding or investment.

5️⃣ 𝐖𝐫𝐢𝐭𝐢𝐧𝐠: Writing skills can be useful for creating technical documentation, reports, article and communicating with team members and stakeholders.

Developing both technical and non-technical skills is key to staying competitive and up-to-date in the field of software development.
Better Internal Links #
Tags: css, html, codepen
Published: 2023-01-03 13:42:22

**Internal links are a great way to divide the parts of your article.**

_**But they can be better!**_

If you make the internal titles (h2, h3, h4) look different with CSS (see the example below) that makes it possible to share the link. Also this lets the user FOCUSED to that part of the article 🎯 

## Lets See How

When the internal link is active, make it look featured or different.

So, if you send a link like `https://abc.com/page#inner` , your title will look different than the other titles (or internal links).

Also, if you use a link image and make it clickable, your readers can/will make the title active and share that internal link by themself. So emphasise it if you can.

### Lets see it in action with the code:
[https://codepen.io/altug/pen/VwdwKpw](https://codepen.io/altug/pen/VwdwKpw)

{% codepen https://codepen.io/altug/pen/VwdwKpw %}</script>

Please share your thoughts and/or development suggestions ✌
Aleo Testnet 3 Tutorial (automatic)
Published: 2023-01-03 13:22:12

Run the script and wait for the installation to complete

```javascript
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/Aleo/main/multi_tool.sh)

```
To run the pruner on an existing wallet, place a file called `aleo_account.txt`, necessarily containing the line

```javascript
Private Key  APrivateKey1___

```
By path (the command displays the path)

```javascript
echo $HOME/aleo_account.txt

```
And run the script after that

## Update
**Semi-automatic**

```javascript
Run the script and wait for the update to complete
```
**Automatic**
Create a folder for node files

```
mkdir -p $HOME/.aleo
```
Create a service file

```javascript
sudo tee <<EOF >/dev/null /etc/systemd/system/aleou.service
[Unit]
Description=Aleo auto-updater
After=network.target

[Service]
type=forking
User=$USER
Environment="HOME=$HOME"
WorkingDirectory=$HOME
ExecStartPre=`which wget` -qO $HOME/.aleo/multi_tool.sh https://raw.githubusercontent.com/SecorD0/Aleo/main/multi_tool.sh
ExecStartPre=`which chmod` +x $HOME/.aleo/multi_tool.sh
ExecStart=$HOME/.aleo/multi_tool.sh -up
Restart=always
RestartSec=5m

[Install]
WantedBy=multi-user.target
EOF
```
Run the service file

```javascript
sudo systemctl daemon-reload
sudo systemctl enable aleou
sudo systemctl restart aleou
```
**The script restarts every 5 minutes**
To view the log of the auto update script use the command

```javascript
sudo journalctl -fn 100 -u aleou
```

## Removal

Don't stop

```javascript
sudo systemctl stop aleod
```
Delete service file

```javascript
sudo systemctl disable aleod
rm -rf /etc/systemd/system/aleod.service
sudo systemctl daemon-reload
```
Delete the project folder and the binary file

```javascript
rm -rf $HOME/snarkOS /usr/bin/snarkos
```

## Useful Commands

```javascript
Available variables (remove echo when using)
echo $aleo_wallet_address
echo $aleo_private_key
```
**View log**

Prover

```javascript
aleo_log sudo journalctl -fn 100 -u aleod
```
 
Automatic update script

```javascript
sudo journalctl -fn 100 -u aleou
```
Restart the node

```javascript
sudo systemctl restart aleod
```

Stop auto update script

```javascript
sudo systemctl stop aleou
```
Validate the order of parenthese in an expression
Tags: javascript, algorithms
Published: 2023-01-03 13:21:04

> I wrote this logic when i was developing a simple calculator. My aim was to validate the order of parenthese in an expression.

_Please you can go through it and help me identify some bugs in it_

Here is the implementation.

```js
const brackets = ["(", ")"];

/**
 * validates the order of parenthese in a string
 * @param {*} type string 
 * @returns boolean otherwise `throws an error`
 */
const checkSyntax = (str) => {
  if (typeof str !== "string") return false;

  //check if both of the brackets dont exists
  if (str.indexOf(brackets[0]) === -1 && str.indexOf(brackets[1]) === -1)
    return true;

  // check if one of the brackets exists.
  if (
    (str.indexOf(brackets[0]) === -1 && str.indexOf(brackets[1]) !== -1) ||
    (str.indexOf(brackets[1]) === -1 && str.indexOf(brackets[0]) !== -1)
  )
    throw new Error(
      `Syntax error: ${str[str.length - 1]} at index ${[str.length - 1]}`
    );

  //check if ) is at index 0  or ( is a last index throw otherwise skip
  if (str[0] === brackets[1] || str[str.length - 1] === brackets[0])
    throw new Error(`Error ==> index ${[str.length - 1]}`);

  //Here we now check for validity
  let stack = [];

  for (let i = 0; i < str.length; i++) {

    if (str[i] === brackets[0]) {
      stack.push(str[i]);
      continue;
    }

    if (str[i] === brackets[1]) {

      //if we are trying to pop an empty stack []
      if (!stack.length) throw new Error(`Error : not in order ${i}`);

      stack.pop(str[i]);

      //if the stack is not empty and i is on the last iteration then throw otherwise skip
      if (stack.length !== 0 && i === str.length - 1)
        throw new Error(
          `Syntax Error : stack is not empty i.e stack length = [${stack.length}]`
        );

      continue;
    }
  }

  return true;
};

```
```js 
console.log(checkSyntax("((()))()()()")); //true
```
HTTP Request in Each Language
Published: 2022-12-19 20:03:57

There are many ways to make an HTTP request in different programming languages. Here are a few examples:

Java

You can use the built-in java.net.HttpURLConnection class to make an HTTP request in Java. Here's an example of how to send a GET request:

`import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
  public static void main(String[] args) {
    try {
      URL url = new URL("https://www.olansgz.com/");
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      connection.setRequestMethod("GET");
      connection.setConnectTimeout(5000);
      connection.setReadTimeout(5000);

      int responseCode = connection.getResponseCode();
      System.out.println("Response code: " + responseCode);

      BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
      String inputLine;
      StringBuilder response = new StringBuilder();

      while ((inputLine = in.readLine()) != null) {
        response.append(inputLine);
      }
      in.close();

      System.out.println(response.toString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}`

Python

You can use the built-in urllib module to make HTTP requests in Python. Here's an example of how to send a GET request:


`import urllib.request

def main():
  url = "http://www.example.com"
  response = urllib.request.urlopen(url)
  data = response.read()
  print(data)

if __name__ == "__main__":
  main()
`
JavaScript

You can use the built-in XMLHttpRequest object to make HTTP requests in JavaScript. Here's an example of how to send a GET request:

`var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.example.com", true);
xhr.send();

xhr.onload = function() {
  if (xhr.status === 200) {
    console.log(xhr.responseText);
  }
};`

C#

You can use the System.Net.Http.HttpClient class to make HTTP requests in C#. Here's an example of how to send a GET request:

`using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace Example
{
  class MainClass
  {
    public static async Task Main(string[] args)
    {
      using (HttpClient client = new HttpClient())
      {
        using (HttpResponseMessage response = await client.GetAsync("http://www.example.com"))
        {
          using (HttpContent content = response.Content)
          {
            string result = await content.ReadAsStringAsync();
            Console.WriteLine(result);
          }
        }
      }
    }`
7 Subtle Signs of Developer Burnout — And How to Recover From It
Tags: discuss, mentalhealth, productivity, career
Published: 2023-01-03 13:12:23


![Burnout is not a badge of honour](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jp32jjxsfq48m7srg1of.png)

Burnouts are inevitable in a long career in tech.

These 7 signs will help you in identifying it early and love your work again

Let’s dive in ↓

## TL;DR

- [You feel isolated](#you-feel-isolated)
- [You regularly miss deadlines](#you-regularly-miss-deadlines)
- [You don’t get proper sleep](#you-don-t-get-proper-sleep)
- [You are being overworked](#you-are-being-overworked)
- [You constantly lack motivation](#you-constantly-lack-motivation)
- [You don’t take breaks](#you-don-t-take-breaks)
- [You often feel distracted](#you-often-feel-distracted)

## You feel isolated 😓

1 in 5 people deal with workplace loneliness.

Feeling disconnected from peers is a terrible feeling.

Make new connections and find opportunities to collaborate.

Volunteer and rise by lifting others.

## You regularly miss deadlines 🤦

We all suffer with optimism bias.

That makes us underestimate time and roadblocks in completing the tasks.

Schedule *buffer time* and cut yourself some slack.

While planning, assume the worst.

## You don’t get proper sleep 🥱

You find yourself in a state of stress — or have poor sleep habits.

Lack of sleep costs you more than just drowsiness.
 
For better sleep:
Avoid large meals
Get some exercise
Limit Caffeine

Most importantly, make time for sleep.

## You are being overworked 😥

Ever felt that you lack energy for simplest tasks?

That’s because your mind is overwhelmed.

Take time to plan and set realistic expectations.

Value health before sickness.

## You constantly lack motivation 😕

So you feel you are NOT making progress.

Revive your motivation by:
Learning new things
Side projects
Collaborating

Have goals, not chores.

## You don’t take breaks ☕️

By not taking breaks,

You are starving your body and mind from recharge.

Add *effective* breaks to your work routine:
Standup and stretch
Breathing exercises
Short walks

Learn to rest your mind.

## You often feel distracted 😖

You are constantly bombarded by:
Messages
Notifications
Interruptions

Identify and eliminate distractions from your work environment.

Block time for what needs to be done.

Focus and win.

## Wrapping up 📝

That's it!

I hope you found these tips helpful.

If you liked this post, follow me for more of these 🙂

Also, share how do you avoid or recover from burnout in comments 👇
2023: Make Money Online: 10 Proven Strategies to Earn an Income
Tags: opensource, passiveincom, programming, productivity
Published: 2023-01-03 13:09:36

Are you looking for ways to earn an income online? Look no further! In this blog post, we will explore a variety of strategies that can help you tap into the digital economy and start making money from the comfort of your own home. From freelance work and e-commerce to affiliate marketing and online courses, there are endless opportunities to earn an income online. We'll break down the pros and cons of each option and provide tips and resources to help you get started. Whether you're a stay-at-home parent, a recent graduate, or a seasoned professional looking to supplement your income, this blog post has something for everyone. So if you're ready to take control of your financial future, read on and discover the many ways you can earn an income online.

1. Freelance Writing: 

If you have an interest in writing, you can use it to make money online. You can write articles, blog posts, and web content for businesses. Many businesses are also looking for copywriters and editors to help them produce content.

2. Affiliate Marketing:- 

Affiliate marketing involves promoting products or services through your own website, blog, or social media accounts. When someone makes a purchase through one of your links, you earn a commission.


There are endless sources to earn a passive income, follow the beautiful written blog post.

[10 most effective ways to earn online](https://www.javaoneworld.com/2023/01/2023-make-money-online-10-proven.html)

Happy Coding.....
Best Database to use with C#
Tags: csharp, database, dotnet, beginners
Published: 2023-01-03 13:03:01

One of the biggest questions for any developer is choosing what database to use. And if you google this term, you get mostly a lot of of outdated results -- posts from 2016 on stackoverflow, links to random blogs that haven't been updated in a decade, etc. And even though we might have a resource like [db-engines](https://db-engines.com/en/) to tell us the most popular databases, it doesn't tell me which databases C# developers _actually use._

I decided to take the StackOverflow survey raw results, filter them for C# developers only, and then do some calculations on which databases are used extensively by C# developers. Voila!

Out of the 83k SO survey responses of 2021, 22,984 were developers who know C#. This is a fairly large sample, so let's proceed.

## What databases are used with C#?

1. An astounding 55.49% of C# developers use Microsoft SQL Server. This is a gigantic number considering the number of potential choices. Microsoft SQL server is far more popular with C# developers than it is with anyone else - just 22% of all StackOverflow developers use it overall.
2. 42.93% of C# developers use mySQL extensively, which is not that surprising
3. 32% use sqlite. 


## What database do C# developers want to use?
Here's where the data gets really interesting. When you compare the number of developers using a database vs what database they say they want to use, that's where we see the difference between preference/desire ("want") vs what our jobs insist upon. This is actually true for a lot of databases, where we see the number of developers are using something is _more than_ the number of developers who say they want to. For example:

- Even though 55% of C# developers use Microsoft SQL server, just **35%** say they want to use it. 35% is still a very large number, but that's a fairly significant loss.
- 29% of developers use PostgreSQL, and 28% want to use it (imo, a trivial difference)

We can also see there are some databases where the usage lags than the number of developers who want to use it:

1. MongoDB (25.34%)
2. Redis (20.53%)
3. Elastic (14.08%)


Pretty surprising results.

## What databases are not used with C#?
DynamoDB, Couchbase, Cassandra, DB2 all fared very poorly with C# developers. Cassandra in particular had just 501 users, a market share of 2%. Couchbase was even worse, with 337 (1.47% of C# developers).
What are JavaScript Template Literals?
Tags: javascript, beginners, webdev, tutorial
Published: 2023-01-03 13:00:00

**What are JavaScript Template Literals?**

Template literals are literals delimited by backtick (``) characters that enable multi-line strings, string interpolation with embedded expressions, and tagged templates.

## Back-Tics Syntax

To define a string, Template Literals use backticks (``) rather than quotes (“”).

Example

```javascript
let hello = `Hello World!`;
```

## Why use template literals in JavaScript?

Template literals make it simple to convert variables and expressions into strings. String interpolation is the name given to this technique.

### Interpolation

The syntax is:

```javascript
${...}
```

## How to use ${} in JavaScript?

A placeholder is represented by `${]` It allows for the introduction of a variable without concatenating. This is done using `${var}` to add the variable string in-line to your current string.

Example

```javascript
var location = 'bar';
console.log(`Let's meet at the ${location}`);
// Let's meet at the bar
```

## Quotes Within Strings

Within a string, you can use both single and double quotes with template literals:

Example

```javascript
let name = `He's frequently referred to as "Roger."`;
```

## Multiline Strings

Multiline strings are supported by template literals.

Using normal strings, you would have to use the following syntax in order to get multi-line strings:

```javascript
console.log("string text line 1\n" + "string text line 2");
// "string text line 1
// string text line 2"
```

Using template literals, you can do the same with this:

```javascript
console.log(`Say hello to 
multi-line
strings!`);
// "Say hello to
// multi-line
// strings!"
```

## Variable Substitution

With template literals, it’s a bit easier to include variables inside a string. For that, we use the ${...}syntax.

Example

```javascript
let firstName = 'Paul',
    lastName = 'Smith';

let greeting = `Hi ${firstName}, ${lastName}`;
console.log(greeting); // Hi Paul, Smith
```

## Expression Substitution

Template literals also allow expressions in strings:

Example

```javascript
let a = 10;
let b = 20;
console.log(`Result = ${a + b}`); // Result = 30
```

The process of assigning variables and expressions inside the template literal is known as interpolation.

### Further reading

Want to learn more about Template literals then check out: [Template literals | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#:~:text=Template%20literals%20are%20literals%20delimited,special%20constructs%20called%20tagged%20templates.)

### See also

[What is the Syntax of JavaScript?](https://maxlockwood.dev/what-is-the-syntax-of-javascript/)
[How to Display Output in JavaScript](https://maxlockwood.dev/how-to-display-output-in-javascript/)
[What are the Three Variables in JavaScript?](https://maxlockwood.dev/what-are-the-three-variables-in-javascript/)

If you liked this article, then please share. You can also find me on [Twitter](https://twitter.com/maxlockwood88) for more updates.
Building an interactive stock ta app with streamlit and openbb
Tags: openbb, streamlit
Published: 2022-12-15 17:49:52

---
title: Building an interactive stock ta app with streamlit and openbb
published: true
date: 2023-01-03 13:00:00 UTC
tags: openbb, streamlit
canonical_url: https://friendlyuser.github.io/posts/stonks/stock_dashboard_ta/
---


This project is a Streamlit app that uses openbb-sdk to display technical analysis graphs for a given stock. The app allows the user to input a ticker symbol, start date, and end date in the sidebar, and then displays a line chart of the stock's adjusted close price, as well as a Bollinger Bands graph using the openbb-sdk. The Bollinger Bands graph is saved to an image file and then displayed in the app.

```python
today = datetime.date.today()
def user_input_features():
    ticker = st.sidebar.text_input("Ticker", 'ZIM')
    start_date = st.sidebar.text_input("Start Date", '2020-05-01')
    end_date = st.sidebar.text_input("End Date", f'{today}')
    # ta_range = st.sidebar.number_input("TA Range", min_value=1, max_value=50)
    return ticker, start_date, end_date # , ta_range

symbol, start, end = user_input_features()
```

The user_input_features() function is used to get the user input from the sidebar. The user can input a ticker symbol, start date, and end date. The start date and end date are used to get the stock data from the yfinance API. The ticker symbol is used to get the company name from the yfinance API using the open bb load utility.


```python
@st.cache  # 👈 Added this
def build_bbands_img(data, symbol, file_name="sample.png"):
    ...
    pass
```


To improve the performance of the app, you can use Streamlit's @st.cache decorator on the build_bbands_img() function. This will enable caching of the results of the function, so that it is only executed when the input values change. This can help reduce the time it takes to generate the Bollinger Bands image, especially if the user is repeatedly requesting the same data. 

```python
stream = os.popen('cd ~ && pwd')
root_dir = stream.read()
# /home/codespace/OpenBBUserData/exports/temp.png
# find root directory/OpenBBUserData/exports
sample_dir = root_dir.strip()
# root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
temp_image = os.path.join(sample_dir, "OpenBBUserData", "exports", file_name)
```

The code above is used to find the root shell directory of the project. This is used to find the location of the image file that is generated by the openbb-sdk. The image file is then displayed in the app using Streamlit's st.image() function.

```python
bbands_img = build_bbands_img(data, symbol, "bbands.png")
# plot ta using open bb sdk in streamlit
st.header(f"Bollinger Bands\n {company_name}")
# 
# if bbands.png exists, display it

if bbands_img:
    st.image(bbands_img, caption='Sunrise by the mountains')
```


To view the full app go to https://friendlyuser-stonk-ta-app-app-fhrcso.streamlit.app/


and view the source code at

https://github.com/FriendlyUser/stonk_ta_app