teleren/devto huggingface dataset:
Structures and arrays in C
Tags: c, structures, arrays, beginners
Published: 2019-12-25 19:43:42

---
title: Structures and arrays in C
published: true
description: Working with structures inside arrays in the C programming language
tags: C, structures, arrays, beginners
series: Basics of the C programming language
---

####Overview

As covered in the previous post, structures are very useful for logically grouping related elements together. This can be further extended by combining them with arrays. Since structures are a type, it is perfectly valid in C to create an array of structures. So, if you had to keep track of many dates (to continue with the previous examples), an array could be created to hold all of them in one place.

#####Declaring an array of structures

To declare an array of structures, the syntax is similar to declaring as any other array, but preceded by the struct keyword and structure type:

```c
// declares an array of ten items of structure type date
struct date myDates[10];
```

To access or assign elements inside the array, use the index and the dot notation:

```c
myDates[1].month = 7;
myDates[1].day = 9;
myDates[1].year = 1979;
```

Initializing of arrays containing structures is similar to initializing multidimensional arrays. The internal curly brackets below are optional, but they make the code much more readable, so are recommended:

```c
//assigns the first 3 dates in an array of 6
struct date myDates[6] =
{
  {7, 9, 1979},
  {11, 26, 2019},
  {12, 26, 2019},
};

  // to initialize values besides the one declared in the initial initialization, the curly brackets can be used inside the declaration
struct date myDates[3] =
{
  [4] = {1, 1, 2020}
};

// ...and dot notation can be used to assign specific elements as well
struct date myDates[3] = {[1].month = 12, [1].day =30};
```

#####Structures that contain arrays

It is also possible to define structures that contain arrays as members. The most common use case of this is to have strings inside a structure, e.g. creating a structure named 'month' that contains both the number of days and the abbreviation for the name of the month:

```c
struct month
{
  int numberOfDays;
  char name[3];
}

struct month aMonth;
aMonth.numberOfDays = 31;
aMonth.name[0] = 'J';
aMonth.name[1] = 'a';
aMonth.name[2] = 'n';

// a quicker way to do the above, for the name, though slightly less readable, would be to use the following notation
struct month aMonth = {31, {'J', 'a', 'n'}};
```
Structures in C
Tags: c, structures, basics, beginners
Published: 2019-12-25 19:43:16

---
title: Structures in C
published: true
description: Working with structures in the C programming language
tags: C, structures, basics, beginners
series: Basics of the C programming language
---

####Overview

As covered in the previous post, structures are very useful for logically grouping related elements together. This can be further extended by combining them with arrays. Since structures are a type, it is perfectly valid in C to create an array of structures. So, if you had to keep track of many dates (to continue with the previous examples), an array could be created to hold all of them in one place.

#####Declaring an array of structures

To declare an array of structures, the syntax is similar to declaring as any other array, but preceded by the struct keyword and struct type:

```c
// declares an array of ten items of structure type date
struct date myDates[10]
```

To access or assign elements inside the array, use the index and the dot notation:

```c
myDates[1].month = 7;
myDates[1].day = 9;
myDates.year = 1979;
```

Initializing of arrays containing structures is similar to initializing multidimensional arrays. The internal curly brackets below are optional, but they make the code much more readable, so are recommended:

```c
struct date myDates[3] =
{
  {7, 9, 1979},
  {11, 26, 2019},
  {12, 26, 2019},
};

  // to initialize values besides the one declared in the initial initialization, the curly brackets can be used inside the declaration
struct date myDates[3] =
{
  [4] = {1, 1, 2020}
};

// ...and dot notation can be used to assign specific elements as well
struct date myDates[3] = {[1].month = 12, [1].day =30};
```

#####Structures that contain arrays

It is also possible to define structures that contain arrays as members. The most common use case of this is to have strings inside a structure, e.g. creating a structure named 'month' that contains both the number of days and the abbreviation for the name of the month:

```c
struct month
{
  int numberOfDays;
  char name[3];
}

struct month aMonth;
aMonth.numberOfDays = 31;
aMonth.name[0] = 'J';
aMonth.name[1] = 'a';
aMonth.name[2] = 'n';

// a quicker way to do the above for the name would be to use a shortcut
struct month aMonth = {31, {'J', 'a', 'n'}};
```
Tumblr new post APIs not working
Tags: help
Published: 2019-12-25 19:03:48

Have been trying to get the Tumblr new post APIs working for quite some time. Unfortunately, I am getting errors each time I try these. 

