teleren/devto huggingface dataset:
Coding Practice - Counting Valleys (Hacker Rank)
Tags: javascript, practice
Published: 2020-08-13 20:28:37

---
title: Coding Practice - Counting Valleys (Hacker Rank)
published: true
date: 
tags: javascript, practice
canonical_url: https://www.lindakat.com/blog/cp-counting-valleys
---

## Counting Valleys Problem

This is an easy rated problem on Hacker Rank, but I solved it on my first try so I'm fairly excited! All those years of doing [Advent of Code](https://adventofcode.com) has paid off! :) So here's the breakdown of this problem, and my solution.

### The Setup

We're supplied with the number of steps someone takes on their hike, and an array that lists if each step is up or down. Their hike always starts and ends at sea level, and we're tasked with figuring out how many valleys (how many times they go down below sea level, and then come back up to sea level) they encounter during the hike.

### My solution

To me, the main part is tracking what the person's sea level value is. Then, we just need to count the number of times the sea level value goes from -1 to 0! This is the only time they're coming out of a valley and back to equal. So we can basically read through the array and update the sea level value for each step, and then when it goes from -1 to 0 (which will only happen on an up step), we increase the valley count! Then return the valley count when we finish going through the hike array.

```js
/* we have a few provided values: 
n - total number of steps 
s - the array of directional steps 
U - an up step 
D - a down step 
*/
function countingValleys(n, s) { 
  let seaLevel = 0; 
  let valleys = 0; 
  for (let i = 0; i < n; i++) { 
    if (s[i] === 'U') { 
      seaLevel++; 
      if (seaLevel === 0) { 
        valleys++; 
      } 
    } else if (s[i] === 'D') { 
      seaLevel--; 
    } 
  } 
  return valleys;
}
```

Pretty amazed this worked on the first try, in all honesty! lol Let me know if anything doesn't make sense, I'd be happy to walk through this with you!

Happy coding, friends!
Argument time does not exist on multi argument console command
Tags: php, laravel
Published: 2020-08-14 11:06:35

Hello can you help me with this problem?

{% stackoverflow 63411555 %}

I try tro make a console with 2 arguments:

1. `time` a single argument one
2. `store_ids` containing multiple values


But as you can see I have trouble callimg my command with the required params.
Take Initiative.
Tags: 100daysofcode, motivation
Published: 2020-08-14 23:06:43

Please Take initiative ..start something that makes you better,
Start something that's can make you, your life,
leave bad habits. 
What are you thinking right now?
Awake and Start Work...

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5hxvgf2bwtjbeao4x07p.jpeg)

#100DaysOfCode
Github Actions & Telegram Notification
Tags: actionshackathon, github, opensource
Published: 2020-08-15 06:03:12

---
title: Github Actions & Telegram Notification
published: true
description: My submission to the GitHub Actions x DEV Hackathon!
tags: actionshackathon, github, opensource
---

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon, please fill out all sections.)

This project is a telegram bot and build with node js and use telegraf as a chatbot framework.

### My Workflow
[Note]: # (Make sure to include the name of your GitHub Action and share where it's being used!)

Since I need to deploy the project to the VPS and using ssh, I use github actions to automate the process. The actions that I use are:

{% github appleboy/ssh-action no-readme %}
I use this action to connect to my VPS using SSH then run the deployment command.

{% github appleboy/telegram-action no-readme %}
After the deployment is complete, this action will notify me via telegram, I prefer to use telegram than the other messaging service.

And the repo where I use this workflow is here
{% github yogiwisesa/telegram-ambil-ig no-readme %}

The workflow
```
name: Deploy Ambil IG

on:
  push:
    branches: [ master ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy Ambil IG
        uses: appleboy/ssh-action@v0.1.2
        with:
          host: ${{secrets.SSH_HOST}}
          username: ${{ secrets.SSH_USERNAME }}
          password: ${{ secrets.SSH_PASSWORD }}
          script: |
            cd ~/repos/folder-name
            git pull
            npm install
            pm2 restart app-name
      - name: send custom message with args
        uses: appleboy/telegram-action@master
        with:
          to: ${{ secrets.TELEGRAM_TO }}
          token: ${{ secrets.TELEGRAM_TOKEN }}
          args: 👨🏻‍💻 User ${{github.actor}} in ${{ github.repository }} repository. Make ${{ github.event_name }}. Job ${{github.job}}.
```
Don't forget to add the secrets to your repository.

