teleren/devto huggingface dataset:
Java Structure
Tags: java, basicstructures, integer
Published: 2019-01-10 20:53:56

---
title: Java Structure
published: true
description: This article a provide simple into to the ba
tags: Java, Basic Structures, integer
---
Java is programming language with static typization. Which means that programmer need declare type and name of the variables. After it made we may use it.

```int wheels = 4```

By this string we say to the compiler that we need integer variable with name wheels.
Let's talk about data types at the java. As we know exist next type:

## byte
This type is 8 byte signed integer. It may uses for optimize speed by using it the huge array. Min value is -128 and max value is 127

## short
This type is 16 byte signed integer. Also uses for optimize speed with using huge array. Min value is -256 and max value 255.

## int
By the standard this is 32 byte integer. Min value 2^(-32) and max value is 2^(32) - 1. By default all variable declared with this type set default value 0. 

## long
This is 64 byte integer. At the Java 8 support unsigned value, by this way we may have max value 2(^64) - 1

## float
This primitive needs for represent value with floating point(single precision). It is 32 byte value. Do not use this type for operation with currency values.

## double
Double precision, it is 64 byte value. Do not use for operation with currency values.

## char
This primitive we need to represent an unicode symbol. Min value is \u0000 and max value is \uffff.

## boolean
This primitive needs to represent only two value - true or false. We need to mark some expression. 

## Strings
In additional to above, exist a class which represent a string at the java. If you put some string literal at the double quoute and assign it to the some string variable we get string variable with provided given literal.

You are write
`String author = "vrnsky";`

But inside it call
`String author = new String("vrnsky");`

Also notice that class marked as a final class. Which say to us that each instance of this class is immutable. And it is good.
Schema-DTS: TypeScript Shims for Schema.org and the Semantic Web
Tags: typescript, javascript, webdev, semanticweb
Published: 2019-01-10 19:56:06

---
title: Schema-DTS: TypeScript Shims for Schema.org and the Semantic Web
published: true
description: JSON-LD TypeScript types for Schema.org vocabulary.
tags: typescript, javascript, webdev, semantic web
---