Been following the [api docs judiciously](https://www.tumblr.com/docs/en/api/v2#posts---createreblog-a-post-neue-post-format) - to no avail.

All other data fetching works find, even with OAuth.

I am using Postman for the requests.

A working curl request that creates a new post on a Tumblr blog from the bash/terminal will be of great help.

Thanks,
Sarthak
Plug.Static priv/a/:id/b
Published: 2019-12-25 18:41:31

I'm setting up some routing to static assets. I essentially have a buckets file structure with IDs in the path. Is there a way to use variables in the paths. For instance,

  plug Plug.Static,
    at: "/public/:id/:bid",
    from: {:baspia, "priv/public/:id/bundles/:bid.json"}
What was your win/loss this year? What important lesson did you learn?
Tags: discuss, yearlyretro
Published: 2019-12-25 18:30:11

---
title: What was your win/loss this year? What important lesson did you learn?
published: true
description: 
tags: #discuss #yearlyretro
---

2019 is coming to an end and it's time for a new beginning. It was a very good year for me overall, I started blogging, gave a little back to the community, learned lots of new tools and technologies, landed my first fully remote job and visited two countries. 
Aside from almost losing my dad and getting cut off from the rest of the world (internet shutdown in Iran), everything else went great.
The important lessons for me were:
1. Never underestimate the power of your will 💪💪
2. Remote job is difficult but its advantages outweighs its disadvantages.(at least for me)

I always like to hear stories and learn from others so please share your thoughts. I'd love to hear them.
Members Abusing Tags
Tags: discuss
Published: 2019-12-25 18:17:42

---
title: Members Abusing Tags
published: true
description: 
tags: discuss
---

I'm going to keep this short and sweet.  Anybody else notice people abusing tags?  By which I mean, tagging something say with "foobar", and then "foobar" appears nowhere in the post.  But having been tagged foobar, it pushes other bona fide foobar content down the foobar tag page.  

I complained about a specific instance of this in a tag in which I'm active, but I'm wondering as to the community's thoughts and experience around this.  Thanks for your consideration.
Happy Ruby Day!!!
Tags: ruby, watercooler
Published: 2019-12-25 17:26:53

[Ruby 2.7.0 Released](https://www.ruby-lang.org/en/news/2019/12/25/ruby-2-7-0-released/)


Introducing:

* Pattern Matching
* REPL (irb) improvement
* Compaction GC
* Separation of positional and keyword arguments
and more!
Daily Challenge #144 - Box Office Clerk
Tags: challenge
Published: 2019-12-25 17:00:17

---
title: Daily Challenge #144 - Box Office Clerk
published: true
series: Daily Challenge
description: Can you return change to everyone in line? 
tags: challenge
---
You work as a clerk at a cinema box office and a new movie has been released. There are a lot of people standing in a line waiting to buy a ticket with either `25`, `50`, or `100` dollar bill. Each ticket for the new movie costs `25 dollars`. 

If you start with no money in the register, can you sell a ticket to every person in line and give change? You must attend to everyone in order, it would be unfair to sell tickets out of order. 

Return `YES`, if you can sell a ticket to every person and give change.
Otherwise, return `NO`. 

**Examples**
`tickets([25, 25, 50])`  => `YES` 
`tickets([25, 100])`  => `NO` You will not have enough money to give change to 100 dollars
`tickets([25, 25, 50, 50, 100])`  => `NO` You will not have the right bills to give 75 dollars of change (you can't make two bills of 25 from one of 50)

**Tests**
`tickets([25, 25, 50, 50])`
`tickets([25, 50, 25, 100])`

Good luck!

***
_This [challenge](https://www.codewars.com/kata/555615a77ebc7c2c8a0000b8) comes from AlexIsHappy on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
When is it appropriate to use expression bodied methods?
Tags: csharp, codequality, discuss
Published: 2019-12-25 16:43:17

C#6 introduced the concept of [expression bodied members](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-6#expression-bodied-function-members) for methods and readonly properties, and c#7 expanded that concept further to also include constructors, finalizers, getters and setters.

Personally, it took me some time to get used to this concept, and for quite a long while I've avoided using expression bodied members.

In a recent project I've been working on, I've had to deal a lot with the file system, so I've created a class to wrap all the IO operations, to enable easy unit testing. 
Since it's a simple wrapper class with almost no logic, most of the methods in this class are one liners - things like 
```csharp
    public void DeleteFile(string fullName)
    {
        File.Delete(fullName);
    }
```

After writing a few of these methods, I've decided to change them to expression bodied, which makes them look like this:
```csharp
    public void DeleteFile(string fullName)
        => File.Delete(fullName);
```

Except in one-liners, where an expression bodied member seems like an obvious choice, where else is it appropriate to use that technique?
Which scheduler scheduled the scheduler in minikube ?
Tags: kubernetes, devops, go
Published: 2019-12-25 14:37:08

In oneliner, minikube is a tool that makes it easy to run Kubernetes locally.

In `kube-system` namespace, we can see result like below,

```bash
$ kubectl get pods -n kube-system -o name -l tier=control-plane
pod/etcd-minikube
pod/kube-apiserver-minikube
pod/kube-controller-manager-minikube
pod/kube-scheduler-minikube #scheduler is running, but who scheduled ?
```

Whenever we create pod(rs/deployments/sts/ds), `Scheduler` is the one which schedules this pods into any of the available node (in minikube, there is only one).
In minikube, `kube-scheduler-minikube` is the one who schedules. For long time, I wondered who scheduled the `kube-scheduler-minikube` pod to this minikube node. I assumed it as `magic` 🤪

Now, I understood how things are happening, here you go:

There is something called [static pods](https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/) in kubernetes. Without  master components (`api-server`, `etcd`, `scheduler`, `controller-manager`), we can run pods in `kubelet` **directly**. Minikube used this to run master components and thus formed the cluster.

#### Proof:
```bash
$ minikube ssh
$ ps aux | grep kubelet
root      3035  3.9  4.6 1377692 91476 ?       Ssl  07:27   0:06 /var/lib/minikube/binaries/v1.15.2/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=docker --hostname-override=minikube --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.99.100 --pod-manifest-path=/etc/kubernetes/manifests
```

In the above example, kubelet is started with `--pod-manifest-path=/etc/kubernetes/manifests`

> Note: `--pod-manifest-path` is path to the directory containing static pod files to run.

```bash
$ ls -l /etc/kubernetes/manifests
-rw-r----- 1 root root 1532 Jan  1  0001 addon-manager.yaml.tmpl
-rw------- 1 root root 1990 Dec 25 07:27 etcd.yaml
-rw------- 1 root root 2893 Dec 25 07:27 kube-apiserver.yaml
-rw------- 1 root root 2262 Dec 25 07:27 kube-controller-manager.yaml
-rw------- 1 root root  990 Dec 25 07:27 kube-scheduler.yaml
```

Thus when kubelet started, it started the master components and thus **cluster formed**.
15 tips for Job Seekers for the Holiday
Published: 2019-12-25 14:07:01

1. Take a short break.
2. Review your resume.
3. Set up your LinkedIn Profile.
4. Festively network in person.
5. Upskill with online courses.
6. Practice your interview skills.
7. Clean up your social media presence.
8. Consider moving to where the jobs 
     are.
9. Consider changing industry.
10. Change your mindset and job 
      Search strategy.
11. Ask yourself what has been holding
       you back so far.
12. set up your portfolio very well
13. Connect with the right people on social media like (Twitter, LinkedIn)
14. Join communities related to your job, example for those in tech will join (Ardejob, GDG, Facebook development circle)
15. Most importantly Always pray and believe in God

Take some time during the Holidays to finesse your job search for 2020. 

Goal = Plan + Method + Discipline.

Happy Holidays, everyone and I wish you a Good job come 2020! 😍😍😍🤩😎🥰😍😎
Wish you all health, happiness and lots of love 🎄☃️🎅
Tags: merrychristmas, happiness, health, nocode
Published: 2019-12-25 14:03:01

---
title: Wish you all health, happiness and lots of love 🎄☃️🎅
published: true
description: Wish you all health, happiness and lots of love 🎄☃️🎅
tags: merry Christmas, happiness, health, no code
---
No code. ⚠️ 
No meetings. ⛔
No email/slack/etc. 🚫
Yes to Family time. 👍

Wish you all health, happiness and lots of love 🎄☃️🎅
Funniest & most evil Input-Forms
Tags: funny, webdev, html
Published: 2019-12-25 13:51:29

Hi guys,

here something a very nasty and funny developer hase create to drive its user crazy. Some really inovative possibilities of how to use the input fields in forms. (Unfortunately I don't know how to add a video here, so just the link to the 9gag [by the way kudos to that guy, I'm just sharing :) )

[9gag](https://img-9gag-fun.9cache.com/photo/a7w0nZb_460sv.mp4)

<a href="/gif/devil-vfsaRs" title="DEVil"><img src="https://i.makeagif.com/media/12-26-2019/vfsaRs.gif" alt="DEVil"></a><div style="font-size:11px;">make <a href="/" title="make a gif">funny GIFs</a> like this at MakeaGif</div>

Happy X-MAS to you all.
[Devmates.co] 📣 Expressive Words 
Tags: challenge
Published: 2019-12-25 13:08:54

Hello👋, 
*My name is [Alex](https://twitter.com/alexwawl) and I'm maker of [Devmates.co](https://devmates.co).* 😊

*We are resolving daily coding problems which asked by top tech companies together. We share our solutions, give some help if anyone stuck, support each other and just hangout together in the internet.* 🍻☕️💬

*I get this problem from our members or just searching them in the internet(leetcode forums, Glassdoor, teamblind, etc.). Sometimes this problem can be very easy, sometimes too 👷‍♂️hard, everything depends on skills but we are trying to resolve all of them and Have Fun.*  🙌 

Today I want to [share problem](https://devmates.co/home/problems/-LwlpVVnfZpwqv0ls8jp) which was asked by 🏢Google.

#####Problem:
Given an original word and an expressive word.

Return the starting and ending index of repeating characters which are not present in original string.

For example, given an original word "Hello" and an expressive word "Heeeellooo". "e" is being repeated three times and "o" is being repeated two times so you have to return [["e", 2, 4], ["o", 8, 9]]

#####Example:
  __Input__: 
    original="Hello", 
    expressiveWord = "Heeeellooo"
  __Output__: [["e", 2, 4], ["o", 8, 9]]
  __Why__: "e" is being repeated three times and 
           "o" is being repeated two times.

[Link to the Problem](https://devmates.co/home/problems/-LwlpVVnfZpwqv0ls8jp)


🙌 Don't hesitate to share your solutions directly on [devmates.co](https://devmates.co)
Is JavaScript a silver bullet?
Tags: javascript
Published: 2019-12-25 12:13:41

I've been in a software development for 4 years and I'm using JavaScript as my main language on web, mobile, api, desktop development even on end to end testing and devOps tasks. Some developers who use this or that language says 

*"Does your language able to do this or that?"* and I'm gonna say 
*"Yeah sure it can because in reality it does"*. 

Clearly I'm biased in favor of JavaScript 😂. And they gonna say *"Oh really?"*.
Receiving that kind of reaction lead me to share this.

*"JavaScript is not a silver bullet and it will never be."*

Now wondering...
Why did I say that? 

*"You're not suppose to say that because you are a JavaScript guy"*

To my fellow JavaScript guys around there 😂 forgive me.

JavaScript is not a silver bullet, just because it can do a lot of things other language cannot, which solves a lot of problems. It just happened that JS community is very active and rapidly growing. I can say that yeah JavaScript can do this thing like this language but not 100% much better than it's counter part language because it really depends on many factors. It just happen that it's flexible to do things that other language can.

😂 Final thought to other developers and my fellow JavaScript Engineers/Developers.

*"JavaScript is not a silver bullet and it will never be"*

BUT......

*"JavaScript can be use to built one..."*

😁
Day 25 of the Visual Studio Tips Advent Calendar is now live
Tags: visualstudio
Published: 2019-12-25 12:06:12

Day 25 of the Visual Studio Tips Advent Calendar is now live. 

I'm a little late posting today because of the Christmas morning Chaos.

This is the final day in the Calendar, I hope you have enjoyed it.

https://visualstudiotips.co.uk/calendar/

#VisualStudio #DevDecember #VsTipsAdvent #Advent
Oculus QuestだけでフリーロームVR向けに複数人を位置トラッキングする
Tags: unity3d, oculusquest
Published: 2019-12-25 12:00:00

---
title: Oculus QuestだけでフリーロームVR向けに複数人を位置トラッキングする
published: true
tags: Unity, OculusQuest
date: 20191225T12:00Z
canonical_url: https://qiita.com/shiena/items/69a2cb561b3ef44522cc
---
# はじめに

本記事はUnity #2 Advent Calendar 2019　の14日目の記事です。
フリーロームVRをマルチプレイヤーで実現するためにはプレイヤーのトラッキングが必要となり割と大掛りな機器が必要となります。
それをOculus Questのガーディアンだけでそこそこの精度で実現できたので紹介したいと思います。

## フリーロームVRとは

フリーロームVRとはプレイヤーがフィールド内を自由に歩き回る事が可能なVRコンテンツで以下のような施設があります(ありました)

* [BIOHAZARD WALKTHROUGH THE FEAR](http://dynapix.jp/am/biohazard7_vr/)
* [近未来制圧戦アリーナ 攻殻機動隊ARISE Stealth Hounds - VR ZONE SHINJUKU](https://vrzone-pic.com/shinjuku/activity/koukaku.html)
* [ゼロレイテンシー](https://tokyo-joypolis.com/attraction/1st/zerolatency/)

# Oculus Questの設定

ホーム画面でルームスケールに設定して歩ける範囲をガーディアンの境界線を引きます。以下の図は境界線とそれを元に生成されたプレイエリア(四角形の領域)です。
![image.png](https://dev-to-uploads.s3.amazonaws.com/i/351aq89g29cixc0oz201.png)

この時にマルチプレイで使用するOculus Questでほぼ同じプレイエリアを作るのが位置合わせで重要になってきます。
床の四隅にガムテームなどで`┌`、`┐`、`└`、`┘`のような形で目印を作りそのラインに沿って境界線を引くとほぼ同じプレイエリアができあがります。

# Unityの設定

1. [Oculus Integration](https://assetstore.unity.com/packages/tools/integration/oculus-integration-82022)をインポートします。
1. `OVRCameraRig`プレハブや`OVRPlayerController`プレハブをヒエラルキーに追加します。
1. このプレハブにアタッチされている`OVRManager`を探し、`Tracking` > `Tracking Origin Type`を`Stage`に変更します。

![image.png](https://dev-to-uploads.s3.amazonaws.com/i/6yue8szo5e2bmbk27xv0.png)

`Tracking Origin Type`が`Eye Level`か`Floor Level`ではプレイヤーのXZ座標はヒエラルキーに配置した位置のままですが、`Stage`にするとゲームの原点座標(0,0,0)はプレイエリアの中心になり、プレイヤーのGameObjectはプレイエリアの中心を基準にした位置に移動します。この仕組みによって実際に歩く領域とゲーム内の位置を合わせる事ができます。

# プレイエリアの問題

ルームスケールのプレイエリアで複数台のOculus Questの位置トラッキングができそうですが1つだけ問題があります。
ゲームの原点とプレイエリアの中心を合わせる事はできるのですがY軸が回転してZ軸の向きが原点から4辺のいずれかになり確定することができません。
つまり、同じ領域のプレイエリアを作っても0°、90°、180°、270°のいずれかに回転してしまうので、プレイヤーのTransformを同期しても位置が合わない事があります。

この問題をオペレーションなしに解決して正面方向を合わせる方法として以下の手順を考えました。

1. プレイエリアを4等分する。(十字型でも×でもよい)
1. プレイヤーの初期位置を4等分した領域のいずれかに配置して正面方向も固定する。たとえば(3, -3, 0)を初期位置、このPositionに対してforwardを正面方向とするならback、right、leftを向かないこと。
1. ゲームを開始して**数フレーム以降に**プレイヤーが正面を向いていなければプレイエリアが回転しているので原点を中心にプレイヤーのGameObjectを回転する。プレイヤーが右を向いているとプレイエリアは90°回転なのでプレイヤーのGameObjectを-90°回転する。

ゲーム開始直後だとプレイヤーの位置が反映されていないので`Awake`や`Start`を使えません。ネットワークライブラリで同期する直前あたりでフェードインして回転補正すると無難だと思います。もっと良い方法があればコメントで教えていただけると助かります。

**回転補正前のプレイエリアとプレイヤーの位置と向きのパターン**

![image.png](https://dev-to-uploads.s3.amazonaws.com/i/u9s7ekl743wpcbjpf4zh.png)

# まとめ

Oculus Questのガーディアンすごい！
How to Host Quasar application on aws in 10 mins using aws-amplify
Tags: codeguru, vue, quasarframework, aws
Published: 2019-12-25 11:55:14


{% youtube 1F0SfYmrSbA %} 


Hello code guru's welcome back. 

In this video we will discuss on hosting quasar application on aws in under 10 minutes using aws-amplify framework.

If you like more content from us please do consider supporting us on Patreon at https://www.patreon.com/codeguru

Please do not forget to provide your feedback  or any topic suggestion in the below comments section.

You can also find us on 
twitter   : https://twitter.com/codeguru_io
facebook  : https://www.facebook.com/codeguru.io
instagram : https://www.instagram.com/codeguru.io/
Youtube   : https://www.youtube.com/c/codeguru_io