teleren/devto huggingface dataset:
Anonymous Class
Tags: dlang, javascript, go, csharp
Published: 2020-02-01 05:56:51

An anonymous class is a way to provide a structured type which has no name making it optimal for single use, similar to delegates/lambda. 

I have been making use of this in C# to build data I serialize to Json. 

```dlang
// D
auto air = new class {
    auto thin = "I am real.";
};

pragma(msg, typeof(air));
// __anonclass1
```
D shows us the premise, we can assign an instance to a variable and the compiler builds an internal reference to the class. 

```csharp
// C#
var air = new {
    thin = "I am real"
};

Console.WriteLine(air.GetType());
// <>__AnonType0`1[System.String]
```
C# drops the need to specify class and field type but functions basically the same. It does print additional info about the field types. 

```golang
// Go
import "reflect"
air := struct {
	thin 	string
}{
	"I am real.",
}

fmt.Println(reflect.TypeOf(air))
// struct { thin string }
```
Go does not have classes but structures will serve the same purpose. In this case a field type is specified like D and its value is passed through constructor. The type print out looks just like the declaration. 

D has struct but they cannot be created anonymously. This is likely because D added anonymous class to make porting Java code easier (DWT is pretty cool).

```javascript
// Javascript 
const air = {
    thin: 'I am real.',
};
console.log(typeof air);
// object
```

With Javascript I did not use an anonymous class because I looked it up and found [it is not a good idea?](https://stackoverflow.com/questions/38739499/anonymous-class-instance-is-it-a-bad-idea). I wasn't sure what I would find for a dynamic language.

Lua will get an honorable mention. It does not have classes. Meta tables allow for some interesting things, but like Javascript anonymous is basically default. 

# Additional Thoughts 

In D if we repeat the same anonymous class structure the internal type is not reused. 

```dlang
// D
auto air2 = new class {
    auto thin = "I am real.";
};

pragma(msg, typeof(air3));
// __anonclass2
```

If we use meta programing you can create a new object of the same type. 

```dlang
// D
auto air3 = new typeof(air);
air3.thin = "still exist";

