teleren/devto huggingface dataset:
Making Snake Game With Javascript
Tags: javascript, game, programming, fun
Published: 2018-07-14 17:21:21

---
title: Making Snake Game With Javascript
published: true
description: Making a snake game with javascript
tags: javascript, game, programming, fun
cover_image: http://erhankilic.org/wp-content/uploads/2018/07/snake-game.jpg
---
This post was first published on [*Making Snake Game With Javascript*](http://erhankilic.org/post/making-snake-game-with-javascript/)

Ever since childhood I have always wondered how to make games and I wanted to make my own game one day. After spending so much time in the software industry, I asked myself why I should not do it anymore. Thus, I will improve my Javascript skill and I will also look at the software development process in a way that I have never looked at before.

Before I started coding the game, I began to think about how the algorithm of the snake's movement would be. Some of the first options that came to mind were; scan the entire playground in every move, to keep the coordinates of each cell of the snake on a array and update the old and new cells while moving. At the end, I understood that it was best to erase the last cell of the snake and attach a cell to the head.

First I created a snake object and I wrote the code that would create the playground. After creating the playground, I found a nice font for the game and added it. I wrote the algorithm that would make the snake move after I wrote a code that composes the snake and puts it into the playground.

When I wrote the snake's movement for the first time, it continued to move outside the playing field and could go back inside. For example, while the snake was moving upwards, if I pressed down, it was moving within itself.

First of all, if the snake came to the edge of the playing field, I wrote the codes that would allow it to continue from the other end. So, for example, if the snake reached the left edge, it would have entered the right edge.

After that, I wrote the codes that control the direction key that moves according to the direction the snake moves. So, for example, if I press down on the button while the snake is moving up, it doesn't do anything. After this I added the ability to start and stop the game.

At this point, I stopped taking care of for about a month or two. A lot of different thoughts and things got in.

Today the game came to mind again and I started again. Finally, I finished the game by adding the bait, the game score and the ability to manage game settings.

I enjoyed making this game very much and I am very excited to see the result. Only problem is if we press the arrow keys too fast, the snake starts to act ridiculous. I think this is caused by the frame rate of the game, but I have not figured it out yet.

My next goal is to write a tetris or a simpler than tetris.

You can play the game on [here](https://erhankilic.github.io/snake-game/).

You can check the codes on [here](https://github.com/erhankilic/snake-game).
What's in your bookmarks bar?
Tags: tools, productivity, discuss
Published: 2018-07-14 17:18:43

---
title: What's in your bookmarks bar?
published: true
description: I have a lot of bookmarks; but the ones I can't live without are right up there where I can see them, in the bookmarks bar!
tags: tools, productivity, discuss 
---

My go-tos are W3Cschools, RawGit, HTML5 Outliner, W3C Validator, JSLint, websniffer.cc (http req/res on the fly), regex101.com (regex tester), OhShitGit.com, explainshell.com, Liveweave (great color matcher) and Codepen.io. 

How about you?
Proxymise Your Async Code
Tags: javascript, coding
Published: 2018-07-14 16:12:54

---
title: Proxymise Your Async Code
published: true
description: 
tags: javascript, coding
---

If you've written a fair amount of JavaScript these days, it's likely that you came across [promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) and their language integration [async functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function). With [Proxymise](https://github.com/kozhevnikov/proxymise) there is now a way to make your code even more consise!

## What

Proxymise is a JavaScript library that lets you wrap functions that return promises so you can call methods on the objects they would resolve to.

## Why

When using synchronous functions, you can use the returned value directly. This lets you write [fluent interfaces](https://en.wikipedia.org/wiki/Fluent_interface) for your libraries.

```javascript
select("*").from("myTable").where("x > 10");
```

While _async functions_ helped a bit with some types of invocations, it still can clutter your code.

Proxymise wants to solve this issue.

## How

Instead of writing a `then` chain like this:

```javascript
fetch("example.com")
.then(r => r.json())
.then(r => r.record.id)
.then(id => ...);
```

Or a `await` list like that:

```javascript
let r = await fetch("example.com");
r = await r.json();
const {id} = r.record;
...
```

It allows you to wrap your promise and call methods on it, making the your interfaces more fluent.

```javascript
const newFetch = proxymise(fetch);

const {id} = await newFetch("example.com").json().record;
```
It does this by returning [proxy objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) right away while the promise is still in flight. These will then wait for the resolve and apply the function calls later.

## Conclusion

Proxymise is a quick way to make asynchronous library usage more consise by getting rid of boilerplate code.
Ruby Gem debug_helper Version 1.7 Is Up
Tags: ruby, debugging
Published: 2018-07-14 15:52:43

---
title: Ruby Gem debug_helper Version 1.7 Is Up
published: true
description: Adds classes File and Set, option depth
tags: ruby, debugging
---

Ruby gem <code>debug_helper</code> [Version 1.7](https://github.com/BurdetteLamar/debug_helper#new-in-version-17) is up.

New classes detailed:

- ```File```
- ```Set```

New option:

- ```depth``` (controls depth of recursive analysis)
They Watched Us With Webcams And Rewrote Our Code!
Tags: career, culture, database, story
Published: 2018-07-14 15:02:51

---
title: They Watched Us With Webcams And Rewrote Our Code!
published: true
description: One of the most frustrating software projects I've been on involved webcam spying and having our code rewritten.
tags: #career #culture #databases #story
---

One of the most frustrating software projects I've been on involved webcam spying and having our code rewritten.

A large company that bought out two young entrepreneurs hired me and 9 other consultants to help them.

But the entrepreneurs *didn't really want help*.

They had no desire to listen to our advice, or treat our opinions as worth anything whatsoever.

Their parent company had hired us to help with serious problems with performance of the data layer of the application.

But when we offered solutions, _we were subjected to intimidation and ignored_.

In this story, I share how software developers can act irrationally when they fear being "found out" as not knowing something.

Visit my site to watch the full video (or listen as a podcast):

# [📺 Watch or 🎧 Listen](https://jaymeedwards.com/2018/07/13/they-watched-us-with-webcams-and-rewrote-our-code/)

<hr />[🔔 Subscribe for over 100 videos on healthy software development](https://YouTube.com/c/JaymeEdwardsmedia?sub_confirmation=1)
What does good onboarding look like?
Tags: devdiscuss, newhire, devculture
Published: 2018-07-14 14:44:46

---
title: What does good onboarding look like?
published: true
description: discussions about onboarding culture
tags: devdiscuss, newhire, devculture
---

On Monday, *two* new developers start at our company. We only have ***two*** developers now, so this is a big increase for us. I've been thinking over the past two weeks what would be the best way to bring these new people into our organization, with our limited culture, and how to grow the culture with them moving forward. 

What does a good on onboarding process look like? Are there any specifics it should or should not have?
How do you think Guido stepping down as BDFL will affect Python?
Tags: discuss, python
Published: 2018-07-14 13:00:07

---
title: How do you think Guido stepping down as BDFL will affect Python?
published: true
description: 
tags: [discuss, python]
---
Edit:
I missed the earlier discussion from 2 days ago
{% link https://dev.to/ben/guido-van-rossum-steps-down-as-pythons-bdfl-thoughts-4nc3 %}
Set Button onPress Event In React Native
Tags: react, reactnative, javscript, android
Published: 2018-07-14 12:45:08

---
title: Set Button onPress Event In React Native
published: true
description: Set Button onPress Event In React Native
tags: #react #reactnative #javscript #Android
---

# Set Button onPress Event In React Native

Post Link : https://www.skptricks.com/2018/07/set-button-onpress-event-in-react-native.html

In this tutorial, We are going to explain how to set button onPress Event in react native application. A basic button component that should render nicely on any platform. Supports a minimal level of customization. In this demo we are applied onPress Event on button and calling buttonClickListener() function, when user clicks on button.

<a href="https://www.skptricks.com/2018/07/set-button-onpress-event-in-react-native.html" >Set Button onPress Event In React Native </a>

<img src="https://3.bp.blogspot.com/-FVeOc3q_HmU/W0nqaIULesI/AAAAAAAABsU/zLxHmsgNTrQQVah205FYX3HJc0_nq33PgCLcBGAs/s400/button.jpg" />
Test Driven Development 101 and JS testing
Tags: testing, javascript, jest, mocha
Published: 2018-07-14 11:04:18

---
title: Test Driven Development 101 and JS testing
published: true
description: 
tags: Testing, Javascript, Jest, Mocha
---

## **Test Driven Development Cycle**

TDD Cycle: 
1. Write a test case which will obviously fail in the beginning. Do not have more than one failing test case at a time. Implement the simplest algorithm first, then generalise it when you identify some patterns. 
2. Write code that makes test case pass 
3. Refactor code on code base. Do not refactor when your tests are failing. Make test cases pass first. 

I’m honestly still trying to get the hang of testing and I am still trying to familiarise myself with js in general. 

## **Writing tests in Jest**

Setting up is pretty straightforward.
Just npm install jest. 
Remember to change in package.json, 

```
  "scripts": {
    "test": "jest"
  },
```


Name test file [file name].test.js
First, we write our test. 
The test would require the main module.
We can assign it to a variable name.
For example:

```
const arabicToRomanNumbers = require(“./arabicToRomanNumbers”); 
```

Following that, we can start writing our test.

The first test would be something like,

```
test(“I is 1”, () => {
expect(arabicToRomanNumbers(“I”)).toBe(1);
});
```

Name file name [file name].js
Main js file: Just write the function.

```
function arabicNumber(string) {
if (string == “1”) {
return 1;
}

export.modules = arabicNumber;
```

**BTW: export class MyClass doesn’t work for nodejs.**  I have to use the module.exports keyword :( Or use babel npm package to transpire ES6 into commons target. 

You can write all your function declarations first and then export them in an object:

```
function bar() {
   //bar
}

function foo() {
   //foo
}

module.exports = {
    foo: foo,
    bar: bar
};
```
There's no magical one-liner though, you need to explicitly export the functions you want to be public.

```
var exported = {
   someFunction: function() { },
   anotherFunction: function() { },
}

module.exports = exported;
```

## Writing tests in mocha:
Somehow, I have to name my test file test.js. Not sure why yet.

Need to also declare assert.
const assert = require('assert');

Otherwise, the structure is pretty similar. 
Write a function, and then use the function during the test itself.

```
describe('romanise', () => {
    it('should be less than 4000', function () {
        const result = romanise(4000);
        assert.equal(result, 'invalid input');
    });

// write more it and asserts here.

});
```
On esoteric languages
Tags: discuss, esoteric, code, fun
Published: 2018-07-14 10:10:23

---
title: On esoteric languages
published: true
description: Looking for opinions on esoteric languages
tags: discuss, esoteric, code, fun
cover_image: https://thepracticaldev.s3.amazonaws.com/i/bqf6xx5lxghx80wbjsqa.PNG
---

I've got a new laptop so I had to arrange the files and folders I wanted to transfer from my old computer to the new one. I guess you know that it can be a time-consuming process, but it worth the time because you might find some interesting stuff you have already forgotten about. 

And this is how I've found a folder where I kept all the things (code, books, etc) on esoteric languages like Brainf*ck, Shakespeare or Befunge. 

I have a few source files and as I remember I even answered a [question on Stackoverflow](https://stackoverflow.com/questions/32100046/print-text-multiple-times-in-brainfuck/32117455#32117455). I also made a BF interpreter running in the browser, but the code is awful as I made it 3 years ago. (the cover image is a screenshot of it)

I checked the list of esoteric languages on the [Esolangs portal](https://esolangs.org/wiki/Language_list) and as I remember it was a lot shorter a few years back, so I guess people still love the idea of doing something fun! :)

- So what is the most complex program you have written in an esoteric language?
- Have you ever taken part in a competition?
- Do you like esoteric languages? Why? Why not?
- Have you made an esoteric language?

And the most interesting to me:

- Do you think writing code in esoteric languages can help to be a better developer? Why? How?
Parse JSON string without JSON.parse and eval()
Tags: json, javascript
Published: 2018-07-14 07:20:18

---
title: Parse JSON string without JSON.parse and eval()
published: true
description:  Parse JSON string without JSON.parse and eval()
tags: json,javascript
---

```

	var jsonStr="{name:'abc',age:20}";
	var jsonObject = (new Function( "return " + jsonStr ) )() ;
	console.log(jsonObject);

```
Finding duplicates algorithm series - An Unsorted array as an input.
Tags: hashtable, array
Published: 2018-07-14 05:18:24

---
title: Finding duplicates algorithm series - An Unsorted array as an input.
published: true
description: 
tags: HashTable, Array
---

Whenever I prepare for the interviews I start with “Arrays and strings” and then move to Linkedlist, trees and eventually find myself lost in plethora of topics that I don’t know much about like Dynamic programming, Graphs etc.

So here we go again, hopefully I get through most of them this time, more importantly understand better what I know already hence writing here.

                        


**Problem: Finding duplicates inside an array?**


Solution: Let’s draw a simple example of what is expected in this problem.


![Example](https://thepracticaldev.s3.amazonaws.com/i/9ut1e3qm8g2hwbiadhd2.jpeg)

What are the concerns and questions I have as soon as I hear/read this problem.

![Follow-ups](https://thepracticaldev.s3.amazonaws.com/i/blrt04e429ajs55xq50i.jpeg)


Set or HashTable kind of data structure that comes to my mind for most of the array/strings related problems.

Set-: With set I can store only the item not their occurrence, would that do it? 
Let’s see: for each item inside an array add them to set, if item already exists inside an array that means that is a duplicate item so we’ll add it to list. Repeat this for all the items inside an array and return the list at the end.

Why Set/HashTable not list or another array-: Both Set and HashTable stores distinct items inside them and they give us O(1) search time which is the fastest among different data structures. When input array is large constant search runtime can be very vital.

![Set & Map](https://thepracticaldev.s3.amazonaws.com/i/rri7bnc7r0u0xr6wyy1h.jpeg)

Let’s try writing down a pseudo code.

![pseudo code](https://thepracticaldev.s3.amazonaws.com/i/92607peg08e3ofwohf1l.jpeg)

Time Complexity-: O(n)
Space Complexity-: O(n)

n: number of items inside array.

How to update our algorithm when we only have to check if duplicate exists in an array?

We can change our existing algorithm and instead of filling items inside list when we are iterating over set we'll just return true boolean value if item exists inside set or otherwise.

Similar problems -:

{% link https://dev.to/s_awdesh/finding-duplicate-character-inside-string-3100 %}

{% link https://dev.to/s_awdesh/check-if-duplicate-exists-inside-a-sorted-array-3aa5 %}

This is the simplest and not the most efficient implementation for finding duplicates. In the next article I plan to work on different version of this problem. 

Stay tuned.
Introduction to mapping with {sf} & Co.
Tags: r, rstats, rspatial, sf
Published: 2020-06-09 14:30:36

---
title: Introduction to mapping with {sf} & Co.
published: true
date: 2018-07-14 00:00:00 UTC
tags: r, rstats, rspatial, sf
canonical_url: https://statnmap.com/2018-07-14-introduction-to-mapping-with-sf-and-co/
---

At the “Rencontres R 2018” in Rennes, I proposed a brief introduction to mapping using the recent {sf} package and some other interesting packages. This blog post is an extended version of my presentation allowing me to share the code of the different maps that appeared on it. It’s still a brief introduction.The original “RR2018” presentation in French is on my github repository

See more: [Introduction to mapping with {sf} & Co.](https://statnmap.com/2018-07-14-introduction-to-mapping-with-sf-and-co/)
A Quick Productivity Tip For Scala Beginners
Tags: scala, beginners, tip, test
Published: 2018-07-13 22:07:06

---
title: A Quick Productivity Tip For Scala Beginners
published: true
description: A quick tip for getting productive quickly with Scala
tags: scala,beginners,tip,test
---

One of the first things I might want to learn when given a new language is how to quickly run an isolated chunk of code, so that I can easily try out small experiments, and make sure I understand the language semantics or its libraries. It's not always simple to figure out how to do this, though.

If we're using Node.js / Javascript, we can simply write a little script and execute it. Something like the following.

We write a little file called `foo.js` to see if we understand how strings and numbers interact in Javascript:

```
function foo() {
    var addingNumbersToStrings = 1 + "2"
    console.log(addingNumbersToStrings)
}

foo()
```

and we run it like this:

```
node foo.js
```

It will run, and print out "12", and now we're sure we understand how JS works 😉.

But now let's say our job description changes a bit, and we're moved onto a team that's writing Scala. How can we quickly test our assumptions like we did in the example above?

We might reach out for the Scala REPL inside of `sbt`, which works to some degree, but is cumbersome to iterate with, and isn't great for keeping those little tests around, if we want to refer to them later.

But, if we're using IntelliJ with the Scala plugin as our editor (which I think most Scala developers are at this point), here's a handy little tip. Inside of any `.scala` file, we can add an object that extends `App`, and that object will become executable:

```
object UnderstandAddition extends App {
    println(1 + 2)
}
```

IntelliJ will even put a little green triangle in the gutter next to that object, telling us that we can run just that piece, without having to run the whole massive server we're working on.

If we don't see that little green triangle, we can always always right click on the name of that object, and choose to run it from within the contextual menu.

In this case, we'll see the console print out the number "3".

But, let's level up a little bit and turn those experiments into ad-hoc tests:

```
object TestAddition extends App {
    assert(1 + 2 == 3, "Oops, math broke")
}
```

Wow! we've just written a little test inside of our main codebase without having to configure test runners, load assertion libraries, or make new files! And any time we run that class, it will tell us if our assumptions are true or not.

Obviously, for a real test suite we'd want to go to the trouble of configuring a test runner, etc... and hooking up something to `sbt test` so that we can rest assured that all the test in our codebase have been run, and are passing. This little tip is just here to help us spot-test our logic, and iterate our way into becoming proficient in the ecosystem.
1000 Followers.  I am Famous Now, Yes?
Tags: update, feedback
Published: 2018-07-13 20:15:34

---
title: 1000 Followers.  I am Famous Now, Yes?
description: I know it's not that big of a deal, but it's kind of neat!  Give me your feedback!
published: true
tags: update, feedback
cover_image: https://thepracticaldev.s3.amazonaws.com/i/oajtd514f5q7nh1k7bp7.jpg
---

*Photo by Audrey Fretz on Unsplash*

## Woohoo!

I know it's not that big of a deal, but I broke 1000 followers over the weekend!  I'm mostly very surprised that 1000 people thought that they might like to read what I have to write.  But, I'm also feeling pretty good because I've managed to put out *63* posts on Dev.to since I joined in March of last year, which is an average of almost *four per month*.  My initial goal when I started out blogging was to do one every two weeks, and I'm proud that I was able to hold that goal (on average) for over a year.

I think that the Dev.to community is a huge part of why I was able to meet my blogging goals so far.  Every time I post something, I get enough people liking or commenting on it in a meaningful way to give me a boost of endorphins to get to work on the next one.  Even on posts that didn't do that great, like this one:

{% link https://dev.to/rpalo/microdecisions %}

In the whole of last year, I don't think that I've any real negative interactions -- or at least, none that stuck with me strongly enough to remember.

 > No negative interactions on a social media site (on the internet!) in over a year is a *big deal*.  The Dev.to folks are doing a very good job and should feel proud.

## Highlights

In case you missed it, my most popular post was probably this one:

{% link https://dev.to/rpalo/wishful-coding-dpj %}

I give full credit to my dog Willy for that.

I also have to mention my highest-rated comment, which I find really speaks to my intelligent and well-thought-out interactions here:

{% devcomment 2h32 %}

## Now I Need Your Help

That's right, I want to keep pushing forward and meeting my goal.  So, I want to know:

 - Were there any of my posts that you really, really liked?  What about it made you like it so much?
 - Were there any posts that were just the worst?
 - Are there any topics you'd like to see me tackle or that give you difficulties?  Bonus points if these topics are right in my wheelhouse of Python/Ruby/Scripting/Math/Physics/Data.

Thank you all for your support and kind words over this last year.  Hopefully, I can come up with some more posts that are useful and fun to read.  Thanks to the @thepracticaldev team for making such a great platform.

Happy coding!
how to add cover images for dev.to feed entries
Tags: blogging, images, personal, whatevers
Published: 2018-07-13 19:56:25

---
title: how to add cover images for dev.to feed entries
published: true
description: make sure you read the instructions
tags: blogging, images, personal, whatevers 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/u1x7n8mbvor1nq6tcbk0.jpg
---

Just a heads up: if you want to add nice cover images to the articles you post on dev.to, add a **cover_image:** entry to that nice little block at the top. For example, the block for this post looks like this:

```
---
title: how to add cover images for dev.to feed entries
published: true
description: make sure you read the instructions
tags: blogging, images, personal, whatevers 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/u1x7n8mbvor1nq6tcbk0.jpg
---
```

And then you get a nice picture of a huge black hole at the top of your post, and also when folks are browsing through the feeds of dev.to posts.