teleren/devto huggingface dataset:
Coming from Javascript, Arrays in Java are confusing?
Published: 2019-08-23 05:35:52

---
title: Coming from Javascript, Arrays in Java are confusing?
published: true
description: 
tag:
---
Coming from Javascript, arrays in Java were confusing to me. Below I would like to discuss how arrays work in Java.

### Array Declaration 
In Java, an array has to declare with a type. Elements in it has to match the array type as well.
```
//integer array example, both declarations will work

int [] myArray; 
int myArray [];

//string array example

String [] strArray;
String strArray [];

```
### Give array a size
The size of an array will not change dynamically in Java, so we have to define a size before using it. ArrayList is a better option when we need a dynamic size for a collection of datas.
```
//using the arrays from the examples above, we can define a size for them

myArray = new int[10];

//we can also perform the declaration and size with one line of code

int [] myArray = new int[10];

```
### Array literal
When we know what elements that an array will have, we can use array literal to declare an array.
```
//the size of the array is determined by the number of elements were defined

int myArray = new int[]{1,2,3,4,5,6,7,8};

//in newer version of Java, we can skip the new int[]

int myArray = {1,2,3,4,5,6,7,8};

```

### My favorite loop to use to get the array elements
```
for(int eachNumber : myArray){

 System.out.println(eachNumber);
}

```
VPC Primer - VPC, VPN, Endpoints, Subnets
Tags: aws, networking, programming, devops
Published: 2019-08-23 05:14:27

---
title: VPC Primer - VPC, VPN, Endpoints, Subnets
published: true
description: What is a VPC, VPN, Endpoints, Subnets
tags: aws, networking, programming, devops
---

## We start with summary

VPC - Your own non real virtual private cloud.
VPN - Your own non real virtual secure network connection between VPC.
Subnets - Internal networks within your VPC.
Endpoints - Connect to externals aws services - external to your VPC.


## VPC - It's all virtual

> Virtual Private Cloud - Your own private cloud

VPC is virtual meaning it's not really a thing - it's virtual. So it's a private cloud but it's not really a private cloud because it's virtual but in your eyes you can think of it as a private cloud.  It's your personal data-center.

## VPN - It's also virtual not real

> Virtual Private Network - Your own secure connection to VPC
This guy is also virtual its not real but you use VPN in order to interconnect VPN.

## You have your actual applications in VPC

> You have your own stuff like your own EBS and instances your actual applications in VPC but s3 or no it's on the outside.

What do you have in VPC you have mainly instances EBS but S3 although you could think it should be in VPC it's actually outside of it, so you can think of having in your VPC your nuts and balls of the servers and not the external services like S3.

## Subnets in VPC

> You can create subnets in VPC after all isn't it your own cloud?
> Private subnets for your internal servers, public subnets for your external servers like web servers.

So as it's your cloud you can just go ahead and create private/public subnets

## Connecting from one VPC to another

> You connect from one VPC to another with VPN.

## Endpoints

> We said that S3 is external to your VPC so how do you connect to it?

You connect to s3 by creating an **endpoint** so an endpoint allows you to connect to other AWS resources external to your cloud external to your private cloud.

## Default VPC

When you create an AWS account you get a default VPC so you already have one. 

## Summary

VPC - Your own non real virtual private cloud.
VPN - Your own non real virtual secure network connection between VPC.
Subnets - Internal networks within your VPC.
Endpoints - Connect to external to your VPC AWS services