[**schema-dts**](https://github.com/google/schema-dts) is a new library (and related tools) providing TypeScript definitions for [Schema.org](https://schema.org/) vocabulary in JSON-LD format. The typings are exposed as complete sets of discriminated type unions, allowing for easy completions and stricter validation.

![Example of Code Completion using schema-dts](https://raw.githubusercontent.com/google/schema-dts/HEAD/example-1.gif)


## Motivation

I noticed while Schema.org schema has had a lot of usage throughout the web, few Schema validation tools were integrated as part of a Developer's toolchain. For example, [Google's Structured Data Testing Tool](https://search.google.com/structured-data/testing-tool) remains a main resource for many in validating the correctness of hand-written Schema.org schema.

Enter TypeScript, and the ease of defining JSON schema using typings. Thanks to the JSON-LD format and the recommendation of Google and other search engines to encode structured data using JSON-LD (rather than microdata and other structured data formats), there's an opportunity to make writing structured data much easier. We can tighten the write-test-debug iteration by including the Schema.org schema we are writing against in our development toolchain.

## Usage

To use the typings for your project, simply add the `schema-dts` NPM package to your project:

    npm install schema-dts

Then you can use it by importing `"schema-dts"`.

## Examples

### Defining Simple Properties

```ts
import {Person} from "schema-dts";

const inventor: Person = {
    "@type": "Person",
    "name": "Grace Hopper",
    "disambiguatingDescription": "American computer scientist",
    "birthDate": "1906-12-09",
    "deathDate": "1992-01-01",
    "awards": [
        "Presidential Medal of Freedom",
        "National Medal of Technology and Innovation",
        "IEEE Emanuel R. Piore Award",
    ]
};
```
### Using 'Context'

JSON-LD requires a `"@context"` property to be set on the top-level JSON object, to describe the URIs represeting the types and properties being referenced. schema-dts provides the `WithContext<T>` type to facilitate this.

```ts
import {Organization, Thing, WithContext} from "schema-dts";

export function JsonLd<T extends Thing>(json: T): string {
    return `<script type="application/ld+json">
${JSON.stringify(json)}
</script>`;
}

export const MY_ORG = JsonLd<Organization>({
    "@context": "https://schema.org",
    "@type": "Corporation",
    "name": "Google LLC"
});
```

### See Also

- [GitHub Page](https://github.com/google/schema-dts)
- [NPM Package](https://www.npmjs.com/package/schema-dts) ([Generator NPM Package](https://www.npmjs.com/package/schema-dts-gen))
- [Google's Open Source Project Listing](https://opensource.google.com/projects/schema-dts)
AWS S3 file upload from client side
Tags: aws, ruby, s3, security
Published: 2018-10-20 22:32:06

---
title: AWS S3 file upload from client side
published: true
description: AWS S3 file upload from client side
tags: AWS, ruby, S3, security
---

Originally posted on my personal blog http://haidrali.com/aws-s3-file-upload-from-client-side/

Last week I pushed a new feature on production which involve file upload on AWS S3. When you are uploading file to S3 from frontend there is always a risk of exposing your AWS secrets to user, so you have following options to avoid this risk

1. Involve server as middleware and upload via server API, you will have more control over it
2. Allow users to upload directly to S3 anonymously

I don’t like both of above methods, as involving middleware you are uploading file twice i.e. frontend → server, server → s3 bucket and I don’t really want server to do this heavy lifting of uploading files to S3 on user behalf, while allowing user anonymous upload you are giving a blank check to you S3 bucket i.e. anyone in the world can upload to your s3 bucket, this was also not acceptable to me as this could have very swear consequences. I wanted to have bit more control over uploads while not compromising security issues, so I used AWS Security Token Service to generate secrets (access_key, access_secret) which lived temporarily and have limited access as you define it.

### H3 Configure an IAM user on AWS console to generate temporary secrets

In order to generate temporary secrets you need following configurations on AWS console

1. create a new IAM user
2. create a policy to allow upload on S3 bucket
3. create a role for you IAM user to assume Security Token Service

Watch this video for configurations

{% youtube z-r5w82C8uo %}

Now, you can generate AWS STS with this ruby code

```
aws_sts = AWS::STS::Client.new(
          access_key_id: ENV['AWS_ACCESS_KEY_ID'],
          secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
        ).assume_role(
          role_arn: ENV['AWS_ROLE_ARN'],
          role_session_name: 'session_name',
          duration_seconds: 12*60*60)
// this will generate access_key, access_secret
aws_sts.credentials
```

AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are credentials you download after creating user and AWS_ROLE_ARN is value which I copied at the end of video

### H3 Enable ACL uploading to S3

You will be able to successfully upload files with secrets generated with above code, Since we have used a separate user to generate STS then only this user will be able to access file. To make this file accessible by other user as well you must send ACL: 'public-read' in request body or header while uploading file to S3. you can read more about [ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl)

I hope this help you improve your file upload as well. If you need any help please do ping me on twitter [@alihaider907](https://twitter.com/alihaider907).
How should we indent `const` declarations?
Tags: discuss, codestyle, javascript, esnext
Published: 2019-01-10 19:28:48

---
title: How should we indent `const` declarations?
published: true
description: "`var` and `let` work nicely with 4 spaces of indentation, but `const` is 2 characters longer! How will we handle this crisis???"
tags: discuss, codestyle, javascript, esnext
---

I'm a huge fan of the additions to JavaScript of `let` and `const` to declare block-scoped variables. In particular, I love `const` for the clarity of intention it gives developers. If this is a value that should never be changed, make it a `const` so everyone (including your future self) knows not to change it.

But I have a complaint: while `let` and its predecessor `var` are each 3 characters, **`const` is 5 characters**, which ruins indentation!

```javascript
// var is 3 characters, which aligns nicely with a 4-space indentation style
var foo = 10,
    bar = 20,
    baz = 50;

// let keeps to the same 3 character pattern
let apples = 5,
    oranges = 30, // gotta get that citrus, no scurvy for me
    bananas = 12;

// const ruins everything!!!
const dontchangeme = 10,
    howmuchindentshouldihave = 4,
    thisfeelsverydirty = 0x0;
```

`const` doesn't allow for a nice alignment of variable names during declarations if you're used to 4-space indentation! I don't like the above default of just hitting enter and letting the indentation fall where it will, but I don't know what to do about it. Here are three options I'm considering:

* **Indent 6 spaces for `const` declarations** - this is *okay*, but I hate that it breaks conformity with the surrounding code.
```javascript
const foo = 10,
      bar = 20,
      baz = 30;
if (test) {
    console.log('Misaligned! 😢')
}
```

* **Write `const` repeatedly** - a few of my coworkers have adopted this pattern; I'm not sold. It just seems unnecessarily verbose to me.
```javascript
// seems like a lot of keywords...
const foo = 10;
const bar = 20;
const baz = 30;
```

* **Give `const` its own line** - I've used this a bit, and it's alright, but still feels uncomfortable.
```javascript
const
    foo = 10,
    bar = 20,
    baz = 30;
```

I need some feedback. What have you used? Which of these do you like/hate?

Another thought I had is that there's a crowd of developers out there that has sort of been dealing with the "declarations are 2 spaces more indented than everything else" problem for a while now: the 2-space indentation folks! What do you all do about this? Do you just indent 4 spaces for declarations, or... something else?

Awaiting responses!
SCSS Nesting Question
Tags: scss, css, discuss, help
Published: 2019-01-10 19:10:57

---
title: SCSS Nesting Question
published: true
description: 
tags: scss, css, discuss, help
cover_image: https://media.giphy.com/media/26gscNQHswYio5RBu/giphy.gif
---
Hi SCSS Peeps! I'm trying to get in the habit of writing better cleaner SCSS, and I need some feedback. 

![](https://media.giphy.com/media/3DnDRfZe2ubQc/giphy.gif)

Given the following (simplified) mix-in to generate media queries in SCSS:

```scss
@mixin breakpoint($point) {
    @if $point==desktop {
        @media (min-width: 70em) {
            @content ;
        }
    }
}
```
## Example A

Do you nest a Parent and Child selector like this: 

```scss
.parent {

    // Parent Mobile Styles

    .child {
        // Child Mobile Styles
    }

    @include breakpoint(desktop) {

        // Parent Desktop Stlyes

        .child {
            // Child Desktop Styles
        }
    }
}
```

## Example B

or like this:

```scss
.parent {
    // Parent Mobile Styles

    @include breakpoint(desktop) {
        // Parent Desktop Styles 
    }

    .child {
        // Child Mobile Styles

        @include breakpoint(desktop) {
            // Parent Desktop Styles
        }
    }
}
```

Or something totally different? One of my problems is I need to pick one way to handle media queries and stick with it. Any suggestions?
Fancybox without jQuery
Tags: lightbox, fancybox, javascriptlightbox, materiallightbox
Published: 2019-01-10 18:50:32

---
title: Fancybox without jQuery
published: true
tags: lightbox, fancybox, javascript lightbox, material lightbox
---
I wanted to have lightbox that will look clean, material and will work without any additional dependencies. So why I should I not do it by myself? I've developed https://fslightbox.com.

And now to the point. I would like to ask you for an opinion about the project overall, but mainly about the code - https://github.com/PiotrZdziarski/Fullscreen-Lightbox-Basic . To be honest it's beginning of my journey with JS :P

And if someone is working on Mac, can you please check library on Safari and respond how it works on it? I would be very grateful :)
Changelog: New SlideShare Liquid Tag
Tags: meta, changelog, slideshare
Published: 2019-01-10 18:35:06

A few days ago @ice-lenor raised an issue asking for the ability to embed SlideShare presentations. 

{% github https://github.com/thepracticaldev/dev.to/issues/1483 %}

Issues like this are great you simply have to say what you want and anyone can pick it up and run with it.

In order to embed a SlideShare you will need the slides key which is that last part of the embedded src URL, which you can see in the share panel.
```html
<iframe src="//www.slideshare.net/slideshow/embed_code/key/wZudqqTdctjWXA" width="595" height="485" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;" allowfullscreen> </iframe> <div style="margin-bottom:5px"> <strong> <a href="//www.slideshare.net/carologic/ai-and-machine-learning-demystified-by-carol-smith-at-midwest-ux-2017" title="AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017" target="_blank">AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017</a> </strong> de <strong><a href="https://www.slideshare.net/carologic" target="_blank">Carol Smith</a></strong> </div>
```

Then you just add it the tag like so `{% slideshare wZudqqTdctjWXA %}`
{% slideshare wZudqqTdctjWXA %}
On-Call Nightmares Podcast - Episode 5 - Kolton Andrus - Gremlin 
Tags: podcast, devops, ops, operaitons
Published: 2019-01-10 18:12:00

---
title: On-Call Nightmares Podcast - Episode 5 - Kolton Andrus - Gremlin 
published: true
description: On-Call Nightmares Podcast - Episode 5 - Kolton Andrus - Gremlin 
tags: podcast, devops, ops, operaitons
---

## On-Call Nightmares Podcast - Episode 5 - Kolton Andrus - Gremlin 

Fear, Chaos and Pain

{% podcast oncallnightmares/episode--5--kolton-andrus--gremlin-inc %}

Common subjects in the Christopher Nolan Batman films, especially when the Joker appears. How do we avoid the moments of fear, chaos and pain in real time? By preparing for it. Today we talk with Gremlin Inc founder and CEO Kolton Andrus.

Kolton is co-founder and CEO of Gremlin. Previously, he was a Chaos Engineer at Netflix improving streaming reliability and operating the Edge services. He designed and built F.I.T., Netflix's failure injection service. Prior he improved the performance and reliability of the Amazon Retail website. At both companies he has served as a 'Call Leader', managing the resolution of company-wide incidents.

Gremlin.com
Twitter: @gremlininc
Announcing dotenv-linter: a tool to lint your .env files
Tags: githunt, python, productivity, tools
Published: 2019-01-10 17:31:18

---
title: Announcing dotenv-linter: a tool to lint your .env files
published: true
description: Simple linter for `.env` files. While `.env` files are very simple it is required to keep them consistent. This tool offers a wide range of consistency rules and best practices. And it integrates perfectly into any existing workflow.
tags: githunt, python, productivity, tools
cover_image: https://thepracticaldev.s3.amazonaws.com/i/untiw080ajgmz84m9857.png
---

I happy to announce a simple yet very useful tool to lint your `.env` files.

{% github wemake-services/dotenv-linter %}


## Background

As a part of our ["not blaming but fixing" corporate culture](https://dev.to/sobolevn/building-blameless-working-environment--17hl) we build a lot of tools that prevent us from making the same mistakes over and over again.

`dotenv-linter` is one of these tools.

Some time ago we had several problems with `.env` files:

- Some developers used `CONSTANT_CASE` for variable names and some developers used `snake_case` for that. While this is not a technical issue, but it is not very practical to mix these two cases and then think: what case I have used for this particular variable? Consistency is important!
- We also had a problem with quotes and extra spaces. Some developers used `KEY=VALUE` and some used `KEY = "VALUE"` while in fact, these two examples will resolve in exactly the same thing - we prefer to have one-- and preferably only one --obvious way to do it. So, we now stick to `KEY=VALUE` notation
- We also once had a duplicate key that ruined my day. [I have spent several hours](https://dev.to/sobolevn/i-am-a-mediocre-developer--30hn) debugging my app because of this simple issue. That was a turning point for me and I have decided: let's automate it!

## Installation

You can install it via `pip` (or any other similar tool):

```terminal
$ pip install dotenv-linter
```

Why `pip`? Because `python` is present almost on all Linux setups. And we try to make this tool as portable as possible.

## Usage

Usage is really simple:

```terminal
$ dotenv-linter path/to/your/.env even/multiple/files/are/fine/.env
``` 

## Real-life examples

If you are interested in how we use it real life applications you can have a look at (and even try!) our [`django` template](https://github.com/wemake-services/wemake-django-template). Here's the [line](https://github.com/wemake-services/wemake-django-template/blob/master/%7B%7Bcookiecutter.project_name%7D%7D/docker/ci.sh#L55) that invokes it.

We also have a full list of [linting rules in our docs](https://dotenv-linter.readthedocs.io/en/latest/pages/violations/index.html), check it out.

## Conclusion

I hope this simple tool will save you some time, make your project more consistent, and your life slightly better. [Add me on github](https://github.com/sobolevn) to stay informed about the tools I am building!
Ideal boilerplate for reusable React components
Tags: react, javascript, web
Published: 2019-01-10 17:20:28

Getting started with a functional React component is easy but when we are building reusable components we should keep somethings in mind.

1. We can render custom markup inside the component to make it more flexible.
1. We can add classes to the component for modifying the styling of the component.
1. We can set attributes of the element the container is wrapping. (e.g. aria attributes, data attributes);

To ensure that our React component can support all of them we should use the following code as boilerplate.

```jsx
import React from 'react';

function ReusableComp({ className, children, ...props }) {
  const classList = ['componentClass1', 'componentClass2', className];

  const classNames = classList.join(' ');
  return <div className={classNames} {...props}>{children}</div>
}
```

First we destructure all the props we need in our component and then collect all the remaining props in `props` variable.

Then we merge the className prop with our own component's classes.

At last, we assign the className and spread the other props and render children inside the div.

We can then use it like this

```jsx
<ReusableComp className='special-item' title='actions'>
  <div>
    <button>Do Something</button>
    <a href="/go-somewhere">Go</a>
  </div>
</ReusableComp>
```

**PRO TIP**: in our component to avoid hardcoding the div element as wrapper, we can implement `as` prop in the component like this.

```jsx
import React from 'react';

function ReusableComp({ className, children, as: Element, ...props }) {
  const classList = ['componentClass1', 'componentClass2', className];

  const classNames = classList.join(' ');
  return <Element className={classNames} {...props}>{children}</Element>
}
```

then it will be used like this

```jsx
<ReusableComp as='section' className='special-item' title='actions'>
  <div>
    <button>Do Something</button>
    <a href="/go-somewhere">Go</a>
  </div>
</ReusableComp>
```
Enhance your IDE with Vim
Tags: vim, development, ide, tooling
Published: 2019-01-10 16:53:23

---
title: Enhance your IDE with Vim
published: true
tags: Vim,development,IDE,tooling
canonical_url: https://hackernoon.com/enhance-your-ide-with-vim-10b0a6ae2e40
---

#### The perfect match for a fantastic development experience 🙌

![](https://cdn-images-1.medium.com/max/2600/1*HAe2PfVOsi9MQgTYOv2Y5g.jpeg)

For a long time, I have listened to people gushing about Vim. I always respected their opinion, but in the end, I still refused to give Vim a try.

My experiences with Vim were just too painful. It was surreal to imagine how it could increase my productivity.

After listening to another Vim enthusiast, I finally rolled up my sleeves and decided to give Vim a try. 💪 And guess what — it was an excellent decision.

Don’t get me wrong.

I am not a hardcore Vim user that knows all commands and has a lot of plugins installed. I also would not want to code with plain Vim.

But combined with an IDE of your choice, Vim is a perfect tool!

[Find out why!](https://hackernoon.com/enhance-your-ide-with-vim-10b0a6ae2e40)
Share your views on development in 2019
Tags: career, survey, opinions, charity
Published: 2019-01-10 16:28:08

---
title: Share your views on development in 2019
published: true
description: A shoutout about a developer survey that's running at present
tags: career, survey, opinions, charity
---

Hi there! I've just joined the community and am looking forward to contributing some thoughts on coding with graph databases and AI. But that's for next week :o)

Today, I just wanted to do a quick shoutout for [SlashData](https://slashdata.co), a company that I work with from time to time (we recently published a book on how to market to developers ... clue: don't patronise or hype). In the spirit of that message, I promise that I won't be pushing many of this kind of post onto DEV, but I did want to share this survey before it closes. 

You may have come across SlashData before. They are an analysis company that tracks global software developer trends via regular, large scale developer surveys.

Those answering the surveys provide data for research that help the top technology firms understand who developers are, what tools are they using and where they‘re going next.

SlashData have just launched the 16th edition of our Developer Economics Survey. For everyone that takes the survey SlashData donates to a charity. This month, they're aiming to donate $2,000 to help get more kids into software development.

If you're interested in sharing your views on software development, or know someone who may be, please check out the survey [here](https://survey.developereconomics.com/surveys/de16?utm_source=owned-community&utm_medium=owned&utm_campaign=AR_VR_article).