teleren/devto huggingface dataset:
The Downfall Of Functions And The Rise Of Knative
Tags: serverless, kubernetes, devops
Published: 2019-06-03 06:37:57

---
title: The Downfall Of Functions And The Rise Of Knative
published: true
tags: serverless, kubernetes, devops
canonical_url: https://shamun.dev/posts/2019-06-03_the_downfall_of_functions_and_the_rise_of_knative/
cover_image: https://shamun.dev/posts/2019-06-03_the_downfall_of_functions_and_the_rise_of_knative/images/1.jpeg
---

So maybe the title is a little exaggerating but now you are here and I would like to introduce you to Knative, the Kubernetes add-on for serverless workloads.

First thing first, let's talk about Functions and why they exist. There is an everlasting trend to reduce the overhead of deploying applications.
It started with the transition from on-prem servers to the cloud, to managed services and Kuberentes and now Functions.
With Functions, developers can focus only on their code which will be triggered by an HTTP request or a Pub/Sub message.
They don't have to think about anything else, devops, operating systems, hardware, networking and configurations are things of the past.
Write your code and deploy with a simple command. Sounds good isn't it?
So let me tell you what you cannot do with Functions and why this abstraction is one step too much.
If your serverless task is CPU intensive or requires GPU to serve deep learning models for example, there is nothing you can.
Long tasks? no can do, you are limited by the maximum timeout (9 minutes).
Special networking requirements? guess what… I guess it will improve over time but at least for me I find many use cases which cannot be done with Functions.
Just recently, Google provided VPC access to Functions which really opened it up to new use cases but it is still lacking.
Do not get me wrong there are still many use cases where Functions can shine and really make it easy but you can get to a dead-end pretty soon.

### Enter Knative 🚢

A Kubernetes-based platform to build, deploy, and manage modern serverless workloads.
It is still in early development stages but already offered as a managed service called Cloud Run, still in beta though.
Knative provides the ability to scale a deployment to zero pods and react to HTTP requests and events on demand, just like Functions.
Knative Serving is all about serverless HTTP triggers and Knative Eventing is focused on reacting to events from different sources (such as Google Pub/Sub).
The Eventing project utilizes cloudevents, a spec for defining events, this way you can be agnostic to the event source.
Although it requires a little bit more heavy lifting than actual Functions, such as writing YAML configurations and having a Kubernetes cluster (most of us already have it anyway), it opens you to all Kubernetes goodies.
You can customize whatever you want if you need and still enjoy the serverless world. Again, it is not the same as Functions but for me it makes much more sense and flexibility.
I am only in the beginning of my journey exploring Knative but it surely is exciting!
My Top 5 Music APIs
Published: 2020-03-15 10:20:57

Some music platforms expose their APIs (Application Programming Interfaces) to allow developers to integrate platform's music services into their applications. These APIs enable you to programmatically mine, browse, and enhance the music platform’s data and accomplish various tasks, such as retrieving information about certain albums, getting playlists, or obtaining artists details.

With the extensive availability of music platforms out there, it can be difficult to keep track of the APIs you can use to extend the functionality of your applications. I analyzed several music APIs based on the following four main criteria:

* **API features**: We assessed the astounding features available in each of the APIs.
* **Price**: We looked at the price of using the music APIs.
* **Popularity**: We evaluated the popularity of the music platforms.
* **Ease of use**: We scrutinized the ease of implementing the APIs in applications.

Based on the criteria listed above my top music APIs are:

