teleren/devto huggingface dataset:
Lambda expressions in Java
Tags: java, java8, lambda, tutorial
Published: 2020-04-24 16:52:35

##__What is a lambda expression?__
* Lambda expression is a function without any signature.
* It doesn't have a name, return type, and modifiers. 
* It can have any number of arguments.
* For one argument lambda expressions, parenthesis are optional.
* Compiler can understand the data type.
* Curly braces are mandatory for many arguments.

##__Advantages of Lambda expressions__
* It helps to iterate, filter, and extract data from a collection in a very efficient way.
* It saves a lot of code.
* Code reuse
* Reduce class files

##__Functional interface__
* An interface that has only one abstract method.
* _@FunctionalInterface_ annotation is used to declare an interface as a functional interface. 
* Ex: Runnable interface

##__Lambda expression signature__

* (argument-list) -> {body}
* Ex:
``` 
( ) -> { }        
(p1) -> { }        
(p1, p2) -> { }
```
##__Rules__
```
public void m1(int a, int b){    
    System.out.println(a+b);
}
    //lambda expressions
( a,b ) -> System.out.println(a+b);
```

* Lambda expression doesn't have a name, a modifier and a return type.
* If the code contains only one line. curly braces are optional.
* Compiler can guess the return type.
```
public int square(int n){
    return n*n;
}

//lambda expressions
(int n) -> {return n*n;}
(n) -> {return n*n;}
n -> n*n;
```
	
* If only one parameter is there, parentheses are optional.
* Since it has only one line, curly braces are optional. 
* Without curly braces, the return type is optional.

##__Valid statements__
```
Interf i = n -> n*n;
Interf i = (n) -> n*n;
Interf i = n -> {return n*n;};
```
##__Invalid statements__
```
Interf i = n -> return n*n;
Interf i = n -> {return n*n};
Interf i = n -> {return n*n;}
Interf i = n -> {n*n;};
```
##__Example 01__
```
public void m1(){
    System.out.println("Hello");
}

//lambda expressions
( ) -> System.out.println("Hello");
```

##__Example 02__
```
public void add(int a, int b){
    System.out.println(a+b);
}

//lambda expressions
(int a, int b) -> System.out.println(a+b);
(a, b) -> System.out.println(a+b);
```

##__Example 03__
```
public int square(int n){
    return n*n;
}

//lambda expressions
(int n) -> {return n*n;}
(n) -> {return n*n;}
n -> n*n;
```
#2020 was a Non-Starter For Me
Tags: webdev, career
Published: 2020-04-24 17:12:29

Something of a humbling experience, I left China in August '19 and ready to get back into Western life and a drive to get into Web Development and Software Engineering. I spend the past year studying what I could and building some smaller projects while learning. No Computer Science degree, no Boot camp. 

2020 was meant to be the start of something serious for me, and then Covid-19 starting to take a grip on the world and hiring-freezing started settling in. My job alerts began drying up, and now here I am.

An inspiring conversation with a family friend in the job field, I got running again with patching holes in my knowledge and getting stuck into the events that were once in-person and now free online webcasts. 

> Now is the time to be taking this free-time and really developing what you can

So, I'm doing just that, I've scratched up on Data Structures and Algorithms, I've gotten my head around Typescript. I still have other lessons I want to learn like native mobile development, however, for now, I'm going for the spit-and-polish approach. I'm revisiting what I've learnt, old projects that I should have hosted online ages ago, and finally getting to grips with having an online presence again.

I'm sat on quite extensive notes, and without plagiarising any course or material that I've learnt from, I do think that everything that I'm learning is best shared online rather than sat as 1s and 0s in my laptop. Not to mention that technology moves so fast right now, that it'll probably be outdated by this time next year. Just like how searching anything outside of MDN or other well-maintained sources, you can find yourself looking at outdated or hacky approaches. I mean, just google 'centring with CSS'.
How to disable youtube iframe video right click copy video url option?
Tags: javascript, html, css, react
Published: 2020-04-24 17:11:05

---
title: How to disable youtube iframe video right click copy video url option?
published: true
description: 
tags: javascript, html, css, reactjs
---

Hello,
I need to disable the youtube iframe video right click "copy video url" option.
Is there any way to fix it, kindly need help. 
<img src="https://i.imgur.com/cnlOAVM.png">
Today I found a bug !
Tags: webdev, story, opensource, github
Published: 2020-04-24 16:58:30

Hello, 

I like coding, I do that everyday but something strange happened to me today. I work in a company that use extern library with API for his business and I have for mission to update a block that use one of this services with extra data.

