teleren/devto huggingface dataset:
Create light weight api server using Spark Java
Tags: rest, api, server, sparkjava
Published: 2017-09-05 13:48:59

---
title: Create light weight api server using Spark Java
published: true
description: Create a light weight backend for mobile developers    
tags: rest, api, server, spark-java
---

Hi everyone,

As a mobile developer, one problem i faced a lot is `server not ready`.
Alternates are available to build api-server, our goal is create light weight api-server, our main purpose is to create minimal usable server which we are not going to deploy anywhere. 
So we will focus on Spark Java(http://sparkjava.com).

We will try to create a small twitter like api-server using spark java.

Lets get started:

We will use Intellij IDE for creating our api-server application(i still like full `application` instead calling it as `app` :heart: )

* File->New Project->Maven
* Create from archtype->maven-archtype-quickstart
* Fill in group-id and artifacts details then proceed
* Let other defaults be as it is
* Name project


After all these you will be presented with ready to use maven project,
add a run configuration using App class having main method and press play button app should print `Hello World!` thats our maven project created.


Add some server code to it.

To use spark java we first need to add spark-java dependency to maven(pom.xml) file.

Lets move ahead to http://sparkjava.com/documentation
copy maven dependency and paste it inside dependencies tag in pom.xml

here is how it looks as of writing this article:
```xml
<dependency>
    <groupId>com.sparkjava</groupId>
    <artifactId>spark-core</artifactId>
    <version>2.6.0</version><!-- check for the updated version from documentation -->
</dependency>
```

`spark.Spark` class has all the necessary stuffs to get started with HelloWorld api.

add these lines to main method:
```java
Spark.get("/sayhello", (request, response) -> {
            return "Hello buddy!!!";
});
```

Save and run the application then launch `http://localhost:4567/sayhello` on your browser, it should respond `Hello buddy!!!`

Congrats you just created a very tiny server-application.

Thats it for now, in the next section we will configure our application to behave more like an api-server intead of hello world.

Thank you for reading.
Configuring for Log Levels & Observability
Tags: logging, observability, debugging
Published: 2017-09-05 10:33:44

---
title: Configuring for Log Levels & Observability
published: true
description: Thoughts on improving log configurations
tags: logging, observability, debugging
---
In the old days, we debugged with console output, logs, and god-knows what other poor tools we had back in the stone age. But having to suffer through this, we learned some good lessons and had some good ideas.

One dearest to my heart as a developer, debugger and ops guy is logging. Most programs log things somewhere, usually to a single log, usually at a single log level, i.e. the log you get is all you’re gonna get; and is probably both too much and too little.

With today’s log and observability tools like Honeycomb.io, ELK, Sumo, etc. of course you can handle, search, and tag a lot more, but this is not unlimited, especially for debugging levels and across networks — you simple cannot send all your debug logging at scale to Sumo Logic. You need more granularity, and ways to change it easily.

The first step people took to improve this was adding log levels, following the the usual hierarchy of INFO, WARNING, ERROR, DEBUG and so on. This helps, much more so if you can change it while the darn system is running (critical on larger, more mission-critical stuff). Store this in your R`edis cache and let admins change at run-time

Next was to add more complex filters and configs with tools like log4j and its clones across various languages. This helps, though often involved complex config files and requires restarts, plus really thinking in advance of what to log where, in what subsystems, what log4j configs, etc. Some of this is fixed now with logstash and external senders, but still messy to me.

I was always more interested in dynamic per-module logging via flags and log levels, because I want the logs I want, when I want them, and not more.

For example, usually I’m mostly interested in a single module or issue, so what I really want is to have ERROR debugging on most stuff, but DEBUG on my code.

This can be done a variety of ways, but we’d often re-use the existing single log level directive with a more complex config line, something like this:

DEF=1:SECURE=2:NET=2:RULES=5

Which means default is low level 1, security and networking at 2, and my rule module at level 5. Very simple; easy to parse, etc. You can even use sub-sub systems, like “Rules/Evaluator=5 to be more specific.

In your code, there’s no need for If-then/Macro logic (just like using log4j, etc.), so you just send send everything to the logger, tagged with its log level and module name (via introspection or other language-specific magic).

Then in the logger, you check the module and log level tag and emit what the configuration calls for. You can always spice this up with different configs by channel, e.g. what to send to standard out vs. syslog vs. to the DB, etc.

That’s it. Too bad I almost never see this in any of the hundreds of tools and systems I’ve run over the years, including a long list of current ones I’d love to have this included in.
Hi I'm Paul!
Tags: introductions
Published: 2017-09-05 06:38:04

---
title: Hi I'm Paul!
published: true
description: My introduction
tags: #introductions
---
Hi Everyone!

I've been professionally coding for 3.5 years in QA Test Automation but have done manual QA for 10+ years.

You can find me on GitHub as [pnaranja](https://github.com/pnaranja)

I live in the San Francisco Bay Area

I currently work for [Chegg](https://www.chegg.com)

I mostly work with Java and Python

Currently interested in learning Functional Programming.  Have played around with Clojure, Elm, Haskell, and Rust
Fastlane Supply uploads everything!
Published: 2020-09-16 01:31:45

---
title: Fastlane Supply uploads everything!
published: true
date: 2017-09-05 00:00:00 UTC
tags: 
canonical_url: https://luisramos.dev/fastlane-supply-uploads-everything
---

Ever since I found out about [`fastlane`](https://fastlane.tools/), I've been using it to deploy Android and iOS apps. It's amazing how streamlined things can get: it saves you a bunch of time when deploying a release; it supports integrations with your favourite distribution platforms (yay Crashlytics); and you can easily copy the setup from one app to the other! Couldn't be happier with it.

Here's a tip for the Android devs out there using [`fastlane`](https://fastlane.tools/), add this to your `before_all` step:

```
before *all do
  sh "rm -f ../app/build/outputs/apk/*/\_/\*.apk"
end
```

I've found that when deploying Android builds using `supply`, the tool tries to upload whatever it can find in your `build/outputs` folder. And often the error you get are unrelated like:

```
Google Api Error: apkUpgradeVersionConflict:
APK specifies a version code that has already been used.
```

This is obviously not true if you check your google play console and your build.gradle file. Looking at the output the (at the `GRADLE_ALL_APK_OUTPUT_PATHS` variable), it seems supply is trying to upload every apk he finds, including debugging version and other flavors. Adding that line will save you some time and stop you from screaming "Why don't the versions match??"
Mapping Categories and Tags with Hexo
Tags: hexo
Published: 2018-02-10 22:37:18

---
title: "Mapping Categories and Tags with Hexo"
published: true
tags: hexo
canonical_url: https://techblog.djs-consulting.com/2017/mapping-categories-and-tags-with-hexo.html
---

The DJS Consulting Tech Blog moved today from [Jekyll](//jekyllrb.com "Jekyll") to [Hexo](//hexo.io "Hexo") (and it’s now [open source](//github.com/danieljsummers/techblog.djs-consulting.com "DJS Consulting Tech Blog • GitHub") as well). One of the final issues I had when wrapping up the conversion was how to handle categories and tags that do not necessarily have a slug that can be naturally derived from the name. Take the “C# category, for example. The normal slug for that category would be `c`, which is an entirely different programming language; interestingly, “C++ will also normally get its slug as `c`.

Within Hexo’s default `_config.yml` file, there are two empty items named `category_map` and `tag_map`; their comments allude to a mapping, but I could not find what the proper syntax was for those items. We hopped onto the Hexo [Gitter](//gitter.im "Gitter") chat and asked the question, and someone pointed us to [this issue](//github.com/hexojs/hexo/issues/908#issuecomment-62913729 "Hexo category\_map Issue"). To define a mapping, create an item under either the `category_map` or `tag_map` top-level item. The maps for this site, as they currently are, look like this:

```yaml
category_map:
  C++: c-plus-plus
  C#: c-sharp
  .NET: dot-net
tag_map:
  c#: c-sharp
  .net: dot-net
```

As you can see from the links in the sidebar (on the blog itself), “Programming \> .NET \> C# ends up with a URL ending with `/programming/dot-net/c-sharp/`, which is exactly what we were looking for.



_This post was originally published on [techblog.djs-consulting.com](https://techblog.djs-consulting.com/2017/mapping-categories-and-tags-with-hexo.html)_
Can we ship mobile apps that are not monolithic?
Tags: discuss, reactnative, ios, android
Published: 2017-09-04 23:17:21

---
title: Can we ship mobile apps that are not monolithic?
published: true
description: Is there a pattern for creating micro apps and combining them into one shippable mobile application?
tags: discuss, react-native, ios, android
---
It's common in web applications to serve several small applications, combined through domain routing, to a user as a single service. I could have separate application for login, profile management, and chat being served as:
- www.website.com/login
- www.website.com/profile
- www.website.com/chat

It's a trivial example, but it serves its purpose. To the user, it's one website, but for developers, it's several small applications. This comes with plenty of advantages that mostly boil down to having a small codebase.

I'm beginning mobile development (react-native) and wondering if this pattern has found it's way into that environment? My hunch is "no" due to the type of deliverable. A mobile application is delivered as one thing to an app store where a website can be "composed" through URL mapping, but I also know developers are smart and I could be totally wrong.
Thread for finding co-authorship/editor
Tags: introductions, learning, tutorials, meetup
Published: 2017-09-04 19:53:07

---
title: Thread for finding co-authorship/editor
published: true
description: This thread is open for everyone who wishes to find collab to write a great article on dev.to
tags: introductions, learning, tutorials, meetup
---
![Storm is coming](https://thepracticaldev.s3.amazonaws.com/i/0hjfsegs4pceizu32xzj.JPG)


I want to write an article on Dev.to. My interest are vast and experience is diverse, however I never was a "real" IT person. Doing a little bit Python, a little bit Rails. However, I have done few things that I'd like to share and on which I'd like to get feedback, mainly around development and management of medium-scale storage system for research lab. As you can imagine, it is not trivial to manage flow of 10s of TB of data monthly, but I think we got a grasp of core principles.

However, I am not sure I can write about this journey myself. So I would like to find a co-author or maybe editor, someone who will be at least a "rubber duck" to bounce my original idea off. Or maybe someone who would ask me good questions, pay attention, and maybe give a great advice.

So this thread represents an opportunity for people like me to find collaboration on Dev.to writing. Comment with your proposal ("i want to write about X" or "i want to help writing about X"), and maybe someone knowledgeable will connect with your idea.

I see several reasons why that might be useful:
 - you will write better
 - you will write faster
 - you will learn something new
 - maybe writing such an article will be a tutorial/teaching exercise
 - maybe you will find friends

So I'll start
An introduction to Puppeteer and Headless Chrome
Tags: chrome, testing, javascript
Published: 2017-09-04 18:48:29

---
title: An introduction to Puppeteer and Headless Chrome
published: true
description: Headless Chrome is a newly released feature in Google Chrome. Learn what it is and how you can use it!
tags: Chrome, Testing, JavaScript
cover_image: https://thepracticaldev.s3.amazonaws.com/i/zqix4pil4i9vfc0h6fz4.png

---
[Headless Chrome](https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md) is a newly released feature in Chrome 59 (Linux and Mac) and Chrome 60 (Windows). It allows for programmatically testing a website without launching a browser window, thus making automated tests far easier, which in turn gives you more confidence to change your app without breaking anything.
##First of all, what is 'headless'?
Headless basically means 'without a GUI', which means in Chrome's case you'd be working with a programmable API, not with a GUI that you can interact with. A good example of Headless mode is when you're dealing with servers using SSH, and doing all the interactions using shell commands.
##Making use of Headless Chrome with Puppeteer
[Puppeteer](https://github.com/GoogleChrome/puppeteer) is an npm Package made by the Chrome team to easily interact with Headless Chrome with a convenient, high-level API.
It is a newly released module that is very similar to PhantomJS or Selenium, but it differs by using the latest versions of Chrome and using headless mode as a default.
##What kind of tests can you run with Headless Chrome and Puppeteer?
A good use case for Puppeteer is automated tests for your UI, by taking screenshots of it or exporting it to a PDF.
Since headless Chrome gives you the ability to do anything a normal browser can, you can use it to automate an entire use case of your system (End to end tests). For example, user log-ins, form submissions, button clicks, page navigation, and more.
You can also use Puppeteer to periodically scrape websites, and store the relevant info you want to extract in a database, which is similar to what you could do with Python's [Beautiful Soup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/) package.
##Wrapping up
All in all, Puppeteer is a package that allows you to deal with web pages programmatically in an automated fashion, whether it is to take screenshots of a web page, or exporting it to PDFs, or clicking buttons and filling forms, or extracting/scraping the content of pages for later inspection. It offers you a very powerful API that allows you to do whatever you can do in a full-fledged browser, without needing the browser.
If you're interested and want to know more about Headless Chrome, check [this article](https://developers.google.com/web/updates/2017/04/headless-chrome) out.
If you want to see examples of how to use Puppeteer, check [here](https://github.com/GoogleChrome/puppeteer/tree/master/examples).
Custom Template Tags in Django
Tags: python, django
Published: 2017-09-04 16:12:23

---
title: Custom Template Tags in Django
published: true
description: How to begin and use custom template tags in Django?
tags: python, django
cover_image: https://www.djangoproject.com/s/img/logos/django-logo-negative.png
---

## Template Tags

Django has this amazing feature of templating static HTML files to serve them as dynamic pages. If I want to add a title to my web page.

```html
....
<title> Homee </title>
....
```
But what if I want to add different titles for different pages? Like **Home** for home page and cart page as **Cart**.

So for this we use template tags already defined in Django. I use
```
{% block title %}
<title>Home</title>
{% endblock %}
```
for replacing title blocks in each page extended from a base template with a blank title block like this
```
{% block title %}
{% endblock %}
```
using another pre-defined template tag
```
{% extends 'base.html %}
```

## How to create one?

Well now sometimes these predefined template tags are not well enough to solve your problem together. Say you want one tag which can give you the modulo of the number of elements in a passed object and any integer. This can be useful if you want different column offset in bootstrap according to the number of elements.

These are the few steps you must follow:- 

- Create a **templatetags** folder in one of the app which is in INSTALLED_APPS arrray in settings file of the project
- Create a blank **__init__.py** file inside *templatetags* folder o make Python treat the directories as containing packages.
- Create the custom tags file such as **custom_tags.py**
- Inside that, we have to write function for our custom template tag

```python
from django import template

register = template.Library()

@register.filter
def remainder(value, arg):
    return value % arg
```

Here we registering a custom tag with name remainder which takes value and arg from template like this
```html
{{ value|remainder:arg }}
```
and returns the remainder.

## How to use it?

First, we have to load the custom tag. And then we can use them as we want. I am checking the number of coins is even or not.
```html
{% load custom_tags %}
...
...
{% if coin|remainder:2 == 0 %}
<p> You have even number of coins </p>
{% else %}
<p> You have odd number of coins </p>
{% endif %}
...
...
```
This is a very simple example of using custom template tags. You can read the full documentation of Django [here](https://docs.djangoproject.com/en/1.11/howto/custom-template-tags) regarding this topic to get some more advanced idea of how to use template tags.


|Liked my post?|
|---------------|
|  [![](https://thepracticaldev.s3.amazonaws.com/i/lsfkqfysa58u59627uy6.png)](https://ko-fi.com/A0A5WBC1)|
Includes() vs indexOf() in JavaScript 
Tags: javascript, arrayprototype
Published: 2017-09-04 06:40:28

---
title: Includes() vs indexOf() in JavaScript 
published: true
description: 
tags: #javascript #Array.prototype
---

ES2016 Specifications included theÂ  `includes()` methodÂ  forÂ  Array data structure.Â The `includes()` method check if an array includes a certain element, returning `true` or `false` as appropriate.
But in ES5 we are used to performing operations like this with `indexOf()` method.

Using `includes()` method.

```javascript 
const array = [1,2,3,4,5,6];

if(array.includes(4) ){
console.log("true 4 was found in the array")// true 4 was found in the array
} 
```

Let's perform the same operation with `indexOf()` method.
```javascript 
const array = [1,2,3,4,5,6];

if(array.indexOf(4) > -1 ){
console.log("true 4 was found in the array")// true 4 was found in the array
}
```


Using `includes()` method to check for `NaN` 

```javascript 
Â constÂ  array = [NaN];

if (array.includes(NaN)){
console.log("true. NAN was found in the array");// true. NAN was found in the array
}
```

This is where things begin to fall apart with `indexOf()` method.

```javascript 
const  array = [NaN];
if (array.indexOf(NaN) == -1){
	console.log("NaN not found in the array");//NaN not found in the array
}

```

Checking for `undefined` with the `includes()` method.

```javascript 
const array = [, , , ,];

if(array.includes(undefined)){
console.log("true array elements are undefined");// true array elements are undefined
} 
```

Let's see how `indexOf()` method will handle this operation.

```javascript 
const array = [, , , ,];

if(!array.indexOf(undefined) == -1 ){
console.log("true. array elements are undefined");
}else {
console.log("Sorry can't find undefined");// Sorry can't find undefined
}
```
The `includes()` methodÂ  does not distinguish between -0 and +0

```javascript 
const a = [-0].includes(+0);
console.log(a);//true
```

Typed Arrays will also have a method `includes()`

```javascript
let array = Uint8Array.of(2,6,4);
console.log(array.includes(4));//true
```

### Summary  

- The includes method finds *NaN* and *undefined*  whereas the indexOf method doesn't.
- The includes() methodÂ  does not distinguish between -0 and +0(This is not a bug, but clearly how javascript works. [Check javascript Number type](http://speakingjs.com/es5/ch11.html#two_zeros))
- Read more from [MDN about Array.prototype.includes()](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)
Building a document management software: how to choose the best OCR library
Tags: appdev, programming, softwaredevelopment
Published: 2017-09-04 15:01:38

---
layout: post
title: "Building a document management software: how to choose the best OCR library"
published: true
tags: appdev, programming, softwaredevelopment
cover_image: "https://thepracticaldev.s3.amazonaws.com/i/ooju22pj80xy8ugehzqw.jpg"
---

In this post, I will share the experience of our company in choosing an OCR library that suits best for solving our tasks and goals. 

As we needed to improve document management within our company, notably to automate the process of enterprise paper records analysis, we decided to create a software solution based on one of OCR libraries.

OCR, or </span><a href="https://gist.github.com/githubutilities/b6a9062c27f43cc52d60"><span style="font-weight: 400;">optical character recognition</span></a><span style="font-weight: 400;"> , is a mechanical or electronic conversion of images of typed text into machine-encoded text.

OCR also represents a method of digitizing a printed text so that it can be electronically stored, edited, displayed, and used in machine processes like cognitive computing, machine translation, and data mining. 

What’s more, OCR is applied as a form of information entry from paper documents (including financial records, business cards, invoices, and a lot more).

Before starting the development process, we made a research on the three most popular OCR libraries in order to determine the one that would suit our goals best.



<h3>We investigated the following libraries:</h3>
 

1. Google Text Recognition API
2. Tesseract
3. Anyline



<h3>Google Text Recognition API</h3>

 
Google Text Recognition API is the process of detecting text in images and video streams and recognizing the text contained therein. Once detected, the recognizer determines the actual text in each block and segments it into lines and words. 

The Text API detects text in multiple languages (French, German, English, etc.) in real-time.

One should note that in general Google Text Recognition API was effective for solving our tasks. We received the ability to recognize text both in real-time and text documents’ ready images. 

During our research, we defined some pros and cons of using Google Text Recognition OCR library.
 

<b>Pros:</b>

- Ability to recognize texts in real-time
- Ability to recognize texts from images
- Small library size 
- High recognition speed
 

<b>Cons:</b>

- A large size of files with training data (~30Mb)

&nbsp;
Learn more about <b></span><a href="https://smartym.pro/blog/developing-a-document-management-solution-how-were-choosing-between-google-text-recognition-api-tesseract-and-anyline-ocr-libraries/"><span style="font-weight: 400;">OCR libraries, their investigation, check out their comparison.</b></span></a><span style="font-weight: 400;"> 
&nbsp;