[Video](https://www.youtube.com/channel/UC82zocd7ZWMSHe5uuPT4gSw)
使用指定glibc
Tags: glibc
Published: 2019-08-23 04:35:58

---
title: 使用指定glibc
published: true
description: glibc
tags: glibc
---

使用Rust在编译机器上copy过来之后，运行报错: "GLIBC_2.18" not found
![glib 不对](https://thepracticaldev.s3.amazonaws.com/i/maw04ac08t15cwt8kdwv.jpg)

通过 strings /lib64/libc.so.6 | grep GLIBC_ 命令查看发现这台机器上只有2.17，开始本来想升级glibc，但是这个东西确实太底层了，怕影响其他东西，所以决定编译到自定义目录然后指定加载就行。

编译流程很简单 [http://ftp.gnu.org/gnu/glibc](http://ftp.gnu.org/gnu/glibc/) 下载一个需要的版本，我这儿就选了2.18。

解压后新建一个目录glibc-build(因为它不让在源代码目录build)，和一个我们放编译好的glibc目录，然后在build目录里面 ../glibc-xxx/configure --prefix=../glibc/

configure好之后 make  make install

我们编译好的glibc就在glibc这个目录啦，运行是这样

```
RUST_LOG=info ./glibc/lib/ld-linux-x86-64.so.2  --library-path ./glibc/lib:/lib64:/usr/lib64 ./order-server
```
Best way to add line numbers to the large file!!
Tags: learning, tips, data, machinelearning
Published: 2019-08-23 03:49:13

---
title: Best way to add line numbers to the large file!!
published: true
description: 
tags: #learning #tips #data #ML
---

Recently I started working on Machine Learning project. So started working on large uncleaned data files to clean  and learned one of this tip today.

To add line numbers to large file just run below command on the file.

<code>
cat -n  file_name >new_file_name
</code>
Above command will add the line number at the start of each line from file_name separated by tab and store in new_file_name without effecting the content of the file file_name.

If you want to replace tab with any character like comma, pipe(|) etc. Run below command.

<code>
cat -n  file_name | sed 's/\t/\,/g' >new_file_name
</code>
OR
<code>
cat -n  file_name | tr '\\t' ',' >new_file_name
</code>

Some times Mac systems may not identify tab(\t). Press Cntrl + V and press tab to identify tab key in Mac.
Android Q is officially named Android 10
Tags: stuartinhcity, androidq, android10, android
Published: 2019-08-23 01:17:29

Android Q is now simply Android 10
Google ditches dessert-themed Android names in a push for accessibility.
Mariella Moon Mariella Moon, 4h ago
Google has finally revealed Android Q's release name, and it's not Quiche, Quinoa or Quesadilla. In fact, it's not named after any dessert that starts with the letter Q at all -- the tech giant has decided to simply call it Android 10. In a blog post, the company said it's changing the way it names its releases altogether in a push for greater accessibility. "[W]e've heard feedback over the years that the names weren't always understood by everyone in the global community," the company wrote.

Since L and R aren't always distinguishable when spoken in some languages, for instance, it's not immediately obvious for some people that Android Lollipop came after KitKat. The names of some previous Android versions aren't known desserts in certain parts of the world either. In other words, while the names are fun, they don't always resonate with users. The new scheme sounds much less quirky and delicious, but it'll likely serve Google's purpose: come up with more relatable and intuitive names. "[W]e think that at version 10 and 2.5 billion active devices," the blog post reads, "it was time to make this change."
Top  Android 10 features you need to know about:-

1.The iconic back button is going away

2.There's finally a system-wide dark mode!
3.Live Caption transcribes media locally in real-time
4.An improved share menu.
5.Big changes coming to permissions
6.New theming options.
7.Better support for foldable phones.

When will it be released?


On March 13, 2019, Android 10 Beta 1 was launched out in the wild and made available to download on the Pixel, Pixel 2, and Pixel 3 series. Beta 2 was released on April 3, Beta 3 debuted on May 7 during Google I/O, Beta 4 arrived on June 5, Beta 5 hit on July 10, and Beta 6 made an appearance on August 7.

Now, we're just waiting for the final build of Android 10 to be released at some point before Q3 is over.
Set Laravel Mailer with Mailtrap.io and Sendgrid.
Tags: php, laravel, mailtrapio, sendgrid
Published: 2019-08-23 01:02:42

---
title: Set Laravel Mailer with Mailtrap.io and Sendgrid.
published: true
description: Tutorial to set mailtrap and sendgrid to send mails for Laravel.
tags: PHP, Laravel, Mailtrap.io, Sendgrid
cover_image: https://miro.medium.com/max/1000/1*usgKRIjLTVrpcEeGErK4Ng.png
---

#Set email for logs
To add settings for emails Laravel provides an “.env” file, that we need to edit:

```
MAIL_DRIVER=log
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=<mailtrapuser>
MAIL_PASSWORD=<mailtrappassword>
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=admin@yourapp.co
MAIL_FROM_NAME=YourApp
```

To try you can use the forget password link from artisan command "make:auth".

Go to “storage/logs” directory and you will find log file, in very bottom of the file you can see a preview in code of your email.

------

#Set email for Develpment with Mailtrap.io

you only need to add “smtp” as driver, and add your username and password of mailtrap.io you can create a free account, and try again to submit another contact form.

```
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=<mailtrapuser>
MAIL_PASSWORD=<mailtrappassword>
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=admin@yourapp.co
MAIL_FROM_NAME=YourApp
```


If everything is correct you can access to your mailtrap.io inbox and you will see something like:

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/9lls7yabx88sr6xkn5g7.png)

You can now use mailtrap to set all your emails for development.

------


#Set email for Production

First we need to install a package https://github.com/s-ichikawa/laravel-sendgrid-driver to install it you only need the next command

```
$ composer require s-ichikawa/laravel-sendgrid-driver
```

When the package is installed, we need to add the service in “config/service.php” directory.

```
'sendgrid' => [
  'api_key' => env('SENDGRID_API_KEY'),
],
```

Now we need to change the “.env” file again to add the SendGrid Values, you can sign in with a free account in https://app.sendgrid.com and get 100 monthly emails for free or get a payment plan for more.

The username and password to “signin” or “register” are going to be used in “.env” file, and to generate an “apikey” you can go to settings on sidebar and click on “API keys” option, then press the blue button “Create API Key”, you can set any name to your api key, and in “API key permissions” by default is selected “Full access” so create it with “Full access”.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/yo9u7l9yx4hsnjq5fzgu.png)

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/exjnvwjax2gjrwm379ag.png)

