teleren/devto huggingface dataset:
PHP 7.4 Typed Properties BC Problems
Tags: php
Published: 2019-12-29 06:03:41

---
title: PHP 7.4 Typed Properties BC Problems
published: true
date: 2019-12-27 02:13:51 UTC
tags: php
canonical_url: 
---

Prior to PHP 7.4, declaring property scalar types was done with DocBlocks as follows:

```
/ **@var int|null** /
public $id;
```

With typed properties introduced in PHP 7.4, the scalar type can now be set like this:

```
public ?int $id;
```

This is awesome, it cuts down on excessive boilerplate and the PHP interpreter will not allow an invalid value to be set on the property.

But, there are a couple caveats to be aware of...

Without setting a property type, one would be able to have a class property such as:

```
//class.php

<?php
class MyClass {

    / **@var int|null** /
    public $id;
}
```

And then call the property without any problems like:

```
//test.php

<?php
require('class.php');

$object = new MyClass;
$var = $object->id;

var_dump($var);

$:> php -f test.php
NULL
```

However if you declare the property type and then attempt to access that type as above, you'll get a FatalError. I.e.

```
//test.php

<?php
class MyClass {

    public ?int $id;
}

$object = new MyClass;
$var = $object->int;

echo $var;

$:> php -f test.php
Fatal error: Uncaught Error: Typed property MyClass::$id must not be accessed before initialization...
```

To overcome this, you must set the value of `$id` before attempting to access it.  This can be accomplished in a number of ways.

```
class MyClass {

    public ?int $id = null;
}

class MyClass {

    public ?int $id;

    public function __construct() {
        $this->id = null;
    }
}

class MyClass {

    public ?int $id;

    public function setId(?int $id) {
        $this->id = $id;
    }
}
```

Using any of the above means of setting `$id` before accessing the value of `$id` would result in the following:

```
//class.php
<?php
class MyClass {

    public ?int $id = null;
}

$object = new MyClass;

$var = $object->id;

var_dump($var;)

$:> php -f class.php
NULL
```

Of course if you are using setter's to set the value of `$id`, you must call the setter method before accessing the property.
Lighthouse CSS clip-path Animation
Tags: css, html, javascript, codepen
Published: 2019-12-27 02:11:41

I tried to mimic light house animation from the dribble shot.

What I learnt while working on this is that, you can animate CSS clip-path using CSS animation.
Codepen link-
https://codepen.io/prathameshkoshti/full/RwNWWxx

Dribbble shot:
https://dribbble.com/shots/3912302-Lighthouse-Animation
Advanced Docker Image Construction with Bash
Tags: linux, containers
Published: 2023-01-06 01:47:40

---
title: Advanced Docker Image Construction with Bash
published: true
date: 2019-12-27 02:01:37 UTC
tags: Linux,Containers
canonical_url: https://brandonrozek.com/blog/docker-image-bash/
---

On current versions of Docker, you can’t mount volumes during image construction. This poses an issue for me as I don’t want to replicate gigabytes of data already existing on my disk when it won’t appear on the final build. Therefore, instead of building an image with a traditional Dockerfile, we’re going to use a bash script on a running base image container and export the filesystem to create the image from.

So first run the base image with the mounts that you want

```
docker run -v /mnt:/mnt -td --name containername baseimage /bin/bash

```

Then copy whatever `setup` script you have and execute it on the running container

```
docker cp setup containername:/setup
docker exec -it containername /setup

```

Once the setup script finalizes, we can export the container filesystem into a file called `image.tar`

```
docker export --output="image.tar" containername

```

Once we’ve exported the filesystem, we can get rid of the existing container

```
docker stop containername && docker rm containername

```

Now create a `Dockerfile` with the following:

```
FROM scratch
ADD image.tar /
CMD ["bin/bash"]

```

Now you can create the image by building the Dockerfile

```
docker build -t finalimagename .

```
Concent ReadMe have been translated to en
Tags: react, concent
Published: 2019-12-27 01:55:15