1. [Last.fm](https://www.last.fm/api/) is a website that has a huge collection of music. It allows users to create their own profiles, track the music they listen to (called scrobbling) and access other exciting services such as personalized music charts, recommendations, and interaction with other music lovers.
2. The [Spotify API](https://blog.api.rakuten.net/top-music-api-spotify-soundcloud-itunes/) and SDK allows you to create amazing experiences for millions of music lovers around the world. With the API, you can read the audio features of songs and analyze their various attributes such as danceability and valence. You can also integrate Spotify music into your application, serve recommendations to users, and search and manage artists, albums, tracks, or playlists.
3. [iTunes Search API](https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/iTuneSearchAPI/LookupExamples.html) enables you to include search fields on your application, where users can search for their favorite content in the iTunes Store or other Apple services. The API is offered to participants in the Apple’s Affiliate Program and allows you to place promotional content on your website, such as previews of music videos, songs, or album arts. If a user clicks on the promotional content and makes a purchase in the iTunes Store, you’ll earn a commission.
4. The [Deezer API](https://developers.deezer.com) enables you to access the platform’s data and escalate the functionality of your application. Some of the data you can access include albums, playlists, radio, artists, track users, comments, search, and editorial.
5. The [SoundCloud API](https://developers.soundcloud.com/docs/api/guide) allows you to create powerful applications that can escalate sound on the web to higher heights. The API provides several endpoints for completing various tasks, including uploading and sharing sound to social online networks, playing sounds, integrating comments, integrating follow and like features, and searching for sounds.
Did Electron just suffer a major setback at WWDC?
Tags: webapp, wwdc, apple, news
Published: 2019-06-03 22:24:48

With the beta of Xcode 11, Apple [made it easy for developers to migrate iPad apps to MacOS](https://developer.apple.com/ipad-apps-for-mac/). Now I don't think this spells DOOM for hybrid web apps made with Electron in MacOS, but it certainly would make me pause at a company where separate teams develop the same product for iPad, but have a different web based implementation for Desktop Mac and Windows. It makes a lot more sense to go native for performance or at the very least develop a PWA. 

As a developer I'm torn. I like the idea of hybrid web apps built with Electron because it's the platform in which I develop, but having so many node processes running on my machine simultaneously can be a burden on performance. This is an unintended consequence of the hybrid web application boom we've had over the past 5 years.

If you run 

```
ps aux | grep node
```

in your Terminal on MacOS you can see all the active node processes running currently. 

If you've got Adobe CC, Slack, or VS Code open there will be a long list of processes running, alongside any node processes you may require for developing a project.

I dunno about you, but I want a speedy machine for developing. I don't need all these other processes running. Except VSCode, which is currently my IDE of choice. There are times extensions can run wild in VSCode, usually after a monthly update and the extension authors have failed to update as well. 

There is nothing wrong with Node.js. The V8 engine is so performant it runs on a Raspberry Pi, quite well in my experience. It's only when several processes start running that performance can suffer. 

It's not like we can use the simplicity argument anymore when the same team could potentially develop an app for the entire Apple ecosystem and in turn get the performance of a native application. Might as well throw out that card.

It may be too early to tell the ramifications of this move by Apple to allow developers to migrate iPad apps over to MacOS, but wondering what you think? Maybe it's finally time to dive in and learn Swift.
TIL: JSON.stringify takes toJSON methods into consideration
Tags: javascript
Published: 2019-06-04 09:01:09

---
title: TIL: JSON.stringify takes toJSON methods into consideration
published: true
tags: javascript
canonical_url: https://www.stefanjudis.com/today-i-learned/json-stringify-takes-tojson-methods-into-consideration/
---

I was reading [this great article on `JSON.stringify`](http://thecodebarbarian.com/the-80-20-guide-to-json-stringify-in-javascript.html) by [Valeri Karpov](https://twitter.com/code_barbarian) when I discovered something I didn't know before.

You can use `JSON.stringify` to serialize objects and store them let's say in `localStorage`. It turns out that `JSON.stringify` checks if the object to serialize includes a `toJSON` method. If it does it will use this method to evaluate the result of the serialization. 

```javascript
const zoo = {
  animals: {
    list: ['cat', 'dog', 'duck'],
    // toJSON will be called by JSON.stringify
    toJSON: () => {
      return ['🐱', '🐶', '🦆']
    }
  }
}

console.log(JSON.stringify(zoo, null, 2));
```

By including a `toJSON` method you can manipulate the data that should go into serialization. You can use this functionality to e.g. clean up logs and not store sensitive information in a database. Pretty sweet. 👌

![Result of the logged object printing emojis instead of animal names](//images.ctfassets.net/f20lfrunubsq/6L35ZznZmar8feyRjVpm3N/dfaede58c11d8d930ab38b608600bcd1/Screenshot_2019-06-04_at_10.14.56.png)

If you want to learn more you can check [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description) or have a look at [a  chapter of Exploring JavaScript](http://exploringjs.com/impatient-js/ch_json.html#example-converting-to-and-from-json) written by [Axel Rauschmayer](https://mobile.twitter.com/rauschma).
Test Liquibase migration changes in the local environment using Docker
Tags: liquibase, docker, migration, postgresnewbies
Published: 2019-06-05 09:46:02

---
title: Test Liquibase migration changes in the local environment using Docker
published: true
description: Found out how easily we can test our schema/database changes using liquibase and docker-compose. 
tags: liquibase, docker, migration, Postgres-newbies
---

I am publishing this article because recently found out we had problems in the pre-live environment related to some liquibase migration issue.

Then I was thinking maybe this could be because of not testing properly in our local environment or not knowing how to do testing itself. 

Unfortunately, some commands use java-maven, but I am sure there are alternatives for these statements.

Maybe the following could help someone :)

#Prerequisites :

 - Docker

#Steps to do:

 - Docker-compose file content can be copied from here - https://hub.docker.com/_/postgres
 - `docker-compose up` - Runs a container with Postgress DB running inside
 - `docker ps` - Lists the container details
 - Do an export of schema from prelive or test environment.
 - `docker exec -it {replace_with_container_id} bash` - You can login to the container and import the exported schema.
 - From your local, open `changelog.xml` and comment out changes other than yours.
 - Change liquibase configuration inside pom.xml to local postgres configuration.
 - Run the command `mvn liquibase:update` to see your changes being applied.
 
#Tips for postgres newbie:

Once you login to the docker container using STEP-5 mentioned in Steps to do,

- execute command `psql -U postgres` - "postgres" is the username used in the docker-compose content.

- \c {db_name} - connect to a db

- \dt - show tables in that database

- \d {table_name} - describe table


Thank you for reading and I am happy if I could help someone.
Using "Reload" options in Chrome
Tags: chrome, devtools
Published: 2019-06-06 07:29:41

---
title: Using "Reload" options in Chrome
published: true
description: Using Reload options in Chrome when using developer console
tags: #chrome #devtools
---

One of the most popular browsers with the best debugging tools is Google Chrome. When working with CSS or JS, the dev tools in chrome are of great help. Chrome definitely makes the dev work easier. On the same lines, while working on the front end things and editing CSS or JS, refreshing is one of the things we are ought to do.

Let us explore what chrome offers on this little but very important thing.

Whenever you are working chrome, try this:
1. Press F12 and open the developer tools.
2. On the refresh button, on the top left of the browser window, do a right click.
3. You will see three options.
![Reload options](https://thepracticaldev.s3.amazonaws.com/i/m14ctiys6udawaywkjbm.png)

## Normal Reload
This is as good as clicking the refresh button or pressing F5.
This will use the cache but re-validate everything during page load. The browser will avoid re-downloading cached JavaScript files, images, text files, etc.

## Hard Reload
In this option, the browser will not use anything from the cache when making the request. This can also be done using Ctrl+Shift+R option we don't need to open the Developer Console for this. This forces the browser do re-download every JavaScript file, image, text file, etc. Here the cache will still remain as is.

## Empty Cache and Hard Reload
Use this option if the cache is to be emptied and we want the page to be hard reloaded. Note that here, the browser's cache will not be cleared, it is the page cache which will be cleared. This will force the browser to re-download everything with respect to the page.
This is the best option to use if you really want to reload a web page completely.
Introduction to Angular 7 Observables
Tags: ionic, angular, observables, rxjs
Published: 2019-06-06 18:49:34

---
title: Introduction to Angular 7 Observables
published: true
description: This tutorial will help you master Angular 7 Observables through three simple examples.
tags: Ionic, Angular, Observables, RxJS
---
Read at - https://www.javascripttuts.com/introduction-to-angular-2-observables/
Building a Python wrapper of C libgeohash using CFFI
Tags: python, cffi, geohash
Published: 2019-06-08 03:46:38

---
title: Building a Python wrapper of C libgeohash using CFFI
published: true
description: Notes 
tags: #python, #cffi, #geohash
cover_image: https://aldnav.com/img/geohash-preview.png
---

First post for DEV.TO 🎊️

I didn't know what a [Geohash](http://geohash.org) is before and was blown away by it's concept. I found an implementation of it written in C. Well I always have been wanting to experiment with foreign functions and found [CFFI](https://cffi.readthedocs.io) suitable for my case. On that same afternoon I wrote a simple wrapper of libgeohash in Python.

Check this out! https://aldnav.com/blog/writing-a-geohash-wrapper-using-cffi/
What's that? Want to jump in to the source code instead? Ok! https://github.com/aldnav/geohash

Here's a preview.

```python
# geohash_build.py
from cffi import FFI
ffi = FFI()
ffi.cdef(
    """
    char* geohash_encode(double lat, double lng, int precision);
    GeoCoord geohash_decode(char* hash);
"""
)
lib = ffi.dlopen("geohash.so")
ffi.set_source("_geohash", None)
```

```python
# Simple testing
from _geohash import ffi, lib
print(lib.geohash_encode(35.689487, 139.691706, 6))
#>> xn774c
```
```python
# Use geohash module
import geohash
geohash.geohash_encode(48.856614, 2.352222)  # u09tvw for Paris! 
geohash.geohash_decode("wy7b1h")  # lat: 35.179554, long: 129.075642
```

Check my notes to see how I build the wrapper. Plus some more references that links to more comprehensive notes from the respective authors.

Let me know your thoughts!
Snake by Hack the box - My writeup
Tags: hackthebox
Published: 2019-06-08 06:41:04

## Disclaimer
If you're uncomfortable with spoilers stop reading now.

## Challenge

While waiting for [SwagShop](https://www.hackthebox.eu/home/machines/profile/188)'s takedown in order to publish my writeup, I took a chance to solve a couple of challenges available on HackTheBox, starting from Snake.

Snake is a reversing challenge by 3XPL017, you can find it [here](https://www.hackthebox.eu/home/challenges/Reversing).

After downloading and unzipping the archive with the password provided we're presented with a Python script named *snake.py*, we'll try and run it:

![Script running](https://imgur.com/07fOOYr.png)

After assigning us a random number is asks for a username and a password, we'll dig into that by taking a look at the code.

![Script code](https://imgur.com/rCzLtEc.png)

We can notice that there are a lot of variables declared, the one which stands out is *slither* since it seems to be the one required in order to be properly identified when prompted for the username.

```
if user_input == slither:
    pass
```

Therefore we can add:

```
print slither
```

In order to print the variable slither, which is the needed username. The script part will look like this:

![Script code](https://imgur.com/NqVSRMQ.png)

Once we run it we get:

![Script code](https://imgur.com/Jm9ktZt.png)

Yes, *anaconda* makes sense and it is indeed the needed username. 

Let's move on to the password, which is generated by this part of the script:

![Script code](https://imgur.com/PVqFSSa.png)

We can see that *passes* is compared to *(chr(char))*

Functions:
- *str()* – returns a string
- *chr()* – returns a character, after that takes in a parameter of a unicode digit

Variables:
- *char* – one element in the array chars
- *chars* – initialized as an empty array

The array chars contains:

```
chars = []
```

And:

```
for key in keys:
    keys_encrypt = lock ^ key
    chars.append(keys_encrypt)
for chain in chains:
    chains_encrypt = chain + 0xA
    chars.append(chains_encrypt)
```

There is also a *break* which terminates the loop even if a single character matches the user given input.

The simplest way to solve this is to print the characters before being asked for the password, we can do this by modifying the script:

![Script code](https://imgur.com/PhNT3CP.png)

And, if we run it we get:

![Script code](https://imgur.com/cZLmLM2.png)

The password is working, and due to the fact that *keys* contains the first 10 characters of the password, we can assume we need to enter them in order to properly solve the challenge.

The flag format is *HTB{user:password}*, so the proper way to enter it is *HTB{anaconda:udvvrjwa$$}*.

Solved!
React Native Create Animated Accordion Panels using Layout Animation
Tags: reactnative, android, ios, javascript
Published: 2019-06-08 17:04:55

---
title: React Native Create Animated Accordion Panels using Layout Animation
published: true
description: React Native Create Animated Accordion Panels using Layout Animation
tags: #reactnative #android #ios #js
---

Source : <a href="https://www.skptricks.com/2019/06/react-native-create-animated-accordion-panels-example.html" >React Native Create Animated Accordion Panels using Layout Animation </a>

This tutorial explains how to create animated accordion panel layout in react native application. Accordions are useful when you want to toggle between hiding and showing large amount of content. Accordion panels are automatically controlled by itself and if user clicks on single panel then it will smoothly slide down and open itself but if you have clicked on any closed panel then it will first close the already open panel and then open the clicked panel using animation. We are using React Native’s Layout Animation to to open and close the panel.

<img src="https://1.bp.blogspot.com/-cx5abLUJKv4/XPdQQUfn1pI/AAAAAAAAC8Q/Pxfl8O_E5kk2ExVbEysHeyRuxD9Bqp8jACLcBGAs/s1600/react-native-create-animated-accordion-panels-example.jpg" />

<a href="https://www.skptricks.com/2019/06/react-native-create-animated-accordion-panels-example.html" >Click Here to read more...</a>
Hello, me again. HTML5 Up design just hit the Full-Stack level  
Tags: html5up, opensource, appseed
Published: 2019-06-08 19:12:27

---
title: Hello, me again. HTML5 Up design just hit the Full-Stack level  
published: true
description: Apps crafted by HTML5 Up, coded as Full-Stack apps 
tags: html5up, opensource, appseed
---
Hello, 

I'm a huge fan of [HTML5 Up](tutorial) and based on this I've coded some free apps on top. Here is the list:

[HTML5 Up Apps coded Full-Stack](https://appseed.us/apps/html5up)

![Solid State - HTML5 Up, coded in Full-Stack](https://raw.githubusercontent.com/app-generator/flask-solid-state/master/screenshots/flask-solid-state-content-image.png) 
 
Happy coding!
Automate Git With Hooks And Husky 🐺
Tags: git, javascript
Published: 2019-06-09 10:59:29

---
title: Automate Git With Hooks And Husky 🐺
published: true
description: Git provides an interface to run some code as reaction on specific triggers. Those triggers are called githooks (hooks used by git). You can run code on every commit, push, pull or other actions. 
tags: git, javascript
---

Git provides an interface to run some code as reaction on specific triggers. Those triggers are called githooks (hooks used by git).

You can run code on every commit, push, pull or other actions. Hooks are programs you can place in a hooks directory to trigger actions at certain points in git’s execution.

* [Githooks documentation](https://git-scm.com/docs/githooks)
* [Husky repo](https://github.com/typicode/husky)
* [Githooks website](https://githooks.com)

[Article for this video](https://maksimivanov.com/posts/git-husky/)
Your First Haskell Function
Tags: haskell, programming, computerscience, beginners
Published: 2019-06-11 22:20:25

---
title: Your First Haskell Function
published: true
tags: Haskell, programming, Computer Science, beginners
canonical_url: https://lautarolobo.xyz/blog/first-haskell-function/
description: Let's write your first Haskell function, and test it!
series: Haskell
---

Your first Haskell function. Who would say that you would come this far, ah.

A function takes some parameters and shows up an output, after a computational process that used the parameters in some way.

The function that we are going to define today, since it’s the first one, will be basic. You will give it two numbers and it’ll sum them, giving you back a single number. But, what kind of number? Any number? Actually not, this function will work with just Integers. You will clarifiy this by writing the _type_ of the function.

The first thing that you should know about writing functions in Haskell, is that you should always define the type of the function before you define the function itself, if you don’t define it, Haskell will figure out which type is the best to match with your function, most of the time it will figure it out right, but some times may miss match the inferenced type and your function won’t work.

```haskell
sumBoth :: Int -> Int -> Int
```

We defined the type; it takes one Integer, then another Integer, and the output will be an Integer, great. You may have noticed that I named the function “sumBoth”, this is because it’s important that the function’s name tells you what that particular function does and also, the name should be short, so when you call it you won’t waste much time writing it. It may seem a silly advise but trust me, getting used to good practices will save you tons of bugs.

Now, the function definition:

```haskell
sumBoth x y = x + y
```

And that’s it! Now save your file with _.hs_ extension, and then open up the terminal, we will test this function there. Go to the directory where you saved your file and simply write

```
ghci
```

You’ll see something like this:

```
GHCi, version x.y.z: http://www.haskell.org/ghc/ :? for help
Prelude>
```

There write

```
:load filename.hs
```

And this should show up:

```
[1 of 1] Compiling Main ( filename.hs, interpreted )
Ok, modules loaded: Main.
*Main>
```

Then call sumBoth and in the line below you’ll see the result:

```
*Main> sumBoth 5 4
9
```

* * *

Something went wrong? Write it down below in the comments and I'll be glad to help you out!

Want to try the next level? [Go ahead!](https://lautarolobo.xyz/blog/recursive-function-haskell)