pragma(msg, typeof(air3));
// __anonclass1
```
Lesson 13 Discussion
Published: 2020-02-01 05:20:08

A contains function will evaluate the whole string, while the hasPrefix function only evaluates the first word of the string and the hasSuffix focuses on the last word of the string. 



when you type the user in lowercase of uppercase you find that the bool is case sensitive, to fix this you must create a method(?) that will allow the string to be evaluated in all lowercase or all uppercase 

EX: let lowerCaseQuestion= question.lowerCased

let upperCaseQuestion=question.upperCased
How to develop the habit of coding
Tags: coding, programming, python, motivation
Published: 2020-02-01 03:53:12

*A habit is a path, formed in your brain.*

The more you follow a habit, the more established that path will become.

So how do you create a new habit ?
Develop a habit loop
According to anonymous in his/her book "The power of habit", all habits are a behavioral loop made up of - **CUE --> ROUTINE --> REWARD**

The **cue** is something that triggers you to follow the **routine** , in order to experience the **reward** at the end.

Every habits follows this loop.To create a new habit, try to come up with a loop that you can start trying to follow.

Example habit loop of coding:
Lets say you want to start coding as part of your daily routine. Here's how that could look:

**Cue** : First thing in the morning after brushing your teeth.

**Routine** : You will go to your computer and work on coding for half an hour or so.

**Reward** : You will feel more productive and happy that you are working towards your goals !

**REMEMBER: IT'S NOT EASY**
Starting a new habit is difficult, because the routine hasn't been established yet. At this point, it takes a lot of willpower to continue following the routine.
But the more you keep at it, the more ingrained it becomes. Once a habit has been established, it will actually seem easier to follow the habit than to break up your routine !

**GOOD HABITS CAN LEAD TO ANOTHER GOOD HABITS**
Another point from the book is if you set one good habit, it can become "keystone" habit and lead to another good habits.
For example, if you start exercising every day, you could more easily develop other good life habits like eating more healthily or being more mindful of your spending habits.

Let me know in comments⬇️👇 which good habits you want to form, or even which bad habits you want to break !
Different Types of Functions
Tags: swift, functions, hasprefix, hassuffix
Published: 2020-02-01 03:48:38

Contain functions are functions that are made from scratch, per se. These are function in which every component in the function is defined to achieve a desired outcome. The hasPrefix and hasSuffix functions are built in functions for a certain type, which just so happens to be type String. They are functions that do not have to be created from scratch every time, they were pre built into the type.

A problem that is sure to be encountered if the user inputs uppercase or lowercase is when a function is tied to certain case. The function might be able to take any input in that starts with a certain value, but if it is tied to a certain case it will not return the desired outcome. 
Fear not, there is a fix for this. Instead of writing a function for each possible case, one might change the case of the text before trying to match it using the lowercased method. 


<code = let question = “WHERE ARE YOU?”
		let lowerQuestion = question.lowercased()
			lowerQuestion.hasPrefix(“where”)>
Como importar (muitos) módulos no Azure Automation | Linha de Comando| pt-br
Tags: azure, devops, automation, powershell
Published: 2020-02-01 03:40:14

#Como importar módulos locais no seu serviço de automação por linha de comando. 

E ae, pessoal, beleza? Trazendo uma dica bem legal para quem utiliza o serviço de automação disponível no Azure o Azure Automation. O processo de importação via interface gráfica é intuitiva e ajuda bastante quando não temos muita intimidade com linha de comando, mas se torna um tanto repetitivo se você precisa buscar vários módulos e realizar a importação. 

Geralmente, quando estamos desenvolvendo alguma automação, realizamos testes locais. E, muitas vezes, utilizamos módulos para nos auxiliar nessas tarefas. Se por algum motivo você tiver inúmeros módulos, como você coloca essa lista na sua conta de automação? vou demonstrar como executar o processo no script abaixo:
{% gist https://gist.github.com/EwertonJordao/16efc9e876bf2e26ec50095d66c66145 %}

![Criando os Jobs no Azure utilizando conexão criada no terminal do Visual Studio Code. Connect-AzAccount ](https://thepracticaldev.s3.amazonaws.com/i/lq4q2gz3305thh1b0pld.png) 

![Visualização dos jobs de importação dos módulos no portal do Azure com status de importando](https://thepracticaldev.s3.amazonaws.com/i/hkqzhmc1bofc1ho711tg.png)

![Visualização dos jobs de importação dos módulos no portal do Azure com status de disponível a partir deste momento podemos utilizar os módulos nos scripts](https://thepracticaldev.s3.amazonaws.com/i/w59mttd3065hrg2ffhsg.png)

Após todos os módulos finalizarem a importação podemos utiliza-los em nosso runbooks PowerShell, sem nenhum problema de falhar por falta de alguma referencia. 

É isso pessoal. Não se esqueça, PWSH + Azure Automation é vida 😍.
How to import (many) modules into Azure Automation | Command Line | en-us
Tags: azure, devops, automation, powershell
Published: 2020-02-01 03:39:20

#How to import local modules into your automation service by command line.

Hy everyone, how are u? Bringing a cool tip for those who use the automation service available in Azure (Azure Automation). The import process via the graphical interface is intuitive and helps a lot when there is not much intimacy with the command line, but it becomes somewhat repetitive if you need to search for various modules and perform an import.

Sometimes, when we are developing some automation, we carry out local tests. And, often, it uses modules to help the tasks. If for some reason you have module numbers, how do you put that list in your automation account? I will demonstrate how to execute the process in the script below:

{% gist https://gist.github.com/EwertonJordao/16efc9e876bf2e26ec50095d66c66145 %}

⚠ When do you use the first script you can receive an error because the import-module on Azure Automation has a limited number of jobs simultaneously.

![Creating Jobs in Azure using a connection created in the Visual Studio Code terminal. Connect-AzAccount](https://thepracticaldev.s3.amazonaws.com/i/lq4q2gz3305thh1b0pld.png) 

![Visualization of module import jobs in the Azure portal with import status](https://thepracticaldev.s3.amazonaws.com/i/hkqzhmc1bofc1ho711tg.png)

![Visualization of the module import jobs in the Azure portal with the status of available from this moment we can use the modules in the scripts](https://thepracticaldev.s3.amazonaws.com/i/w59mttd3065hrg2ffhsg.png)


After all modules are finished importing, we can use them in our PowerShell runbooks, without any problem of failing due to lack of any reference.

That's it, folks. Don't forget, PWSH + Azure Automation is life
Integer.parseInt() will only work with Strings that are...well...ints.
Tags: java
Published: 2020-02-01 03:38:10

String numString = "8.35";
Integer numInt = Integer.parseInt(numString);

THIS WILL NOT WORK!!!

I made the (wrong) assumption that parseInt will just convert 8.35 to an Integer value of 8 and then do the parsing. NO! WRONG! It will throw an exception. I forgot which exactly. I will add it in later when I check. You can update blogs on dev.to, right? I hope so. Anyways, that's what I have learned. So I thought I would write this post to share my knowledge.
Should Tech Companies Use the Universal Declaration of Human Rights as a Guide for their Privacy and Content Policies?
Tags: discuss, privacy, watercooler, policy
Published: 2020-02-01 03:37:54

A few weeks ago I heard David Kaye, the UN Special Rapporteur on the Promotion and Protection of the Right to Freedom of Opinion and Expression, on [The Lawfare Podcast](https://www.lawfareblog.com/lawfare-podcast-david-kaye-policing-speech-online). Basically, he proposed that tech companies, especially social media companies, look to international human rights law (and in particular the [Universal Declaration of Human Rights](https://www.un.org/en/universal-declaration-human-rights/index.html)) to guide their efforts at moderating content. This approach leans towards allowing more freedom of expression, not less, but he suggested it would provide some guidelines for what content can and should be policed (and what the goals of such policing should be). Interestingly, he also seemed to suggest that this approach would give companies a foundation for determining which of the many national legal regimes they are going to adhere to and which they might decide to resist or ignore.

What do you think of this idea?

Out of curiosity, I re-read the [Universal Declaration of Human Rights](https://www.un.org/en/universal-declaration-human-rights/index.html) thinking specifically from the perspective of how its Articles might apply to a tech company or platform. Here’s what I came up with as a framework, I’d love to hear other’s thoughts: https://github.com/apmarshall/human-rights-platform
Seek and Destroy
Tags: replit, node
Published: 2020-02-01 03:28:16

---
title: Seek and Destroy
published: true
tags: replit, nodejs
---

function destroyer(arr) {
 // Remove all the values
var args =[]; var p =[]; var odd=[];
for(let i=0; i<arguments.length; i++){
  args.push(arguments[i])
}
  var p =  arr.filter(function(item){
    return args.indexOf(item)===-1;
  })
  console.log(p)
  return p
 
  
}
destroyer([1,2, 3, 1,2, 3], 2, 3);

/*destroyer([1, 2, 3, 1, 2, 3], 2, 3) should return [1, 1].

destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) should return [1, 5, 1].

destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return [1].

destroyer([2, 3, 2, 3], 2, 3) should return [].

destroyer(["tree", "hamburger", 53], "tree", 53) should return ["hamburger"].

destroyer(["possum", "trollo", 12, "safari", "hotdog", 92, 65, "grandma", "bugati", "trojan", "yacht"], "yacht", "possum", "trollo", "safari", "hotdog", "grandma", "bugati", "trojan") should return [12,92,65].*/

{% replit @oscarhernandez6/Seek-and-Destroy-free-codecamp-practice %}?signin=true
Remove crapware unused magento 2 extensions
Tags: magento2, webdev, hack
Published: 2020-02-01 03:20:10

Yeah magento should focus in main core modules good for business and avoid bundle crap things

From my perspective i don't need unused modules
Here is the guide to allow you remove module from your magento 2 project based on composer


The Approach
It’s preferred to remove modules via composer. Add a block as follows to your composer.json file:

<strong>Update 2.3.4+</strong>
<div class="code-wrap">
<pre class="highlight xml"><code>
"replace": {
        "magento/module-authorizenet": "*",
        "magento/module-google-adwords": "*",
        "magento/module-send-friend": "*",
        "magento/module-signifyd": "*",
        "magento/module-bundle-graph-ql": "*",
        "magento/module-catalog-graph-ql": "*",
        "magento/module-catalog-inventory-graph-ql": "*",
        "magento/module-catalog-url-rewrite-graph-ql": "*",
        "magento/module-cms-graph-ql": "*",
        "magento/module-cms-url-rewrite-graph-ql": "*",
        "magento/module-inventory-graph-ql": "*",
        "magento/module-configurable-product-graph-ql": "*",
        "magento/module-customer-graph-ql": "*",
        "magento/module-downloadable-graph-ql": "*",
        "magento/module-eav-graph-ql": "*",
        "magento/module-graph-ql": "*",
        "magento/module-grouped-product-graph-ql": "*",
        "magento/module-quote-graph-ql": "*",
        "magento/module-store-graph-ql": "*",
        "magento/module-swatches-graph-ql": "*",
        "magento/module-tax-graph-ql": "*",
        "magento/module-url-rewrite-graph-ql": "*",
        "magento/module-weee-graph-ql": "*",
        "temando/module-shipping-m2": "*",
        "dotmailer/dotmailer-magento2-extension": "*",
        "klarna/module-kp": "*",
        "klarna/module-ordermanagement": "*",
        "klarna/module-core": "*",
        "amzn/amazon-pay-sdk-php": "*",
        "amzn/amazon-pay-and-login-with-amazon-core-module": "*",
        "amzn/login-with-amazon-module": "*",
        "amzn/amazon-pay-module": "*",
        "vertex/module-tax": "*",
        "vertex/sdk": "*",
        "yotpo/magento2-module-yotpo-reviews": "*"
    },
</code></pre>
</div>

<strong>Update 2.2.0+</strong>
Updating...

After modify composer.json
Run composer update

Run setup:upgrade

then run some basic magento commands like compilation or flush caches
Simple (OOP) PHP Calculator
Tags: calculator, adeleyeayodeji, phpoop, codedeyo
Published: 2020-10-03 14:15:06

---
title: Simple (OOP) PHP Calculator
published: true
date: 2020-02-01 02:12:57 UTC
tags: calculator,adeleyeayodeji,phpoop,codedeyo
canonical_url: https://medium.com/@adeleyeayodeji/simple-oop-php-calculator-4b9c55a7c77d
---

![Object-Oriented Programming (OOP) in PHP adeleyeyayodeji.com](https://cdn-images-1.medium.com/max/810/1*eH-f-NRNTjsXjSywazrDtw.png)

Object-Oriented Programming (OOP) in PHP

Object-Oriented Programming has always been fun with the right basic tools.

Get started with OOP using my basic widget

Source Code: [https://github.com/adeleyeayodeji/Simple-OOP-PHP-Calculator](https://github.com/adeleyeayodeji/Simple-OOP-PHP-Calculator?fbclid=IwAR1mw5dQOqxuWVZte7auxkm9aiB0k4QY5aHegvWFK9ddIPCbkzmS9pQe_II)

Happy Coding 😎🤩
On usefulness over accuracy in dev – the broken clock conundrum.
Tags: webdev, discuss, productivity, psychology
Published: 2020-02-02 13:44:53

---
title: On usefulness over accuracy in dev – the broken clock conundrum.
published: true
date: 2020-02-01 01:58:25 UTC
tags: webdev, discuss, productivity, psychology
canonical_url: https://leogopal.com/technology-and-computing/on-usefulness-over-accuracy-in-dev-the-broken-clock-conundrum/
---

Here is a thought experiment. Imagine two clocks; both analogue.

The first clock is broken. But in terms of accuracy its exactly correct twice a day.

The second clock is a minute off; technically, it's the most useful one; but it's never exactly correct. But it's the one thats useful.

I see coding and the technologies we use to be of a similar fashion - and that too the religiosity of "standards" and "best practices". 

I think its far better to be more frequently useful, even if we may not yet be doing what is seen as the correct or right way... 

Be useful is more important than being right and problematic.

Get it done, then on to the next and do that better.

## What's your opinion?

The post [On usefulness over accuracy in dev – the broken clock conundrum.](https://leogopal.com/technology-and-computing/on-usefulness-over-accuracy-in-dev-the-broken-clock-conundrum/) appeared first on [Leo Gopal](https://leogopal.com).
On usefulness over accuracy in dev - the broken clock conundrum.
Tags: webdev, codequality, discuss, productivity
Published: 2020-02-01 01:30:45

Here is a thought experiment. Imagine two clocks; both analogue.

The first clock is broken. But in terms of accuracy its exactly correct twice a day.

The second clock is a minute off; technically, it's the most useful one; but it's never exactly correct. But it's the one thats useful.

I see coding and the technologies we use to be of a similar fashion - and that too the religiosity of "standards" and "best practices". 

I think its far better to be more frequently useful, even if we may not yet be doing what is seen as the correct or right way... 

Be useful is more important than being right and problematic.

Get it done, then on to the next and do that better.
Codelens in Visual Studio Community Edition
Tags: visualstudio
Published: 2020-02-01 01:08:19

---
title: Codelens in Visual Studio Community Edition
published: true
date: 2020-02-01 00:19:25 UTC
tags: Visual Studio
canonical_url: https://www.thatamazingprogrammer.com/blog/codelens-in-visual-studio-community-edition/
cover_image: https://res.cloudinary.com/programazing/image/upload/v1580516307/blogposts/Technology%20Banners/visual-studio-logo.jpg
---

One of my favorite things in Visual Studio has always been CodeLens. It's this beautiful little feature that tells you what's referencing a piece of code and where it is as well as if it has any associated tests.

From what I remember it was only available for the paid tiers of Visual Studio for the longest time. A lot of developers complained that CodeLens was missing from Express, which was an even more limited edition of Visual Studio before Community became a thing.

I hadn't thought about CodeLens outside of a work environment because I just never needed it on the smaller side-projects I made at home. As I've been making larger and larger projects for myself and the community I started to miss having the ability to quickly find where some of my functions or models were being referenced or if they had test coverage.

I mentioned that to someone tonight and they told me that we've had CodeLens in the Community since 2017.

__2017!__

After looking around the settings, sure enough, I found that it came with CodeLens installed but turned off by default.

All you have to do to activate it is:

* Click Tools > Options
* Toggle open Text Editor
* Toggle open All Languages
* Click CodeLens
* Click Enable CodeLens
* Then click OK

Ta-da! 🎉

Now you have CodeLens and can start getting better insights into your project like this:

![Number of references a model named Settings Model has](https://res.cloudinary.com/programazing/image/upload/v1580517112/blogposts/2020/Codelens%20in%20Visual%20Studio%20Community%20Edition/references.png)

![Number of tests a method named Set Settings has](https://res.cloudinary.com/programazing/image/upload/v1580517112/blogposts/2020/Codelens%20in%20Visual%20Studio%20Community%20Edition/test.png)
How to  extract all the styles from an element
Tags: todayilearned, css, productivity
Published: 2020-01-31 23:55:45

###TIL

Today I learned something really cool. You can easily copy the CSS of an element from dev tools.
Ever browsed a website and found a nice UI element and wanted to see/copy the CSS of it? Normally you would open dev tools and inspect that element to see the CSS and try to get all the style set some of them are set by class, some are inherited from the parent, you might have also inline styles. 



###Example

Let's say for example on a blog page I want to see all the styles of the read more link on my blog page.

![blog page](https://dev-to-uploads.s3.amazonaws.com/i/2es8pssd4dzaoi8rf2ib.jpg)

To get all the CSS for that link you can right-click to inspect it and then on the elements tab right-click on it again and click `Copy->Copy styles` 

![css](https://dev-to-uploads.s3.amazonaws.com/i/ud88jz9thnsm0zurlner.jpg)

Did you know this small trick?
📸✨ Polaroid Camera In CSS
Tags: codepen, css, html
Published: 2020-01-31 23:36:09

I love cameras and I love CSS, so I decided to recreate [this Polaroid camera](https://digital-foto.no/kamera/polaroid-kameraet-vender-tilbake) in HTML and CSS. I only used divs and gradients, no images. 


{% codepen https://codepen.io/fossheim/pen/xxboBzO %}

My plan is to write a tutorial about it the upcoming week, so stay tuned for that 🤗

Code also available on [Glitch (@fossheim)](https://glitch.com/~polaroid-css) and [GitHub (sarahfossheim)](https://github.com/sarahfossheim/polaroid-css).

**I wrote a [high-level tutorial](https://fossheim.io/writing/posts/css-polaroid-camera/) on my blog.** Also available here on [dev](https://dev.to/fossheim/how-i-recreated-a-polaroid-camera-with-css-gradients-only-4la5).
Loading web-apps faster
Tags: javascript, angular, webdev, node
Published: 2020-01-31 23:26:44

Originally posted: [Blog](https://medium.com/@ppm1988/loading-webpages-faster-6950a65c6d90)

### Story telling

The homepage is mostly about displaying static data / HTML and yet most (if not all) of the framework based modern websites exhaustively load all their packages, exposing all their “minified” code.

Let’s face it — an user who doesn’t want to get into the web application is still being charged some data transfer and page-load time unnecessarily.

There are few good examples where the web applications doesn’t even need a homepage and straight away they render the Auth screen. For example Facebook, Instagram, Twitter.

All that was needed was to display the SignIn / SignUp forms without any introduction of what the product / company is all about.

### Stats

_Page Load (with ~ 50-100 Mbps broadband)_

Facebook: ~3 seconds, ~8MB
Twitter: ~2 seconds, ~ 2.6 MB
Instagram: ~3 seconds, ~ 2.6 MB

### Our approach

We will render plain HTML along with little bit of JS and CSS on the first load. Since the page-size will be smaller, the data transfer will be quicker so the page loads faster.

As we don’t need Angular for the Auth process, we will be loading them at the later stage when we really need them to handle the dynamic data and to handle the Single Page Application stuffs.

> This would save considerable amount of data-usage

[Architecture](https://github.com/ppm1988/cdn/blob/master/base-project.png) 
###### (Open in new tab)

Live demo: [Node rendered Angular](http://ec2-52-15-138-151.us-east-2.compute.amazonaws.com:4200/)

**Note**: The Live demo is not under CDN so comparing it with Facebook or any other established websites would be pointless. I will be hosting a comparative website on GitHub or EC2 sometime soon, so until then kindly bear this note.

### Pros

- Faster page load
- Less data consumption (Saves the Planet)
- [That’s all I can think of with my limited knowledge]

### Cons

- [I couldn’t think of anything at this moment with my limited knowledge]

Kindly share your feedback so that I can improve this article. _Adios_.