```
MAIL_DRIVER=smtp
SENDGRID_API_KEY='apikeyAsString'
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=<sendgridUser>
MAIL_PASSWORD=<sendgridPassword>
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=admin@yourapp.co
MAIL_FROM_NAME=YourApp
```

Now you can manage your different enviornments for development and production remeber sendgrid with free plan only works with 100 mails by month.
Custom Type Definitions for JavaScript dependencies
Tags: tutorial, javascript, typescript, webdev
Published: 2019-08-26 22:12:10

---
title: Custom Type Definitions for JavaScript dependencies
published: true
tags: tutorial, javascript, typescript, web development
canonical_url: https://www.ankursheel.com/blog/custom-type-definitions-for-java-script-dependencies
cover_image: https://thepracticaldev.s3.amazonaws.com/i/lqx137o2yrfi8dbdi33l.jpg
---

If you are importing a javascript dependency into your typescript app, you might run into this error

**_“Could not find a declaration file for module ‘third-party-library-name’. ‘third-party-library-name.js’ has an ‘any’ type. Try npm install @types/third-party-library-name if it exists or add a new declaration (.d.ts) file containing declare module ‘third-party-library-name’;”_**

If you read the error message, you can see that it’s suggesting to check the DefinitelyTyped repository.

If you are lucky you will find it the repository and can install it using _npm_ or _yarn_.

But what if you not so lucky?

## Solution #1

Now, you will only see this error if you have `noImplicitAny: true` in your _tsconfig.json_. So you could get around this error is by setting `noImplicitAny: false`.

But, by doing this you lose type-safety, so let’s rule this out as a viable option.

## Solution #2

Add a local declaration file.

### Steps

So, how exactly do you do that?

1. Create a **_types_** folder.
2. Edit tsconfig.json to use the typeRoots property so that the compiler can find the local declaration files. You will need it to include both your local folder as well as _node\_modules/@types_. You will also want to check the local folder before the _node\_modules_ folder.

```json
"compilerOptions": {
 ...
 "typeRoots": ["./types", "node_modules/@types"]
    }
```

1. Add the property to exclude property in tsconfig so that it does not get compiled.

```json
"exclude": [..., "types"]
```

1. Add a **_third-party-library-name_** folder in the _types_ directory.
2. Add an _index.d.ts_ in that folder.
3. Add your TypeDefinitions. But if like me, you want to prototype things or do not want to write a full custom type, you can declare the module by adding this to the _index.d.ts_ file.