### Submission Category: 
DIY Deployments

[Note]: # (Maintainer Must-Haves, DIY Deployments, Interesting IoT, Phone Friendly, or Wacky Wildcards)


### Yaml File or Link to Code

[Note]: # (Our markdown editor supports pretty embeds. Try this syntax: `{% github link_to_your_repo %}` to share a GitHub repository)

[YAML example](https://github.com/yogiwisesa/telegram-ambil-ig/blob/master/.github/workflows/deploy-ssh.yml)


### Additional Resources / Info

{% github appleboy/ssh-action no-readme %}
{% github appleboy/telegram-action no-readme %}

[Note:] # (Be sure to link to any open source projects that are using your workflow!)

[Note]: # (Be sure to include the DEV usernames of your collaborators, if any. )

[Reminder]: # (Submissions are due on September 12th (11:59 PM PDT) and winners will be announced on September 23!)
How to extend Ruby with C++
Tags: ruby, rubygems, cpp, howto
Published: 2020-08-16 08:58:06

---
title: How to extend Ruby with C++
published: true
description: 
tags: ruby, rubygems, cpp, howto
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/zhlk13c5c7l81jdj20id.png
---
To extend Ruby with C++ is not that hard as you might think. Within a [small project](https://github.com/addisaden/rbextample) I created a barebone structure to getting started.

Here you will find answers for:

* What libs do I need?
* How can I compile?
* And how can I interact with my C++-Class?

Let's start the adventure 🤠

# The code

First we need something to work with. Well a featureless [Car class](https://github.com/addisaden/rbextample/blob/master/Car.hpp) work for that. The goal is to create and control the car. Well it's really featureless, because you can only give gas or stop it. But hey the car talks when it's born.

# The libs

The default is [mkmf](https://ruby-doc.org/stdlib-2.7.1/libdoc/mkmf/rdoc/MakeMakefile.html) (epsecially when you use the C-Api).

For C++ there is the great gem [rice](https://rubygems.org/gems/rice) which is a great tool to bind a c++ class to ruby.

[car_wrapper.cpp](https://github.com/addisaden/rbextample/blob/master/car_wrapper.cpp)
```
// includes goes here
extern "C"
void Init_car_wrapper()
{
    Data_Type<Car> rb_cCar =
        define_class<Car>("Car")
            .define_constructor(Constructor<Car>())
            .define_method("gas", &Car::gas)
            .define_method("stop", &Car::stop);
}
```

So you wrap the class and every method into rice methods. To dig deeper you can read the [documentation](https://jasonroelofs.com/rice/) 🙂

# compiling

This is really beautiful. Just create a [extconf.rb](https://github.com/addisaden/rbextample/blob/master/extconf.rb) file with the following content:

```
require "mkmf-rice"
create_makefile "car_wrapper"
```

Run `ruby extconf.rb` and you get a `Makefile`.

Finally run `make` and you get your Ruby-Extension as `car_wrapper.so`.

# playground

And here you can play with it:

```
[1] pry(main)> require "./car_wrapper"
=> true
[2] pry(main)> mycar = Car.new
A new Car is born
=> #<Car:0x00005557f9db5bb8>
[3] pry(main)> mycar.gas(50)
=> 50
[4] pry(main)> mycar.stop()
=> 20
[5] pry(main)> mycar.stop()
=> -10
[6] pry(main)> mycar.stop()
=> -40
[7] pry(main)> exit
Good bye my car...
```

🥳 have fun 🎉

# Photo credits
car: Thanks to `MovienerdDeluxe` - [source](https://de.wikipedia.org/wiki/Datei:K.I.T.T._Nachbau_aus_Deutschland.jpg)
ruby-logo: Thanks to `Yukihiro Matsumoto, Ruby Visual Identity Team` - [source](https://www.ruby-lang.org/en/about/logo/)
GSoC'20 with NumFOCUS
Tags: opensource, github, bayesian
Published: 2020-08-15 15:05:03

Original post - https://www.codingpaths.com/gsoc/gsoc-2020-with-numfocus/

# GSoC'20 with NumFOCUS

I am super excited to say that I have been selected as a Google Summer of Code student by NumFOCUS for PyMC4. I would like to thank my mentors [Thomas Wiecki](https://github.com/twiecki) and [Maxim Kochurov](https://github.com/ferrine) and the entire NumFOCUS community for giving this opportunity.

My project is about adding `Variational Inference Interface` to [PyMC4](https://github.com/pymc-devs/pymc4). Variational Inference scales better over larger datasets as compared to the traditional MCMC algorithms. First, I had plans to implement OPVI[^OPVI_paper] framework as done in PyMC3 this summer. But as corrected by my mentor [Maxim Kochurov](https://github.com/ferrine), it would have taken extra time and more debugging because of the difficulty to deal with `symbolic graph manipulations` in [Tensorflow](https://www.tensorflow.org/). Now, the whole plan is to implement two Variational Inference Algorithms - Mean Field ADVI[^ADVI_paper] and Full Rank ADVI[^ADVI_paper] in PyMC4. Mean Field ADVI posits a Spherical Gaussian family and Full Rank ADVI posits a Multivariate Gaussian family to minimize [KL divergence](https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence).

All in all, I look forward to a great summer.

Thank you for reading. :smile:
Sayam 

[^OPVI_paper]: [Operator Variational Inference](https://arxiv.org/abs/1610.09033) Rajesh Ranganath, Jaan Altosaar, Dustin Tran, David M. Blei (2016)
[^ADVI_paper]: [Automatic Differentiation Variational Inference](https://arxiv.org/abs/1603.00788) Alp Kucukelbir, Dustin Tran, Rajesh Ranganath, Andrew Gelman, David M. Blei (2016).
How to secure your private keys.
Tags: privacy, beginners, ruby, tutorial
Published: 2020-08-15 21:14:48

# Security is key

Security in your application should be a large priority for a developer. Anyone having access to your sensitive information can wreck havoc in your application and possibly your personal information. Even if it is a pet project to learn, It is always good practice to ensure you secure your keys. I will walk through a simple application to demonstrate how to secure your private keys to prevent anyone to publically access your secure information. 

## Let's get started: 

#### Let's create a Rails application. 

```
$ rails new blog
```
*This command requires Ruby on Rails to be installed.* [Click here for installation](https://guides.rubyonrails.org/v5.0/getting_started.html)


#### Let's navigate to our new app and generate some models, controllers, and views. 

```
$ cd blog
$ rails generate scaffold post title:string body:text
$ rails generate scaffold comment post_id:integer body:text
$ rake db:migrate
```

#### Let's add a few gems. 

```
// file: blog/Gemfile
// Add these into the file

...
gem 'dotenv-rails', groups: [:development, :test]
gem 'omniauth-google-oauth2'
...
``` 
dotenv - Popular gem that allows you to hide your private keys. 
omniauth - Gem that allows you to create authentication in your app.

[Click here to get API keys](https://code.google.com/apis/console/)

#### Execute gem installation 

```
$ bundle 
$ rails server
```

#### Configure omniauth 

```
// Create this file => blog/config/initializers/omniauth.rb 
// Add this snippet 

Rails.application.config.middleware.use OmniAuth::Builder do
    provider :google_oauth2, '123456789', 'Your_Client_Secret'
end
```

Notice `provider :google_oauth2, '123456789', 'Your_Client_Secret'`. This is where you can put your secret keys but they wouldn't be very secret here. 

#### Configure omniauth

```
// Create this file => blog/.env 
// Add your secret credentials 

GOOGLE_CLIENT_ID = '123456789'
GOOGLE_CLIENT_SECRET = 'Your_Client_Secret'
```

#### Update omniauth

```
// replace you secret keys 

provider :google_oauth2, ENV[GOOGLE_CLIENT_ID], ENV[GOOGLE_CLIENT_SECRET]
```

Prepending ENV will give you access to the environment key we created for your secret credentials in the .env file. 

#### Hide your secret file 

```
// Locate your gitignore file => blog/.gitignore
// Add this snippet

# This hides your file from being uploaded to your repository
  .env 
```

Now you are able to rest assured your secret API keys are indeed secret and your application still has access when needed. I hope this helps keep your next project secure. If you enjoyed this article please feel free to follow me. 

Terry Threatt
Recap/ Summary week #33
Tags: devjournal, azure, opensource, showdev
Published: 2020-08-17 11:36:52

---
title: Recap/ Summary week #33
published: true
date: 2020-08-16  13:46:00 UTC
tags: devjournal,azure,opensource,showdev
canonical_url: http://www.frankysnotes.com/2020/08/recap-summary-week-33.html
---

 Every beginning of weekend, I will share a recap of the week and at the same time a summary of my streams. Those videos are at least two hour longs, so I thought a short summary to know if topic interest you could be useful. Watch only the summary or relax and enjoy the longer version that up to you!

{% youtube ED2f8KIDWDk %}

- Coding Python: Deploy Django and Postgres Apps to Azure with VS Code - [c5m.ca/aaa-ep25](http://c5m.ca/aaa-ep25)
- Stream 119 - How easy can we make the deployment of TinyBlazorAdmin -  [c5m.ca/stream-ep119](http://c5m.ca/stream-ep119)
- Stream120 - Celebrating 500 followers and working on the Chatbot -  [c5m.ca/stream-ep120](http://c5m.ca/stream-ep120)
How to Choose the Right PHP Development Company?
Published: 2021-04-13 06:25:42

PHP is universally recognized because of its high performance but all those features are brought into an application only with the help of a well-versed PHP development company. PHP itself is a treasure trove and the company you are hiring can extract good things out of it for your website.

[Finding a good PHP Development company](https://www.sparxitsolutions.com/php-development.shtml) is not as easy as you think it to be. After all, it is about your idea, your project. Your idea is your intangible property and you just can't take the risk by sharing it with someone who is not responsible or trustworthy. PHP has been in existence for a long time, so there are innumerable companies available to serve you. What is more important is to find a compatible company. To navigate the way to it I am writing down a list of points following which you will be able to find out the best of the best PHP development companies.

Points to look for in a PHP development company before hiring-

Experience and good market reputation

Experience and reputation are those assets of a company that can only be earned from sheer hard work and consistent good work. If you are hiring a well-experienced team of PHP developers, you can obtain a prompt solution for creating astonishing PHP development projects. Also, ask them questions beyond their success stories.

Consult about tools and frameworks

You should check the tools they are currently using. With this, you will be able to know how polished they are to use them for your project. You can ask about your specification and know the appropriate tool. Know whether they are well acquainted with tools like XAMPP, PhpED, etc. Ask them which tool they use for debugging, testing, and security.

Customer services

Robust customer service is mandatory for a good and hasslefree partnership. Some companies are available round the clock to resolve your queries. They give you frequent updates regarding the development process. Choose partners who are zealous to let you know the nitty-gritty of daily progress and also strive to resolve your doubts.

Pricing

As an entrepreneur, quality is your vulnerable point, but you can't pay an enormous amount for that. A good company is one that delivers good work in an optimum budget. Out of your chosen companies discuss the cost and then analyze judiciously.
Know their technical prowess


I am writing this point explicitly because it is imperative to know their technical abilities. You will be able to deduce whether they will be able to grasp your idea and make a tailor-made website for you not. Which tool in PHP is their strength or they are comfortable with all the latest as well as older versions.

I'm very certain that you will get the desired development company after following the above-written points. Note that you may find many companies just by searching on google but availing of PHP development services from a good company is something that matters. In Fact, that's the only thing that matters for the success of your project.
How to be an effective mentor?
Tags: mentor, mentee, leadership, webdev
Published: 2020-09-06 17:38:24

We get a good sleep if we are satisfied with the work that we have done throughout a day. As a software developer, coding and attending meetings becomes our daily job. At the initial level, it's appealing but in the long run, you lose something, and that something is the satisfaction. So I found a technique to tackle that which is **Mentoring**.

> They say "knowledge increases by sharing" and I say, they are right.

Who does not want to do this noble work by sharing his/her knowledge which gives the most important thing to you => Satisfaction!
 
For the above-mentioned reasons, I chose to be a mentor and took up the responsibility. So here I am, writing a blog to share the key points on how to become a very effective mentor.

**Know your mentee/s**
* This common point is very important for both a mentee and a mentor, it makes both confident to open up and ask or suggest certain things. If you are interested in how you can make a good relation with your coworker then you should read my [previous blog](https://dev.to/maulik/how-to-get-along-with-coworkers-30h1).

**Take interest**
* It's always good if one gets a mentor who is interested in mentoring him/her. Take a little interest and the respect you will get by your mentee will automatically boost your interest. 

**Be accountable**
* Be available at the scheduled time, check assignments of your mentee, and give the feedback and suggestion and listen to your mentee carefully.

**Constructive criticism**
* Give them the actual feedback but deliver it in a way that it does not break his/her confidence but boost their thinking power.

**Give freedom**
* Don't tell your mentee everything, let him/her make a decision, and then you can have a discussion over it, let him/her make mistakes. Let him/her stand again.

**Let your mentee go beyond limits**
* As a mentor, your task is not just to make your mentee project ready but also to make him/her realize that there is no boundary of learning and he/she can and should go the extra mile.


> A mentor can make a significant difference in one's career and being one can also be a valuable experience.

Feel free to share your suggestions in the comment
Any tips for entry level developers trying to land a full time position in 2020?
Tags: react, javascript, webdev
Published: 2020-09-12 00:36:47

It's been well over 4 months into the job search process. I've changed my strategy from filling out applications solely, reaching out to people on linkedIn, reaching out to employees with the title of Recruiter, Talent, Manager. No luck as of yet, hoping to get some insight on some strategies that some of you have done.
Learn at Local Hack Day: Learn!
Tags: majorleaguehacking, mlh, localhackday
Published: 2020-09-25 15:46:04

Major League Hacking is excited to invite hackers from around the world to participate in Local Hack Day: Learn, a day-long conference full of keynotes and workshops with a week of workshops leading up to it. Earn limited-edition hacker swag by forming a Guild with your friends! Sign up now! localhackday.mlh.io/learn
Base API: Honest Feedback Requested
Tags: feedback, api, discuss
Published: 2020-09-30 04:26:44

Hi there 👋 I am building [Base API](http://www.base-api.io/) a  collection of basic APIs that a web app usually needs (image upload, email sending, authentication, etc...).

The thing is that I'm in a standstill (I haven't done anything with the product in the last half year) and don't know how to proceed with it. I really want to make this a good service which helps developers build products quicker and safer.

Since you are (probably) a developer and you face the issues which this service tries to solve is the reason I am reaching out and **would like your honest feedback** about the product.

It would be really helpful for me if you could answer any of the questions below:
- looking at the site it is understandable what the service does?
- what are the features that you would like to see in an service like this?
- what do you think about the pricing?
- what are the things you like / don't like about it?
- from the available information would you try it out?
- if it were open source would you use it?

If you have any other feedback that is welcome as well or if you have any questions I'm happy to answer them 🙂.
Learning How to Code
Tags: learning, coding, learningresources
Published: 2020-10-01 06:20:48

---
title: Learning How to Code
published: true
date: 2015-12-29 00:00:00 UTC
tags: Learning,Coding,Learningresources
canonical_url: https://www.loginradius.com/engineering/blog/learning-how-to-code/
---

When you work for a tech company in an official capacity, it feels like everyone around you is speaking another language. Which they are, most of their work exists in coding language. To feel more relevant, I signed up on codecademy.com and started working on their beginner courses…

   
[Read On](https://www.loginradius.com/engineering/blog/learning-how-to-code/)
How does a Beginner feel when they are just getting started.
Tags: beginners, opensource, developers, youtube
Published: 2020-10-01 06:25:57

When you enter the arena , you see a whole lot of of troops already fighting for their life and you think you just are getting started as a troop and you want to be a king someday. When you someone shows how something works , a Beginner goes through multiple emotions at consecutively for example , from astonished to excited , to confused , to nervousness to self doubt.
Just want to clear out all my fellow beginners , battle is not with others its with you and either you win or defeat this battle only you are gonna be get affected by it. So be selfish and learn what you want to and not what others are asking you to .
#thursdaytalks.
tsParticles loves Hacktoberfest
Tags: hacktoberfest, news, showdev, contributorswanted
Published: 2020-10-01 07:10:00

tsParticles is always looking for contributors and if you are searching for some project to contribute for the Hacktoberfest 2020 I'll be glad to help you participate.

tsParticles is a web project, written in TypeScript. It uses mostly `canvas` animations but there's also a visual editor and many components for the most used front end framework like:

- React
- VueJS (2.x and 3.x)
- Angular
- Svelte
- Inferno
- Preact
- jQuery

There are also some presets or custom shapes ready to be used by users that can also be added if you have some cool ideas.

There are some cool open issues (mostly new features) to work on, and we can discuss them in [Slack](https://join.slack.com/t/tsparticles/shared_invite/enQtOTcxNTQxNjQ4NzkxLWE2MTZhZWExMWRmOWI5MTMxNjczOGE1Yjk0MjViYjdkYTUzODM3OTc5MGQ5MjFlODc4MzE0N2Q1OWQxZDc1YzI).

{% github matteobruni/tsparticles %}

Happy Coding to everyone, Happy Hacktoberfest 2020!