teleren/devto huggingface dataset:
Loops in C
Tags: loops, while, for, differences
Published: 2020-12-15 17:24:27

WHAT ARE LOOPS?
The computer has an ability to perform a set of instructions repeatedly . This involves repeating some portion of the program a specific number of times or infinite times until the basic condition is satisfied. These kind of repetitive structures or statements are called loops.

METHODS IN LOOPS
1.For statement
2.While statement
3.Do-While statement

1. WHILE LOOPS:
   A while loop in C programming repeatedly executes a target 
   statement as long as a given condition is true
   Until the given condition is true, while loop in repeatedly 
   executes a target statement.
   When the condition becomes false, the program control passes to 
   the line immediately following the loop


SYNTAX OF WHILE LOOP:

// while(condition) {
   statement(s);
}
1.Statement(s): may a block of statements.
2.Condition: can be any expression.
EXAMPLE:

// Print numbers from 1 to 5

#include <stdio.h>
int main()
{
    int i = 1;
    
    while (i <= 5)
    {
        printf("%d\n", i);
        ++i;
    }

    return 0;
}

FOR LOOP:
Used in repetition control structure.
Used when a loop that needs to execute a specific number of times.

SYNTAX OF FOR LOOP:

// for ( initialization; condition; increment ) {
   statement(s);
}
FLOW OF CONTROL IN FORLOOP:

1.INITIALIZATION:
  It is the first step to be executed and it can be executed only 
  once.
  Initialization allows you to declare and initialize any loop 
  control variables.
2.CONDITION:
  Condition is the second step in ‘for’ loop where it can be 
  evaluated.
3.INCREMENT:
  Increment is the third step after condition . Flow of control 
  jumps back to the increment statement after the body of ‘for’ 
  loop executes.
  Loop control variables can be updated using this statement.
  This statement can also be left blank.
EXAMPLE:
// Print numbers from 1 to 10
#include <stdio.h>