Humm.. ok no problem. I'm used to doing this kind of things. 
I start to read in the documentation of this library to find out me how it works, and.. Ok I show it.

I'm ready to code, I go in my terminal create a new branch from preprod and let's go. 
Time flies, I see things take shape I'm glad but when I test I don't get what I expected. Oooookay I should miss something, I go to the documentation recheck if I forget something but no all look good. 

OK maybe there are a dependencies problem ? I check my composer.. Yeah maybe if I update this one it will works. Let's go for that !

![A few minutes later](https://media.giphy.com/media/3o6wNSTMj6KHBEIguY/giphy.gif)


Still same errors grrr !

OK why you don't work *** !?
I don't have a great debugger to help me to find a solution but I saw all Rambo movies and I know what has to be done. I decide to put on a bandanna on my head and dump my request every place where he go to find where it goes wrong.

![Go Rambo go !](https://media.giphy.com/media/3oz8xI5c0K0hFPwmGI/giphy.gif)

I started by putting dump in 2 places, first at the end of my code to show if I send correct data (just to be sure because in theorie I have already test that)
And the other place is directly in the library i use for make connection with this service, juste before the request is sent correctly.

So the first dump I have put, looks ok the data look like it's demand. 
And the second, looks good too.. Damnit ! 

OK I'm confused, I don't know why it doesn't work but there are a fact it's doesn't works. Code isn't magic there are necessarily somewhere a thing who's going bad. 
Well, let's try something else. Humm.. I will simulate the call with Postman maybe I will show a new errors message that can help me ?
So I do that and.. It works !

![Magic !](https://media.giphy.com/media/37QADdG7V5bo9ToyCX/giphy.gif)

Wait.. what ?!
It works, but I do the same things.
> To tell the truth at this moment I am nevertheless delighted to have a good result

Why in Postman it works but not when I execute my code ? I'm sure now my data are good so I check carefully every data send in the library are correct and.. **voila** I found It !!

I did not pay attention but the library convert boolean to integer and there goes the shit. It sounds futile but the typehint is very important.

So after discovery that bug, I went to the Github repository of that library and make a [pull request](https://github.com/HubSpot/hubspot-php/pull/313) with a little fix. Pending, I make a fork of this repository with the fix and use it directly in my project.

Today I found a bug and I tried to fix it !

And you have you already found a bug in a library ?

Thank for reading, 
Codeur M
How Prometheus Monitoring works 🔥 Prometheus Architecture explained
Tags: prometheus, devops, kubernetes, tutorial
Published: 2020-04-24 16:44:56

**Prometheus has become the mainstream monitoring tool of choice in container and microservice world. 🔥**

In my new video you will learn:

1. **Why Prometheus is so important** in such infrastructure and what are some specific use cases
2. **Where and why is Prometheus used**?
3. Specific Use Cases
4. **How Prometheus works?** What are targets and metrics?
5. How does Prometheus collect those metrics from its targets?
6. I explain **Prometheus Architecture with simple diagrams** and go through the main components: Prometheus Server, Pushgateway, Alertmanager, Prometheus Data Storage
7. **Configuring Prometheus** - Example YAML Configuration
8. The advantages of Prometheus Pull System compared to alternative monitoring tools, which use  Push System
9. Using Prometheus Monitoring with **Docker 🐳 and Kubernetes**

You will also **better understand why it’s important to monitor your applications/infrastructure in general**.

✅  Separate practical video for monitoring Kubernetes services with Prometheus will follow  ✅

{% youtube h4Sl21AKiDg %}

-----------------
► Get **30% off** - with this code: UDEMY_NANA_NOV2020: [Udemy course here](https://bit.ly/35qF26i)
► **Kubernetes 101**: [Compact and easy-to-read ebook bundle 🚀](https://www.techworld-with-nana.com/e-books) 
It's a handy way to quickly look something up or refresh your knowledge at work and use it as your cheatsheet  😎


I'm happy to connect with you on 🙂
- [Private FB group](https://www.facebook.com/groups/techworldwithnana)
- [Twitter](https://twitter.com/Njuchi_)
- [YouTube](https://www.youtube.com/channel/UCdngmbVKX1Tgre699-XLlUA?sub_confirmation=1)
- [Instagram](https://www.instagram.com/techworld_with_nana/)
Get Started with a Headless Wordpress Site
Tags: wordpress, nextjs, headless, decoupled
Published: 2020-04-24 16:40:03

When choosing to build a site with Wordpress, there are a couple of options. You can use Wordpress to handle the backend and the frontend with PHP (classic), or you can separate them and use Wordpress for the backend and a JavaScript framework of choice for the frontend, like React or [Next](https://nextjs.org/). 

There are some advantages and disadvantages to each option, which are discussed in this Smashing Magazine post, ["Headless WordPress: The Ups And Downs Of Creating A Decoupled WordPress"](https://www.smashingmagazine.com/2018/10/headless-wordpress-decoupled/). I am starting a project using the decoupled method and will probably post about it along the way. An easy way to get started is by using [Local by Flywheel](https://localwp.com/). Below is a guide to get up and running:

1. In Local by Flywheel click "Add Local Site" to create a new Wordpress site, and then click "Start Site." This will start up the Wordpress backend server. 
2. Install plugins:
    - ACF to WP API
    - Advanced Custom Fields
    - JWT Authentication for WP-API
    - WP-REST-API V2 Menus
    - Custom Post Type UI (optional)
3. Navigate to the Flywheel folder for the project and replace the app > public > wp-content folder with the copy the wordpress > wp-content folder from [this Headless Wordpress Starter repo](https://github.com/aellonk/headless-wp-starter/tree/aellon-master/wordpress/wp-content), which is adapted from [Postlight's Headless Wordpress Starter Kit](https://github.com/postlight/headless-wp-starter).
4. Add the frontend folder from the same repo in the root of the Flywheel project directory.
5. In frontend > config.js, replace the following wpURL with the link to your backend Wordpress API endpoint. The Wordpress API is the Wordpress site followed by wp-json, for example: ` let wpUrl = 'http://headlesswptestproject.local/wp-json/';`
6. Open a terminal, `$ cd frontend && yarn && yarn start `
7. That should open up localhost:3000. This will start up the frontend server. 
8. If there is an error shown on your localhost:3000 page, create a page in WP with the title/slug = “welcome”

The [WordPress REST API](https://developer.wordpress.org/rest-api/) allows us to work with JSON to send and receive data from our Wordpress site. That opens the door for developers who want to create beautiful, dynamic Wordpress sites using newer tools and frameworks like Next.js. I'm excited to try it out and see how it compares to building a site entirely with Wordpress. Check back soon for more updates on the process!
Hiring Game Dev
Tags: unity3d
Published: 2020-04-24 16:31:01

Hi Everyone! 
I'm helping one of the world's leading game studios find a Sr Software Engineer to join their elite engineering team in Sao Paulo. 
Comp: 10-17k BRL/m (equivalent to 2-3k USD/m) + 10k USD relocation package (can start remote).
Stack: Unity with C++ or C#

If anyone feels fit enough or know someone who is, feel free to email me:
juan.blanco@nextonlabs.com
Breaking the tech divide in the times of confinement
Tags: twiliohackathon, techdivide, voice, sms
Published: 2020-04-24 16:27:12

Working with Twilio's **SMS** and **Voice** APIs to help the elderly and other communities overcome social distancing.

Not everyone has a nephew that can help them with tech. Why don't we provide them with one?

Why not use old tech (phones) on the user's end and leave new tech (servers, APIs) to us?

More coming soon :)
Crystal Fridays is in 30 minutes!
Tags: crystal, programming, streaming
Published: 2020-04-24 16:25:32

[Tune in](https://twitch.tv/arschles) today at 10am Pacific Time to watch me write some [specs](https://crystal-lang.org/reference/guides/testing.html). I'm not sure _what_ I'm gonna write specs for, but it'll probably be related to my [cprox project](https://github.com/arschles/cprox).

See you there!

[twitch.tv/arschles](https://twitch.tv/arschles)
JavaScript Coding Challenge #2: Add all Integer in a string using JavaScript.
Tags: javascript, codenewbie, react, reactnative
Published: 2020-04-24 16:24:51

###**Input** : A single string "1bn22vg4n62"
###**Output** : 89
###**Problem** : Add all Integer in a string using JavaScript.
---

```javascript

let s = '1bn22vg4n62';                //Input String
temp = "";                       //temp var to capture digit from string
sum=0;                               //sum variable to add
for(let i=0;i<s.length;i++){
 
  if(!isNaN(parseInt(s[i]))){    //logic to check char in string is digit
    temp+=s[i];                  //if true add char to temp string
  }
  else{
    sum+=parseInt(temp);         //if char in string is char- add to sum after 
                                 //converting into integer
    temp="0"                     //setting temp to 0 to neglect effect
  }
}
console.log(sum+parseInt(temp));  
//89

```
**Next Coding Challenge: updated soon**
Hibernate Optimistic locking and Pessimistic locking
Tags: hibernate, beginners, java, jpa
Published: 2020-04-24 16:23:44

##__Optimistic locking__
 
* When two threads are going to update the same data at the same time, conflict can happen.
* There are two options to handle this, __Versioned__ and __Version-less__.

##__Versioned Optimistic locking__

* In this case, _@Version_ annotation can be used.
* _@Version_ annotation allows Hibernate to activate the optimistic locking whenever executing an UPDATE and DELETE statements.

```
@Entity@Table(name = "orders")    
public class Order {
   @Id
   private long id;

   @Version
   private int version;

   private String description;
   private String status;

}
```

##__Version-less Optimistic locking__

* But in this approach, it considers the entity as a whole unit.
* If you change two fields at the same time, then It will throw an _ObjectOptimisticLockingFailureException_.
* To handle this we can use simply version-less optimistic locking.
* This can be achieved by using _@OptimisticzLocking_ and _@DynamicUpdate_ annotations.

```
@Entity
@OptimisticLocking(type = OptimisticLockType.DIRTY)
@DynamicUpdate
public class VersionlessProduct {
    @Id
    private UUID id;
    private String name;
    private int stock;
}
```

##__Pessimistic locking__
* This can be implemented by _@Lock_ annotation 

```
interface WidgetRepository extends JPARepository<Widget, Long> {

   @Lock(LockModeType.PESSIMISTIC_WRITE)
   Widget findOne(Long id);
}
```
Compact vs Readable Code
Published: 2020-04-24 15:58:26

Happy Friday everyone! I'm gonna be honest y'all, I'm picking up a new cat today so my focus is *not the best*. His name is Bumble Bee and he's the cutest:

![picture of a medium haired black cat sitting amongst many toys and looking up with very wide eyes](https://res.cloudinary.com/dwfqeeh5f/image/upload/v1587742383/Blog%20Images/Image_from_iOS.jpg)

So in light of this, we're going to wait to do part VI of the binary tree series, since I don't have time to do thorough research. Have a bit of an opinion piece instead!

This week I was sent an interesting interpretation of the classic FizzBuzz challenge. For those who do not know, FizzBuzz is a classic algorithm challenge, that goes like so:

> Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

[This article](https://codeburst.io/javascript-breaking-down-the-shortest-possible-fizzbuzz-answer-94a0ad9d128a) provides an extremely concise means of solving the problem:

```
for(let i=0;i<100;)console.log((++i%3?'':'fizz')+(i%5?'':'buzz')||i)
```

It then runs through exactly what's going on there, because frankly it is a pretty intimidating looking jumble of code. But the feather in its cap here is just how short it is. You could say that it is extremely simple, since it uses only one line of code. 

On the other hand, if you define simplicity around readability, I would consider it very complex. A more traditional, but longer, solution looks like this (as provided in the same article):

```
for (var i=1; i < 101; i++){
    if (i % 15 == 0) console.log("FizzBuzz");
    else if (i % 3 == 0) console.log("Fizz");
    else if (i % 5 == 0) console.log("Buzz");
    else console.log(i);
}
```

This code is much more readable, as a human. If this, do this, else if this do this, and so on. More lines of code are used, but it allows for much more approachable code.

Some will tell you that the best code is code that uses as few lines as possible.

Some will tell you that the best code is code that is readable.

While I certainly agree that you should make sure your code is tight, concise, not bloated, etc, I do not think that that should be taken so far as to sacrifice readability. If I'm new to your code, I should be able to walk in and understand what's going on easily.

So far as I can tell, there is no performance difference between the above two samples of code, or if there is one it's negligible (if someone reads this and does know a difference please let me know, I'd be super curious to see where the difference lies! That's an area I'm still growing my knowledge). Given that, I'll take the readable version any day.

I really enjoyed getting to see this - I learned something new about `console.log` and the `||` operator for one, and it was a neat thought experiment to see how this solution could be distilled down.

Still, at the end of the day, I think I'll stick to my ifs and switches!
Parallax Scrolling Effect In UIKIT
Tags: css, html, webdev, tutorial
Published: 2020-04-24 15:51:25

Parallax is a background fix effect that is the first web trending effect. Here we used UI-KIt CSS framework to make this awesome Parallax Scrolling effects elements.



In this element, we used the UI-KIT class to make this Parallax effect. For making full screen we used CSS height properties and width properties. Also, we used a heading tag with a CSS flex property to make this text proper center. We also used some background properties to make an image perfectly center and flexible.

Make it yours now by using it, downloading it, and please share it. we will design more elements for you.

[Download Source Code](https://w3hubs.com/parallax-scrolling-effect-in-uikit/)
Extração de dados em massa
Tags: linux, data, zabbix
Published: 2023-05-13 18:03:55

---
title: Extração de dados em massa
published: true
date: 2020-04-24 15:29:26 UTC
tags: linux,data,zabbix
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/1024/1*xwR7pD6z4p5zgLQMXrPA8Q.png)

Alguma vez ja te pediram uma quantia absurda de dados e você ficou na duvida de como faria isso?

Podem existir varias formas criativas de se fazer isso, mas por exemplo, coletando dados a cada 30 segundos de um item, um mes de dados coletados pode ser algo meio dificil de se retirar da ferramenta de forma “utilizavel” para se utilizar em uma reunião ou apresentação a um cliente.

Procurando por uma solução, encontrei um script alterado, que mesmo nas mais atuais versões, ele continua funcionando, diferente do script base, que parece ter sido abandonado pelos desenvolvedores.  
O cara se chama monitoring\_data\_to\_csv (link no fim do post), que por meio de um script feito em python consegue coletar os dados e registra-los em CSV (oque ja ajuda muito não é mesmo?

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

```
sudo ./fetch_monitoring_data_to_csv.py -s 192.168.xxx.xxx -n 192.168.xxx.xxx -u 'usuario' -p 'senha' -k 'chave do item' -t1 'data inicio' -t2 'data final' -v 1
```

Ps: Por algum motivo bizarro, as vezes ao executar ele não finaliza, então deve-se tentar executar novamente… parece gambiarra, mas acredite, funcione rs.

Creio que muita gente ja conheça, mas acho que possa acabar ajudando se alguem procura uma luz e não tem tanto tempo pra ficar garimpando github’s a fora ou posts em outros idiomas.

Editado: recentemente alterei o script para que fosse mais efetivo e corrigi alguns bugs, então abaixo segue o mesmo em meu github.

[https://github.com/Punkays/ZBX-Automations](https://github.com/Punkays/ZBX-Automations)
100daysofcode Flutter
Tags: 100daysofcode, flutter
Published: 2020-04-24 15:27:59

day 46/100 of #100daysofcode #Flutter
Learning Flutter , courses Udemy from
@maxedapps

Today how to use lib http , http.post,json.encode,
https://github.com/triyono777/100-days-of-code/blob/master/log.md
🎉 Announcing Blitz.js: Rails-like framework for full-stack React apps — built on Next.js
Tags: react, javascript, nextjs, framework
Published: 2020-04-24 15:23:30

Today we're announcing the [first alpha release of Blitz.js](https://github.com/blitz-js/blitz)!

Blitz is a Rails-like framework for monolithic, full-stack React apps.

Blitz brings back the **simplicity and conventions** of server-rendered frameworks like Ruby on Rails while preserving everything we love about React and client-side rendering!

Blitz is the framework for the 99% of us at companies with <100 employees. This means **we don't force you to use advanced technologies like GraphQL**. We let you add advanced technologies on your terms and at your pace.

Blitz **maximizes your productivity** both when starting an app and when scaling it to lots of code and users.


#### Features:
⚡️ Built on Next.js
⚡️ Don't have to build an API for client-side rendering
⚡️ Client-side rendering, Server-side rendering, and fully static pages all in the same app
⚡️ Full Typescript support with static, end-to-end typing (no code generation step needed like with GraphQL)
⚡️ React Concurrent Mode enabled
⚡️ Database/ORM agnostic, but Prisma 2 is default
⚡️ CLI with code scaffolding, Rails-style console REPL, etc
⚡️ GraphQL Ready
⚡️ Deploy serverless or serverful

#### Other key features coming:
⚡️ Highly secure authentication
⚡️ Authorization you can use on both server and client
⚡️ Model validation you can use on both server and client
⚡️ Plugins for easily adding libraries like Tailwind, CSS-in-JS, etc.
⚡️ React native support
⚡️ GUI so you don't have to use the CLI

## Try Blitz Yourself 
```
npm i -g blitz
blitz new myapp
```

[Read the Alpha User Guide](https://github.com/blitz-js/blitz/blob/canary/USER_GUIDE.md) to learn more!
Wizar devlog 13 - Still refactoring the reaction system
Published: 2020-04-24 15:18:21

Tunnel refactoring continues. I spend the week to rewrite the reaction system of Ravioli to react on leaf update. Exhausting and there is a lot of work. I have just found a new way to do this by relying directly on leaf instance reference rather on JSON patch. I thinkg a new week (so two) of refactoring is coming on.

To change my mind, I am writing a 2d engine based on Three.js (yes) for React Native. I hope to show the first sprite next week :)