Hi, my dear friend, I am fantasticsoul, concent [README.md](https://github.com/concentjs/concent) has been translated to english language yet, hope you can know more about it by reading it.

**how Concent works**
![](https://raw.githubusercontent.com/concentjs/concent-site/master/img/cc-core.png)

[online js example](https://codesandbox.io/s/concent-guide-xvcej)
[online ts example](https://codesandbox.io/s/concent-guide-ts-zrxd5)

If you have any question about `Concent`, you can read the articles below to know more about it.
- [use Concent, release react hook's maximum energy](https://dev.to/fantasticsoul/use-concent-release-react-hook-s-maximum-energy-2ldf)
- [concent online demo updated, challenge vue3 composition api & setup!](https://dev.to/fantasticsoul/concent-online-demo-updated-challenge-vue3-composition-api-setup-g7j)
- [Concent, born for build large scale and high performance react app](https://dev.to/fantasticsoul/concent-born-for-build-large-scale-and-high-performance-react-app-3l01)

Star [Concent](https://github.com/concentjs/concent) if you are interested in it, I will appreciate it greatly.

Official doc see here(https://concentjs.github.io/concent-doc/en/)
Happy Birthday Torah && Tech!
Tags: judaism, hanukkah, torah, tech
Published: 2019-12-29 02:27:06

---
title: Happy Birthday Torah && Tech!
published: true
date: 2019-12-27 00:39:07 UTC
tags: judaism,hanukkah,torah,tech
canonical_url: https://blog.yechiel.me/happy-birthday-torah-tech-d5e480020ecc
cover_image: https://cdn-images-1.medium.com/max/1024/1*rcRUt0v8lptMWTEMzY5SQw.jpeg
series: Torah && Tech
---


Chanukah is one of the most well-known, and well-loved, holidays in the Jewish calendar.

The name Chanukah has two meanings.

The first comes from the root חנך and means “renewal” and “dedication.” That name comes from the rededication of the temple (the Chanukat Habayit) after the Syrian Greeks defiled it.

The second meaning of the name Chanukah is a portmanteau of the Hebrew words חנו כ”ה (they rested on the 25th) referring to the calm that was finally achieved with the end of the battles between the Maccabees and the Hellenists that occurred on the 25th of Kislev.

About a year ago, two rabbis turned web-developers, were trying to come up with ideas on how to keep in touch after an upcoming move and career switches that threatened to separate them.

A few weeks later, on the week of Chanukah, we realized the first meaning of the holiday’s name by “dedicating” a new weekly newsletter, and that’s how Torah && Tech was born!

Now, a year and 55 issues later, we are truly amazed at the impact we’ve been able to have. What started as a way of forcing two friends to keep in touch ended up touching 150 people a week! The feedback we’ve received from Jews and non-Jews, techies, and the “technically challenged” alike let us know that this is content the world really needs.

As we’re getting ready to transition to the second meaning of Chanukah, as Torah && Tech is maturing and “settling down,” the tech world still has many questions it needs to answer and conversations it needs to hold. Questions around ethics, morality, and the impact we have on the world.

At Torah && Tech, we are here for these conversations. We want to hear your voices. And we will continue to spread the voice of the Torah and be a “light unto the nations.”

Chanukah Sameach!

Yechiel

PS: if you haven't subscribed to the Torah && Tech newsletter you probably want to. You can do it [at this link](https://mailchi.mp/f78e9b44f28d/torahandtech)

* * *
Does press releases improve SEO?
Tags: showdev
Published: 2019-12-27 00:10:39

Hello, I am launching several products and I am trying to improve SEO. Is publishing press releases still effective? It looks like I am losing money doing that without getting any return.

I posted for many apps I created, and doesn't seem to have much effect yet, It might take some time. Does anybody know if those make difference for SEO?

Photo Vault https://www.marketwatch.com/press-release/online-alternative-to-google-photo-launches-2019-12-24

Moodify https://www.marketwatch.com/press-release/moods-and-more-new-web-app-helps-users-to-track-moods-and-more-2019-12-24

pDrive https://www.marketwatch.com/press-release/pdrive-offers-powerful-document-storage-alternative-to-google-drive-2019-12-25

pBookmarks
https://www.marketwatch.com/press-release/protect-your-online-security-in-2020-with-all-in-one-bookmark-manager-from-pbookmarks-2019-12-25

Bitcoin4Photos https://www.marketwatch.com/press-release/bitcoin4photos-fairly-compensates-artists-for-their-work-with-bitcoin-2019-12-26

Secure Calendar https://www.marketwatch.com/press-release/secure-calendar-launches-free-encrypted-calendar-app-2019-12-26

MyPodium https://www.marketwatch.com/press-release/new-audio-only-share-platform-allows-users-to-post-messages-for-boos-and-cheers-2019-12-26

pNotes https://www.marketwatch.com/press-release/pstack-launches-pnotes-a-free-open-source-and-end-to-end-encrypted-note-taking-app-2019-12-25

SatsHI https://www.marketwatch.com/press-release/zero-fee-bitcoin-based-streaming-platform-2019-12-26

BitPatron https://www.marketwatch.com/press-release/bitpatron-announces-launch-offers-censorship-free-alternative-to-patreon-2019-12-26

pForms https://www.marketwatch.com/press-release/keep-surveys-anonymous-with-pforms-2019-12-26
Azure Policy - Enforce location for CosmosDB
Tags: azure, cosmosdb, security
Published: 2020-02-25 14:51:57

---
title: Azure Policy - Enforce location for CosmosDB
published: true
date: 2019-12-27 00:00:00 UTC
tags: azure, cosmosdb, security
canonical_url: 
---

Now, it’s very easy on Azure to limit allowed locations for your services. Azure has a built in Azure Policy for this use case.

Reminder, the policy to limit allowed location of your ressources is :

```
"if": {
    "allOf": [
        {
            "field": "location",
            "notIn": "[parameters('listOfAllowedLocations')]"
        },
        {
            "field": "location",
            "notEquals": "global"
        }
    ]
},
"then": {
    "effect": "deny"
}  

```

You must add location of your choice. Don’t forget to add **global** location if you want use not regional services like DNS Zone.

Now, on CosmosDB, with this policy if you have selected only _North Europe_ and _West Europe_ as allowed locations, you can create your Cosmos DB only on this two locations.

However, Cosmos DB have a feature to create a replica on an another region like _France Central_. Even if you have the policy, you can create the replica..

If you want deny creation of your replicas, you must create a custom policy with this defintion :

```
{
  "mode": "All",
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.DocumentDB/databaseAccounts"
        },
        {
          "not": {
            "field": "Microsoft.DocumentDB/databaseAccounts/Locations[*].locationName",
            "in": "[parameters('allowedLocations')]"
          }
        }
      ]
    },
    "then": {
      "effect": "deny"
    }
  },
  "parameters": {
    "allowedLocations": {
      "type": "Array",
      "metadata": {
        "displayName": "Allowed locations",
        "description": "The list of allowed locations for resources."
      }
    }
  }
}

```

For your parameters, it’s not possible to use the strong type, we must use a list and use this parameter : _westeurope;northeurope;West Europe;North Europe_
Browse and open VSCode projects using Alfred
Tags: productivity, alfred, macos, vscode
Published: 2020-11-17 14:54:39

---
title: Browse and open VSCode projects using Alfred
published: true
date: 2019-12-27 00:00:00 UTC
tags: #productivity #alfred #macos #vscode
canonical_url: https://mmazzarolo.com/blog/2019-12-27-open-vscode-projects-with-alfred/
---

Here’s an Alfred workflow that you can use to browse and open VSCode projects (or any other IDE projects).  
It returns a list of projects available from a list of paths that you can specify in its configuration.

![screenshot](https://mmazzarolo.com/static/f9834eef1c2cbcf88568a70fca8dbf31/fcda8/screenshot.png "screenshot")

Since the code required to run it is minimal, I’m not sharing the compiled workflow, but you can build it this way:

### 1. Create a “Script Filter” input:

![script filter](https://mmazzarolo.com/static/d2f5bfb8a55ec749dbd3026188f0bfe7/fcda8/script-filter.png "script filter")

```bash
python -c '
import os, json
paths = [
	"/Users/matteomazzarolo/workspace-personal"
]
output = { "items": [] }
for path in paths:
  file_name_list = os.listdir(path)
  for file_name in file_name_list:
    file_full_path = path + "/" + file_name
    if (os.path.isdir(file_full_path)):
      output["items"].append({ "title": file_name, "subtitle": file_full_path, "arg": file_full_path })
print json.dumps(output)
'
```

The `paths` variable is a list of paths where you have your projects.

### 2. Create a “Run Script” action:

![run script](https://mmazzarolo.com/static/917e9669e76309360c7c2d748c4eac61/fcda8/run-script.png "run script")

```bash
path=$1
# Change this to whatever IDE you want to use
open -a "Visual Studio Code" $path
```

![flow](https://mmazzarolo.com/static/01bbd2400c90ffe544bc9d45490ab530/fcda8/flow.png "flow")

Et voilà, you can now use Alfred to browse and open your VSCode projects.

> Yeah… this workflow can be optimized in several ways (e.g.: using env vars instead of hardcoded paths), but it is working well enough for my use case.
Supporting multiple languages in a PWA built with React & TypeScript
Tags: react, typescript, testing
Published: 2019-12-26 23:09:45

I wrote this in my spare time last month. Enjoy. Feedback is welcome.

https://medium.com/@Leejjon_net/supporting-multiple-languages-in-a-pwa-built-with-react-typescript-part-one-8ea8d9f309db

PS: I'm new on dev.to If I get more responses here then on medium then I might consider posting future articles/tutorials on dev.to.
LinusBorg's (nor Other Expert's) Advice Not to be Followed Blindly
Tags: vue
Published: 2019-12-26 23:04:34

---
title: LinusBorg's (nor Other Expert's) Advice Not to be Followed Blindly
published: true
description: 
tags: Vue
---

I started working with Vue.js in 2017, and based on the profile I used at the time I see I posted thrice during my first 2 months.  And LinusBorg (https://forum.vuejs.org/u/linusborg/summary), a core Vue.js team member, responded every time.

Ironically though, I never gleaned anything Vue-specific from his responses to apply to my problems, but rather, unknown to him, he turned out to be my "rubber duck" (https://en.wikipedia.org/wiki/Rubber_duck_debugging).  He still helped me, it's just that in the end my issues never really were Vue-specific.

I was new to Vue at the time and other members already on the team when I joined had a bit of a head-start on me.  Those other team members conveyed that it was best practice to remove event listeners in the beforeDestroy or destroyed life-cycle hooks, so we adopted that technique.

Months later though when I was mired in defect-remediation 95% of the time due to a business decision to change the back-end but shorten the deadline, one defect kept me busy for an entire day give or take, until I traced it back to event listeners being removed.  The issue was that we had multiple components of a particular type on the page, and they could be added and removed, but when any single one of them got removed, the event listeners were removed for all of them :(

Within the last week while googling I found the following post of LinusBorg's on the Vue forum (https://forum.vuejs.org/t/adding-eventlistener-on-mounted/3337/3) wherein he stated, in 2016, that "you should simply use the destroyed() hook to remove the listener when the component is destroyed".  Which made me wonder if my team members had possibly seen this?

So be careful about removing those event listeners in your beforeDestroy/destroyed hooks.  And also when following expert advice, do so with a critical eye.
Best new way to learn music theory
Tags: showdev, music, javascript, react
Published: 2019-12-26 23:04:16

---
title: Best new way to learn music theory
published: true
description:
tags: #showdev, #music, #javascript, #react
cover_image: https://thepracticaldev.s3.amazonaws.com/i/6utet8yuvfpdy01wy2u6.png
---

Hi everybody Shayan here!

As a self taught musician and guitarist I've always struggled with music theory. This has been due to the lack of true user friendly resources (the amount of nights I've spent down youtube/wikipedia rabbit holes...)

In the last couple of months I've set out to fix this gap for myself and everyone.

I've been developing Solfej, an iOS/Android app (React + React Ionic/Capacitor) to help self taught musicians/guitarists like myself learn music theory.

Solfej is now accepting early access users.

I've been so lucky to be able to combine all three of my main passions (music, engineering, design) into one product. 

That being said I'm so excited to share this with the community. Check it out and let me know what you think! 

https://www.solfej.io/
9 Reasons to Use Kotlin Over Java for Android Development
Tags: android, kotlin, java
Published: 2019-12-26 22:51:29

It's a big decision to make by moving from Java to Kotlin as your go-to language for your Android-based projects.

The biggest question now is " Why would you even consider trying Kotlin in your future mobile app projects? "

Here are the nine strongest reasons why, as an Android developer, you should start using a kotlin programming language to build your next Android project:


##**1: Kotlin the future of Android development**

Kotlin is all set for a bright future in the Android app development eco-system. The lower cost of development and maintenance of Kotlin projects is a big plus for any business. It has a plethora of great language features and offers brevity that ensures higher quality with faster turn-around time.
Kotlin is the number one language to build an Android native app.

##**2:  It's Completely Interoperable With Java**

Kotlin is 100% interoperable with java means whenever two java and kotlin files exist together they can share data with each other.

While designing interoperability in kotlin, JetBrains makes major emphasis on Kotlin’s interaction with the existing Java code. The team makes sure that kotlin can easily and completely interact with the existing Java code. So that it can become easy for Java developers to migrate their Java project to Kotlin. There is also an automatic java-to-Kotlin converter in major IDEs for simplifies migration from Java to Kotlin.

##**3: It's More Concise Than Java**

 It means fewer opportunities for errors. Adopting Kotlin does not cost anything. Kotlin is compatible with all Java libraries and frameworks, the JVM (Java Virtual Machine) and can be integrated with Gradle or Maven build systems.
Yes, Kotlin makes programming easier and Android apps better. Kotlin is a modern programming language. It was created by JetBrains - a company that built the best Java IDE ever. They created Kotlin to address the weaknesses of existing languages.

##**4: It Has Null in Its Type System**

Nullability issues have been one of Java's well-known sore points. Since it's a common thing in Android for the absence of certain values to be represented as “null,” Kotlin comes to address these issues by placing null right in its type system.

##**5: Kotlin has a strong community**

JetBrains is constantly improving the language. It's committed to the project, has a large and highly competent team working on it, has a stable business model and is even converting parts of their own flagship product to use it.

##**6: its easier to write than Java**

If you want to facilitate the product maintenance or streamline custom Android app development, you can assign two or three engineers to move the project to Kotlin starting from a small part of the codebase.


##**7: jetpack compose is built upon kotlin**

Jetpack Compose simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.
it's 100% Kotlin.
Day 59 : Happy Hip Hop Holidays
Tags: hiphop, code, coding, lifelongdev
Published: 2019-12-26 22:49:23

_liner notes_:
- Professional : Pretty quiet day back at work. ahah A lot of folks have taken off till the new year. Basically just did research on a report I'm writing and also working on a talk for the new year.

- Personal : Happy Holidays! Totally forgot to say that in the last blog post. haha Hope it is going great for everyone. Had a pretty good one. I rested a little. Got stuff ready to move. Got some more stuff in for the van. Got a Nintendo Switch. As far as coding, I got the Google Cloud Speech-to-Text API working with an audio file. That took a minute because there were information I needed not in the quickstart I was following but on other document pages. Oh yeah, I got Visual Studio Code and Docker working together. I spun up a Node Container and did some programming. Also added a Dockerfile to an existing project and built it from there. Looking forward to playing with it more. Ended my night watching 'Beat Street'.

![Dirt road with a wooden fence and trees on both sides covering the road in Kansas City, Missouri](https://thepracticaldev.s3.amazonaws.com/i/grrhkkfb7sbg3yvtbioq.png)

So I got the Google Cloud Speech-to-Text API working, but I also got the Chrome browser Speech Recognition working the way I need, so I'll go with that since I won't need to set up a Node server. Also may play the Nintendo Switch a friend. I tried to play Fortnite, but I couldn't get connected to a match. Maybe my internet isn't good enough. Back to working on this side project.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube 2P5vCC9LYrk %}
My Side Projects
Tags: showdev
Published: 2019-12-26 22:32:51

I am creating several projects on top of Blockstack. Most of them are serverless and I will opensource all of them by next month. Would love to hear suggestions on how I can improve the reach of our apps. The goal is to improve SEO and get traffic from there, does this scale? Is it possible for a single studio launch several apps that become popular only relying on search engines?

Stackfolio - An encrypted crypto portfolio tracker
https://stackfolio.co

Memocards - Create & Study Flashcards Online
https://memocards.net

minihabits is a private habit tracker that helps you build good habits and quit bad habits.
https://minihabits.co

PDFSTACK is an easy-to-use PDF utility that is designed to split and merge PDF documents.
https://pdfstack.online/

pDrive is an encrypted file storage
http://pdrive.co/

Bitcoin4Photos is a marketplace to buy and sell stock photos for bitcoin
https://bitcoin4photos.net/

pForms is a simple yet powerful form builder
https://pforms.net/d

dBlog is a decentralized blogging platform
http://dblog.live/

Secure Calendar is a private calendar tool
https://securecalendar.online/

BitPatron is a decentralized, censorship-free Patreon alternative
https://bitpatron.co/

MyPodium is a fun audio only social network
https://mypodium.net/

Photo Vault is a free encrypted photo storage solution
http://photovault.online/

Any feedback would be appreciated.
arr.indexOf(item)
Published: 2019-12-26 22:16:26

Hey,
<p>
  As a codewars beta member I just completed training on the "Find the unique number" kata. <a href="www.codewars.com/r/VHz6ew">Take the initiation</a> to join me and start training too!
</p>
<p>
  If you are a member already <a href="http://www.codewars.com/kata/585d7d5adb20cf33cb000235/train/typescript">click here</a> to train on "Find the unique number".
</p>
 arr.indexOf(el) == arr.lastIndexOf(el)