int main() {
  int i;

  for (i = 1; i < 11; ++i)
  {
    printf("%d ", i);
  }


DO-WHILE LOOP:
The Do-While loop is similar to the while loop with one important difference. The body of do-while loop is executed at least once. Only then, the test expression is evaluated.

SYNTAX OF DO-WHILE :
do
{
   // statements inside the body of the loop
}
while (testExpression);
 EXAMPLE:
// Program to add numbers until the user enters zero

#include <stdio.h>
int main()
{
    double number, sum = 0;

    // the body of the loop is executed at least once
    do
    {
        printf("Enter a number: ");
        scanf("%lf", &number);
        sum += number;
    }
    while(number != 0.0);

    printf("Sum = %.2lf",sum);

    return 0;
}

The major difference between While and do-while :

WHILE
1.It tests the condition before executing any of the statements 
  within the while loop.

2.It doesn’t execute its statements if the condition fails for the 
  first time.

DO - WHILE
1.It tests the condition after having the executed the statements 
  with in the loops.

2.It executes the statements at least once, even if the condition 
  fails.
The Art of Initialising Objects
Tags: ruby, objects, oop
Published: 2020-12-15 17:22:01

Last week, I wrote about [Composition in Ruby](https://dev.to/topofocus/composition-in-ruby-2cff). A module was used to masquerade the initialization of an Object. 

This post introduces another way to simplify programming.

Ruby class names, like their java counterparts, tend to be _verbose_. They are sometimes easy to remember. Programs -- on the other side -- are sometimes difficult to read. 

In the [other Post](https://dev.to/topofocus/composition-in-ruby-2cff) a cryptic _Class.new_ was transformed to a _speaking_ Object-call:
``` ruby
# Previously
> Order.new kind: price: 5, ordertype: :lmt, total_amount: 100
# result
> Limit.order price: 5, size: 100
```

However, this approach requires some overhead.

### A Remind to Stenography
A long time ago, mostly women had the capability to write as fast as one can talk. They substituted long phrases with something they mysteriously could translate to readable words later. 

The same technique is useful to clarify ruby scripts, too

A few days ago, I had to write some queries for [ActiveOrient](https://dev.to/topofocus/activeorient-universal-store-facility-58bi). The query-generator is located in `OrientSupport::OrientQuery`.  
For each subquery a new object is created. 

In a script, its obvious that one can choose another constant to substitute the long name. This fails if used elsewhere and is truly bad practice.

### Lamba's to the rescue

As many modern ruby-classes, `OrientSupport::OrientQuery` is initialized with a bunch of hash-items. 
```ruby
> query =  OrientSupport::OrientQuery.new  from: TheList, where: {name: 'Maria Hellweg' } )
```
Define a Lamba
```ruby
> q = -> (**args){ OrientSupport::OrientQuery.new **args }
```
Then the simple query can be rewritten
``` ruby
> maria = q[ from: TheList, where: {name: 'Maria Hellweg' } ]
> maria.to_s
 => "select from the_list where name = 'Maria Hellweg' "
> maria.execute (...)
```

This trick creates a new query-object just by typing `q[]`.

This is must helpful to create standard-queries

```ruby

> q[ projection: address, from: TheList, where: {name: 'Maria Hellweg' } ].execute
=> "Walddornweg 23"

```
and it can be nested

``` ruby
>  q[ from: q[ from: TestQuery, where:{ a: 2 , c: 'ufz' } ], kind: 'traverse', projection: :day).to_s
 => "traverse day from ( select from test_query where a = 2 and c = 'ufz' ) "
```

### Conclusion

Commonly lamba's are used to introduce aspects of functional programming to ruby scripts. However, they can create objects as well.
This trick avoids assignments of simple constants to complicated class names.  Its a strictly local solution with minimal overhead and without any side effects.
DO Hackathon - Middi Habit Tracker
Tags: dohackathon
Published: 2020-12-15 17:19:08

## Idea Generation
In my mind, application development always boils down to two things: the What and the How. In this post, I'll be describing the former, which in my opinion, is way harder than building the thing itself.
<br/>

## Problem and Solution
One of the things I found difficult when shifting into working from home was adjusting the routine that I've been in for years. Granted, I'm very thankful to be able to work from home, so it's not the worst situation to be it, but it was clear that many people, including myself had trouble adjusting at first.

That's why for this hackathon I'll be building an ultra-simple habit tracker in the form of an intuitive, chatbot interface. The purpose of the application is to allow users to track habits in a way that isn't so "admin-dashboardy". Instead, the interface will be in the form of a chat app, with fun interactions and animations to make tracking habits feel good.
<br/>

## The Specifics - Requirements
Now that we have an idea of the purpose, let's get into the good stuff - requirements. A good starting point is to break it down into two categories: the needs and the nice-to-haves.
<br/>

### Needs
1. The web app needs a chatbot interface that feels natural to use
2. A user should be able to make an account
3. A user should be able to login/logout
4. A user should be able to create/edit habits
5. A user should be able to able to mark a habit as completed
6. A user should be able to view a summary of their habits

### Nice-to-haves
1. Ability to set reminder notifications
2. Downloadable as a progressive web ap

<br/>

Now that we've got a shortlist of features, we can start taking a look at the How: what we'll use to build the darn thing.
Finding job as a junior developer - tips from tech recruiters
Tags: career, beginners, codenewbie
Published: 2020-12-15 17:27:27

---
title: Finding job as a junior developer - tips from tech recruiters
published: true
date: 2020-12-15 17:18:37 UTC
tags: career,beginners,codenewbie
canonical_url: https://www.notonlycode.org/junior-developer-job-tips/
series: Finding a new job - interview guide for developers
cover_image: https://www.notonlycode.org/content/images/2020/12/2020-12-junior-advice-blog.jpg
---

Alright junior devs, here's one especially for you! This is the last, bonus episode of the job hunting series and it's dedicated towards junior developers.

We know that right now finding job as a junior developer is tough - there are fewer opportunities and more candidates. So during the 4 interviews I did for this series I asked one more question: what advice do you have specifically for junior devlopers? This video is a compilation of the answers I got, you'll find here tips from tech recruiters and hiring managers specifically for junior devs.

Let me know what you think if you have any questions about getting job as a junior dev, reach out to me or drop a comment. Take care!

{% youtube w-4P7nz0Fa8 %}

🎥 Video timeline:  
[0:00](https://www.youtube.com/watch?v=w-4P7nz0Fa8&t=0s) Intro  
[0:57](https://www.youtube.com/watch?v=w-4P7nz0Fa8&t=57s) Job application (Angus Mackintosh)  
[2:38](https://www.youtube.com/watch?v=w-4P7nz0Fa8&t=158s) Tech interview (Bart van de Garde)  
[4:34](https://www.youtube.com/watch?v=w-4P7nz0Fa8&t=274s) HR interview (Ross Inman)  
[6:18](https://www.youtube.com/watch?v=w-4P7nz0Fa8&t=378s) Offer negotiation (Matthew Barr)  
[8:02](https://www.youtube.com/watch?v=w-4P7nz0Fa8&t=482s) Outro
Announcing Rocket Releaser
Tags: showdev, python, devops
Published: 2020-12-15 17:15:38

[15Five](https://www.15five.com) has open-sourced a python package for generating release notes and sending them to Slack! Take a look below:

{% github https://github.com/15five/rocket_releaser %}

This allows our QA and other teams to easily see what changes have been deployed and what needs testing. The package also labels PR's and tickets, so everyone is kept in the loop as to what stage of the deployment process their code is in.

The repository is based off of the open-source [circleci boilerplate](https://dev.to/15five/ci-cd-python-packaging-through-circleci-30f2) announced earlier.

<!--
why use it instead of https://github.com/semantic-release/semantic-release ?

-->
Implementing styled components with React
Published: 2020-12-15 17:14:08

Before getting started applying styled components, let me tell you the problem I tried to solve; I wanted to retain the original look and feel of material UI components whilst adding my custom styles to it, for example color and size. Todo this, we need to include material UI’s theme feature which specifies the default style rules of the MUI components, such as color, level of shadow,ripple effect etc…The theme enables us to create a pretty good base for our styling. 
Steps to take 
 * Install the package by typing this code on terminal:
 ```
 * npm install--save styled-components
```
 * Import the styled component on top page like so:
```
 * import styled from 'styled-components'
```
 * Declare 'styled.name_of_element in a variable which will be used to wrap the element to be styled. A typical example: 
```
const button = styled.newButton``
 ```

Application of this is simple, take the variable that was styled, replace it with the button tags in the render like so: ```<newButton>My Styled button</newButton>```

> Note: You can write all your custom styles on a seperate page for proper house keeping, then import that page on your component.
Node/TypeScript Template
Published: 2020-12-15 17:08:50


**Update #2:** I am continually making updates to this template repo, so just keep checking and/or star/watch [the repo!](https://github.com/manavm1990/node-starter-ts)

[**Update:** I made the 'tsconfig' more 'strict.'](https://github.com/manavm1990/node-starter-ts/commit/c345c8091eaa3e6beecb83c9004456982c52be14)

# TLDR

Welp, if you follow me here you pretty much already know the drill!

1. Jump to [the repo](https://github.com/manavm1990/node-starter-ts)
2. Click 'use this template'
3. `clone`
4. `npm i`
5. **2 terminals:** 1 is for ~~`npm run watch`~~ `npm run webpack` and the other is `npm start`.

# What's It All About?

As with 'tinkering' with any tech as a beginner, it's nice to be able to jump right in and code without having to worry about tooling. 

So, once again, I have assembled an 'opinionated' (but not really 'my' opinions) template repo. 

You should just go [read the README](https://github.com/manavm1990/node-starter-ts/blob/master/README.md). 

---

As you code starting in 'src/index.ts', `webpack` will 'compile/transpile' into 'dist.' Meanwhile, `nodemon` will pick up this change and run your stuff.

All the while, your code will be linted by `airbnb` and 'prettification' will also be automated.

There's a bunch of helpful VS Code settings and extensions pre-configured also. 

So, if you're a beginner to this stuff, this will probably be a great way to keep yourself in check with regard to code quality, so you can focus more on learning and less on tooling.

You should [join the discussions here.](https://github.com/manavm1990/node-starter-ts/discussions/1)

# Unimportant After Thought 💭

Ordinarily, people say something like, 'Happy Coding!' at the end of these things. IDGI - I'm usually not 'happy coding.' I'm usually 🤬 at 🐛s and figuring 😖 stuff out. But...I am 'happy' when the stuff starts working!  👏🏾🤓

🤷🏾‍♂️
DAY 15 - Advent of Code 2020 w/ GoLang
Tags: go, adventofcode
Published: 2020-12-15 17:08:22

---
title: DAY 15 - Advent of Code 2020 w/ GoLang
published: true
description: AoC 2020 Day15 solutions in GoLang
tags: golang, AdventOfCode
series: Advent of Code 2020
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/gb6jnhz1didpnth3pbsw.jpeg
---
**DAY15:**
![IM BACK](https://media.giphy.com/media/u6EiPNT9dLDrU7ZQuF/giphy.gif)

So, yesterday I thought I'd wrap up on Advent Of Code but today's problem just clicked. I'm assuming it was meant to be easier after those last few days.

It was odd that it took exactly zero lines of changes for part two. All you had to do was alter the final turn. It just took a bit longer. Mine timed in at about 7.6s

```golang
package days

import (
	"fmt"

	inputs "../inputs"
)

// https://adventofcode.com/2020/day/15
// Fifteen : advent of code, day Fifteen part1 and 2
func Fifteen() {
	inputSlice := inputs.Day15

	// k: number spoken | v: {num of times spoken, last time spoken}
	spoken := make(map[int][]int)

	for i, num := range inputSlice {
		spoken[num] = []int{1, i, i}
	}

	fmt.Print("(Part 1) - 2020th number spoken: ")
	fmt.Println(getLastNumberSpoken(spoken, 2020))
	fmt.Print("(Part 1) - 2020th number spoken: ")
	fmt.Println(getLastNumberSpoken(spoken, 30000000))
}

func getLastNumberSpoken(spoken map[int][]int, last int) int {
	nextNum := 0
	var lastNum int
	var lastTurn int
	for _, v := range spoken {
		if v[1] > lastTurn {
			lastTurn = v[1]
			lastNum = v[0]
		}
	}

	for i := len(spoken); i < last; i++ {
		if _, ok := spoken[lastNum]; ok {
			if spoken[lastNum][0] == 1 {
				nextNum = 0
			} else {
				nextNum = spoken[lastNum][1] - spoken[lastNum][2]
			}
		}

		if _, ok := spoken[nextNum]; ok {
			spoken[nextNum][0]++
			spoken[nextNum][2] = spoken[nextNum][1]
			spoken[nextNum][1] = i
			lastNum = nextNum
		} else {
			spoken[nextNum] = []int{1, i, i}
			lastNum = nextNum
		}
	}

	return nextNum
}

```

[Link to Github source file](https://github.com/dizveloper/AdventOfCode/blob/main/2020/days/day15.go)
Simple Settings List in React Native
Tags: react, reactnative, typescript, javascript
Published: 2020-12-15 17:03:10

---
title: Simple Settings List in React Native
published: true
description: I show you how to create a simple Settings List in React Native, without using 3rd party dependencies
tags: react, reactnative, typescript, javascript
cover_image: https://miro.medium.com/max/1400/1*ZTZayT_zVx3BcKF9SGB3cg.png
---

There are many libraries that provide a way to create a settings screen or list for your React Native app. I show a simple way to achieve this with basic or no dependencies.

You can find the source code [here](https://github.com/reime005/SpaceSeek/blob/master/src/components/Settings/SettingsList.tsx). In essence, we use the React Native `SectionList` for a structured or sectioned partition of the list. Alternatively, you could use a `FlatList` or even `ScrollView` if you have a small amount of items to put in your list. For imaging, you would use `react-native-svg` or alternatively the React Native `Image`. Persistence, if needed for things like a dark mode switch, could be achieved by `react-native-async-storage`.

##The SectionList

The most interesting feature about the [SectionList](https://reactnative.dev/docs/sectionlist) is its sectioned data handling. You can pass the data via `sections`, its function to render items via `renderItem` and its function to render the section header via `renderSectionHeader`.

![0*lyUnxHSsm0htic-k](https://dev-to-uploads.s3.amazonaws.com/i/apk7uhkuakaocfop5tjq.png)

Structured data is required for the Section List. Each section has a header and a bunch of items. You can define this structure for yourself. This means, you could also add elements like a header icon, as you can see in the orange box.

{% gist https://gist.github.com/reime005/6a35290187f98aeb44334d77fb85c223 %}

When you put this data in the `SectionList`, when using TypeScript, types for the rendering function should be automatically inferred. This makes writing these functions much easier. It also prevents possible errors by enforcing types on `sections`, for example to require an array type.

{% gist https://gist.github.com/reime005/42b1b1a24ca0a576e1dd78e6bc868049 %}

##The Section Item and Header

When looking closely, you may have also noticed that the Section Item has rounded borders, if they are first or last in the list. This can be achieved by comparing the current render index against the `sections` data that you put into the `SectionList`.

{% gist https://gist.github.com/reime005/250b7008a7e3a33fb0223fdfe7987b3c %}

The Section Header is also a rather simple component. It needs to render the title and icon that you specified.

{% gist https://gist.github.com/reime005/d834fce22ff34a33ea8c121048f52f5c %}

Originally published at [https://mariusreimer.com](https://mariusreimer.com/blog/id/simple-settings-list-in-react-native) on December 15, 2020.
All you know about media queries
Tags: css, mediaquery, responsivewebdesign, webdev
Published: 2020-12-15 17:02:17

While building a website, sometimes we got many confusions about how to make it responsive? what is that responsive mean? what is that media query? why we need that and how to use that?

Cool, you will get an answers for the above questions here, let's go with  responsive first

A responsive website will display a different interface depending on what device is used to access the site.

For example, the font-size of text, images width and height, padding, margin, and many other CSS properties will have different values for different screen sizes, like a website may appear one way on a laptop, another way on a tablet, and still another way on a smartphone.

That's what responsive mean, then how to make our website responsive, there are several ways for that,

One method is to dynamically detect the user's platform and load specific HTML and CSS for the corresponding device.

Another option is to use media queries, which automatically loads different CSS styles depending on the size of the browser window.
 
Then what is the media query? Wait, here we go,

Media query is a feature of CSS, which acts as filters for different screen sizes means it enable the webpage content to adapt to different screen sizes and resolutions.

why we need media queries? because to customize the appearance of websites for multiple devices.

How to use media queries? 

Media queries may be inserted within a webpage's HTML or included in a separate .css file referenced by a webpage.

Ex:![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gmf524n05n7fupdc6nh2.PNG)

The media query above activates if a user's browser window is 768 pixels wide or less. This could happen if you shrink your window on a desktop computer or if you are using a mobile device such as a tablet, to view the webpage.

You can also write media queries for different media types like:

 1. Ex: @media print and(max-width:360px){ }
    print define intended for paged material and documents viewed 
     on a screen in print preview mode.

 2. Ex: @media screen and(min-width:670px){ }
    Intended primarily for screens.
 
 3. Ex :@media speech and(max-width:1024px){ }
    Intended for speech synthesizers.
    
 4. Ex: @media all and (min-width:520px){  }   all define suitable 
     for all devices.                                 
    
  And at last, like all modules within a cascading stylesheet, the ones that appear further down the list override the ones above them. Therefore the default styles are typically defined first within a CSS document, followed by the media queries for different screen sizes.

For example, the desktop style might be defined first, followed by a media query will styles for tablet users, followed by a media query designed for smartphone users and styles may also be defined in opposite order. 
     
Thanks for reading ,it's my first blog ,happy to hear a feedback and suggestion in comments section
Hoisting problems
Tags: javascript, webdev, codenewbie, beginners
Published: 2020-12-15 16:46:45

```js
var guessMe = 2;
(function () {
  console.log(guessMe); // undefined
  var guessMe = 5;
  console.log(guessMe); // 5
})();
```

---

**Thanks for reading 💙**  
Follow **@codedrops.tech** for daily posts.  
[Instagram](https://www.instagram.com/codedrops.tech/) ● [Twitter](https://twitter.com/codedrops_tech) ● [Facebook](https://www.facebook.com/codedrops.tech/)

Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript  
**[codedrops.tech](https://www.codedrops.tech/)**
Budibase 0.4.2 has been released 🎉
Tags: beginners, webdev, opensource, programming
Published: 2020-12-15 16:23:19

---
title: Budibase 0.4.2 has been released 🎉
published: true
description: Budibase is an open-source low code platform, helping developers and IT professionals build web apps 50x faster.
tags: beginners, webdev, opensource, programming
//cover_image: https://dev-to-uploads.s3.amazonaws.com/i/70ax5jfcf6hfjtgs7ce3.jpg
---

![Budibase UI](https://dev-to-uploads.s3.amazonaws.com/i/70ax5jfcf6hfjtgs7ce3.jpg)

Budibase 0.4.2 has been released 🎉

*Budibase is an open-source low code platform, helping developers and IT professionals build web apps 50x faster.*

Title: Back to the future ⏲️

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/b33hpnlr223jiatnp3wg.gif)

🥳 Apps created with Budibase are now backward compatible 🥳

In this version:
- Role-based access control
- Users are stored within a table allowing you to reference them within your app
- Perf improvements & screen transitions
- Stat Card Component
- Rich Text Component

Seriously, [check it out](https://budibase.com), or [visit our Github repo](https://github.com/Budibase/budibase).
CodeIgniter Tutorial
Published: 2020-12-15 16:12:17

Codeigniter is a powerful platform and it follows a pattern of MVC. MVC is a Model View Controller is a toolkit for designing a website. Codeigniter Tutorial aimed at implementing the framework of CodeIgniter and basic configuration and setup. Codeigniter is a quick development web platform for open source applications. https://www.phptpoint.com/codeigniter-tutorial/
Inception
Tags: dohackathon, testing
Published: 2020-12-15 15:56:00

This is my first DO hackathon.

The category I picked is **Random Roulette**. Because I do not have a choice :)

The idea is silly, but not fun.

As a performance engineer, I do not have a lot of development experience. I work in testing and monitoring tools. 

I am learning Python and Flask. I thought of creating some kind of utility for **Apache JMeter**.

Let's get started.