```javascript
declare module 'third-party-library-name';
```

The only caveat is that you don’t get any IntelliSense.

## Conclusion

Hopefully, this post will help you and you won’t have to resort to either removing Typescript from your project or losing type-safety by adding `noImplicitAny: false` in your tsconfig.json.
Using Glass Mapper To Create New Content In Sitecore With Fluent Configuration
Tags: sitecore
Published: 2019-08-22 23:11:48

I found myself asking and answering my own question on StackExchange today (by the way, don't be afraid to do that if you find a good answer, and also be ready for a better answer to possible pop up!):

{% stackexchange 20624 sitecore %}

As an opening summary, my typical setup for using Glass with Sitecore is to use fluent configuration. So if I have a model like this:

```
public interface ITemplate {
  string Field { get; set; }
}
```

Then I would create this mapping entry to link up the POCO to Sitecore:

```
public class TemplateMap : SitecoreGlassMap<ITemplate> {
  public override void Configure() =>
    Map(config => {
      config.Field(f => f.Field).FieldName("Field");
    });
}
```

And then you can retrieve the item with code similar to this (note that `SitecoreService` needs to be replaced with an appropriately arranged call that establishes the service):

```
ITemplate item = SitecoreService.GetItem<ITemplate>(new GetItemByIdOptions(Guid.Parse("{}")));
```

So that's all good. But when you need to add content to Sitecore for any reason, you can't use the interface and instead need a standard class:

```
public class Template : ITemplate {
  public string Field { get; set; }
}
```

Now if you've done the Glass training, you'll see in the section on creating items that they use the attribute mapping. That's easy enough, but how does it work with the fluent configuration? Right now, the map goes to the interface only. So do we have to use attribute mapping, or make a separate map?

Turns out it's pretty easy. All you have to do is change the map to use the concrete class:

```
public class TemplateMap : SitecoreGlassMap<Template> {
  public override void Configure() =>
    Map(config => {
      config.Field(f => f.Field).FieldName("Field");
    });
}
```

Now if you use the `GetItem` call from earlier, it still works. And then if you need to create a new item as a subitem to that, this code will work:

```
ITemplate newItem = new Template {
  Name = "Test Item"
};

using (new SecurityDisabler()) {
  ITemplate createOrg = SitecoreService.CreateItem<ITemplate>(new CreateByModelOptions {
    Model = newItem,
    Parent = item
  });
}
```

So just one extra class and changing the class used in the mapping call, and you're good to go! I'd personally advise only bringing in concrete classes when you have to do these operations, since the interface will work perfectly fine if you're just doing read operations.
Frameworks are good... Everyone should have their own
Tags: kotlin, screwdrivers
Published: 2019-08-22 23:09:16

WARNING: the only Kotlin related thing here is the link at the bottom... However, I hope the story that leads to it would be funny to you.

There are plenty of frameworks out there, specially in the JVM world. Well, not as much as in the JavaScript community (but it is pretty close).

Why people love to write frameworks? they are only tools, it is like wanting to design the perfect screwdriver, right?

Yes I know what you are thinking: "I don't give a damn about the screwdriver, I just want to build things".

And you are right, you can go to the store and pick a screwdriver designed by professionals. You just check what you need and buy one. It is totally cool.

However, what happen when you use screwdrivers for a long time? You have a few of them. Maybe none of them is good enough to use it for everything... Or they are designed for a broad range of needs and you have very particular needs (like those with many attachable heads and none of them work properly).

At this point, you may have realized that screwdriver makers don't care that much about you. They seem more worried in selling you courses about how to use their screwdrivers, or sending you people to use them for you at a convenient rate. Yes... they stopped building screwdrivers, and started building a profitable business. And now, you have to be certified to use their screwdrivers.

So you start to think... Hey, I could make my own screwdriver, maybe it is only good for me, but I'm the one building things here! right? what could go wrong?

So you build "your screwdriver"(tm), it is tailor made for you... It has an odd design, because well, everyone is used to the commercial ones (so they don't understand your genius)... Anyway, you are happy with it and you learnt a lot in the way.

However, that path leads you to stop building things and start designing screwdrivers. And so, the circle is closed. Not really in my case (I don't sell screwdrivers), but you get the idea.

That was my story, with the difference that I developed a programming toolkit instead a screwdriver (I guess you noticed that before, right?).

And that is my journey in the programming tools field: I develop a toolkit for a product which I didn't finish... Well, it is finished, but it is not deployed (but this, my dearest reader, is another story).

And, even I wouldn't pretend that anyone would have to be certified to use my toolkit, I really would like to ear your thoughts about it. Because if there is something good about making this effort (and believe me, it is a big effort) it is all that you learn in the way. And I would love to continue learning helped by my peers thoughts.

https://hexagonkt.com
https://github.com/hexagonkt/hexagon

Thanks for reading my story!
This is day 2, Still haven't written a single line of code for this codewars challenge
Tags: challenge, codewars
Published: 2019-08-22 23:09:05

---
title: This is day 2, Still haven't written a single line of code for this codewars challenge
published: true
cover_image: https://images.unsplash.com/photo-1552345386-6690de5b2c09?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80
tags: challenge,codewars
---
As a junior developer, One of the pieces of advice I often read about how to improve my skills is to solve coding challenges. I started doing this about a week ago and at the beginning of this week, I decided to start picking questions that are above my current level. I have solved 1 and then yesterday I picked the next one. Believe me when I say, from yesterday up until this moment, I haven't written a single line of code because I have absolutely no idea on how to solve the problem. I am not a maths genius, but at least I know how to solve my basic maths problems, but the question is about Fibonacci😱and the help resources link to even a more confusing concept that I just heard about. Golden Ratio 😓.


I could just google the solution, but I feel like I won't be learning anything then. I could also just skip the question, but what if I face the same challenge with the next question and I press the skip button again, then I won't be improving myself since I will only be working on problems I can solve. 


What do you do when you are faced with this kind of problem?

What's the best approach to make sure I keep learning?

I'd really appreciate any advice that will help🙏
Share outcomes and results, not features
Tags: devrel
Published: 2019-08-27 01:10:11

---
title: Share outcomes and results, not features
published: true
tags: DevRel, DeveloperRelations
canonical_url: https://maxkatz.org/2019/08/22/share-outcomes-and-results-not-features/
---

I recently subscribed to [#saashackers daily newsletter](https://saashacker.co/). Every morning you get a short SaaS growth case study in your inbox. It’s a quick 3-4 minute read that I recommend you try.

Today’s email talked about [Mailchimp](https://mailchimp.com/) and how they got to $400 million in revenue from just 550 employees.

What caught my eye was this image and the text that followed:

![mailchimp-saashacker](https://katzmax.files.wordpress.com/2019/08/mailchimp-saashacker.png?w=931&h=1024)<figcaption id="caption-attachment-10693">Source: #saashacker newsletter</figcaption>

text after the picture:

> They are selling an outcome, not features.
> 
> They are selling the thing people actually want, not their software.
> 
> Whether you are a direct to consumer brand with 50,000 customers or a mommy blogger with 1,000 subscribers, you want:
> 
> - To build relationships with your customers
> - To increase sign up (by 250%)
> 
> You don’t (necessarily) want:
> 
> - Email templates
> - CMS integrations
> 
> _Source: [https://saashacker.co](https://saashacker.co)_

And this has a very close connection to Developer Relations (or Developer Marketing).

We should be sharing outcomes and results, not features. We should be showing people how to solve problems, not our software.

I’m sure most of you know this but I think it’s worth mentioning. I personally tend to forget about this (sometimes) and also it’s much easier to talk about features than benefits.

Most of you probably also said: “wait.. this is not new at all” 🤦‍♀️ 🤦‍♂️

You are absolutely correct 🤩

[Adam DuVander](https://twitter.com/adamd) has created and shared this wonderful page: [Share Knowledge, Not Features: The Secret of Marketing to Developers is to Not Use Marketing](http://www.shareknowledgenotfeatures.com/). It’s Developer Relations classic and my favorite Developer Relations resource. I highly recommend you read and bookmark this page. Adam explains that we should be sharing knowledge, not features.

So, let’s try to share outcomes, results, problem solving and knowledge, not features 🤞