teleren/devto huggingface dataset:
Adding jemalloc to Rails apps on Heroku
Tags: heroku, rails, bestpractices
Published: 2021-05-25 14:43:00

---
title: Adding jemalloc to Rails apps on Heroku
published: true
date: 2021-05-23 01:46:23 UTC
tags: heroku,rails,bestpractices
canonical_url: https://prathamesh.tech/2021/05/23/adding-jemalloc-to-rails-apps-on-heroku/
---

`jemalloc` is a malloc implementation developed by Jason Evans which is known to improve memory consumption of Rails apps, [especially on Heroku](https://devcenter.heroku.com/articles/ruby-memory-use#excess-memory-use-due-to-malloc-in-a-multi-threaded-environment). By default Ruby uses `malloc` from C to manage memory but it can run into memory fragmentation issues.

Whereas `jemalloc` describes itself as a malloc implementation which tries to avoid memory fragmentation. A [lot](https://dev.to/devteam/how-we-decreased-our-memory-usage-with-jemalloc-4d5n) of [people](https://pawelurbanek.com/2018/01/15/limit-rails-memory-usage-fix-R14-and-save-money-on-heroku/) have successfully tested jemalloc in production apps deployed on Heroku to verify that it reduces memory usage compared to the default memory management that comes with Ruby.

Enabling it in a Rails app on Heroku consists of following steps.

### Add jemalloc buildpack

```
heroku buildpacks:add --index 1 https://github.com/gaffneyc/heroku-buildpack-jemalloc.git
```

### Enable jemalloc 

This can be done in two ways. Either we can set the environment variable, `JEMALLOC_ENABLED` to `true`.

```
heroku config:set JEMALLOC_ENABLED=true
```

Alternatively, we can add `jemalloc.sh` prefix to the processes listed in the Procfile.

```
# Procfile

web: jemalloc.sh bin/puma -C config/puma.rb
worker: jemalloc.sh bundle exec sidekiq -q default -q mailers -c ${SIDEKIQ_CONCURRENCY:-5}
```

> Note that setting the JEMALLOC\_ENABLED environment variable will enable jemalloc for all processes of your app, where as adding `jemalloc.sh` prefix in Procfile can give you control over for which processes you want to enable it.

After this is done, deploying the app on Heroku will enable `jemalloc` and we can monitor the memory consumption.

### jemalloc version

We can choose the `jemalloc` version by setting `JEMALLOC_VERSION` to a version number from this [list](https://github.com/gaffneyc/heroku-buildpack-jemalloc#jemalloc_version). By default, the buildpack chooses the most recent version.

## Conclusion

With just enabling jemalloc, we can see significant drop in memory usage on Heroku without doing any code change. So I highly recommend enabling it in production apps deployed on Heroku.
Class Diagrams Relationships
Published: 2021-05-23 01:46:18

Class diagrams are the main building block in object-oriented modeling. They are used to show the different objects in a system, their attributes, their operations and the relationships among them.

Classes are interrelated to each other in specific ways. In particular, relationships in class diagrams include different types of logical connections. The following are such types of logical connections that are possible in Unified Modelling Language:
* Association
* Composition
* Aggregation
* Inheritance
* Generalization
* Specialization

An example to understand the relationships 
consider a person with his/her gadgets (phones, Laptops etc )

From here we have 2 classes class person and class gadget
when a person charges a gadget that creates an **Association**  between the two classes

**Composition** implies a relationship where the child cannot exist independent of the parent.
Battery is part of a phone 
A phone can't exist without a battery hence that is an example of  composition

 A battery and a phone can however exist independently . This is an example of **Aggregation**
Aggregation implies a relationship where the child can exist independently of the parent
 
**Generalization** is a mechanism for combining similar classes of objects into a single, more general class.
Phones and Laptops are examples of Gadgets .
class phones can be a subclass of class Gadgets
This is an example of Generalization as phones inherit attributes from the super class Gadgets

**Specialization** is the reverse process of Generalization means creating new sub-classes from an existing class hence in the example we could have class phones being created from class Gadgets

**Representation of the relationships**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdi36zgy2g4l2gp9ch7p.png)
Liberar acesso ao servidor SSH pelas chaves do GitHub
Tags: tip, github, braziliandevs
Published: 2021-05-23 00:41:35

Uma das formas mais utilizadas para acessar servidores GNU/Linux é através do [SSH](https://pt.wikipedia.org/wiki/Secure_Shell). Esse acesso pode ocorrer através de usuário e senha ou de um par de chaves criptográfica, normalmente [RSA](https://pt.wikipedia.org/wiki/RSA_(sistema_criptogr%C3%A1fico)) ou mais recente [Ed25519](https://pt.wikipedia.org/wiki/ECDSA), que são chaves assimétricas, onde a chave pública é copiada para o servidor e a privada fica no cliente que está pedindo acesso. Esse processo é o mesmo que ocorre no GitHub para permitir o acesso aos repositórios através de SSH, e é possível se aproveitar disso.

Caso tenha alguma dúvida para criar chaves, ou mesmo queira verificar como configurar o cliente SSH, recomendo dar uma olhada no meu texto sobre [configuração do Git](https://dev.to/acaverna/configuracao-basica-do-git-e-github-55mo).

## Permitindo acesso através da chave

Primeiramente, para permitir o acesso a um servidor por chave criptográfica, basta adicionar a chave pública no arquivo `~/.ssh/authorized_keys`, onde `~` é a home do usuário no servidor ao qual deseja-se permitir o acesso remoto. Desta forma, basta conseguir uma cópia da chave pública para permitir o acesso. Lembrando que o serviço do SSH deve estar em execução nesse servidor (para Debian e derivados basta instalar o pacote `openssh-server`).

## Acessando a chave pública no GitHub

Como a chave pública não é uma informação sensível, e pode ser divulgada, o GitHub lista as chaves públicas cadastradas dos usuários ao adicionar `.keys` ao final do link do perfil. Exemplo: `https://github.com/eduardoklosowski.keys`. Assim ao acessar essa URL será listada todas as chaves públicas cadastradas para a conta, em vez de mostrar o perfil do usuário. Desta forma, basta adicionar essas chaves ao final do arquivo `~/.ssh/authorized_keys` e o dono dessa conta já poderá acessar o servidor.

Esse processo também poderia ser feito através da linha de comando, não sendo necessário copiar e colar as chaves, bastando executar um dos comandos abaixo (de acordo com a ferramenta que estiver disponível no servidor):

```sh
curl https://github.com/eduardoklosowski.keys >> ~/.ssh/authorized_keys
# Ou
wget -qO - https://github.com/eduardoklosowski.keys >> ~/.ssh/authorized_keys
```

## Considerações

Muitos desenvolvedores possuem conta no GitHub, e adicionaram suas chaves públicas a sua conta. Então fazer esse processo permite liberar o acesso a um servidor de forma fácil e segura (desde que o dono da conta mantenha sua chave privada de forma segura). Uma aplicação bastante interessante disso é na criação de servidores para [pair programming](https://pt.wikipedia.org/wiki/Programa%C3%A7%C3%A3o_pareada), onde um servidor pode ser criado e as pessoas que forem programar podem compartilhar o terminal através do [tmux](https://tmux.github.io/), sendo necessário se conhecer apenas o nome de usuário do GitHub, em vez de criar uma senha e compartilhá-la, ou pedir e aguardar a outra pessoa enviar sua chave pública.
A simple way to improve your technical onboarding
Tags: practices, onboarding
Published: 2021-05-27 16:29:45

---
title: A simple way to improve your technical onboarding
published: true
date: 2021-05-23 00:00:00 UTC
tags: practices,onboarding
canonical_url: https://jhall.io/archive/2021/05/23/a-simple-way-to-improve-your-technical-onboarding/
---

Somewhere, long ago, I’ve long since forgotten where, I learned of a technique I like to employ when onboarding new team members, especially into technical roles. It works really well for setting up a development environment, for example, and it goes something like this:

> Welcome to our team! Here’s the onboarding README, which will tell you how to install all the dependencies for your local environment.

Then in the README, you spell out every step needed to set up the environment, with one additional, final step:

> As the last step, edit this README to improve something for the next person who joins.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Configure M1 Mac to use JDK8 with Maven
Tags: maven, jdk8, m1, arm
Published: 2021-05-23 00:28:33

---
title: Configure M1 Mac to use JDK8 with Maven
published: true
description: A guide on how to use Maven with JDK8 on the new ARM based M1 MacBook Pro
tags: Maven, JDK8, M1, ARM
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zk8dli502153rauzgf6i.png
---

Getting started with the new ARM based M1 Macs can be a bit awkward so here is how you get Maven working with JDK 8.

# Install Homebrew
Homebrew is what we will use to install `Maven`. You can instructions on downloading Brew here https://brew.sh/ or by simply running this script in your terminal
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

# Install Maven via Homebrew
Run the following command in your terminal
```
brew install maven
```

# Install ARM based JDK 8 from Azul
We need to get a version of JDK 8 that works on the ARM based M1 Mac, Azul provide just what we need. At the link below, enter the following if the link doesn't populate it for you.

Java Version - Java 8 (LTS)
Operating System - macOS
Architecture - ARM 64-bit
Java Package - JDK

Download the .dmg file here
https://www.azul.com/downloads/?version=java-8-lts&os=macos&architecture=arm-64-bit&package=jdk

Install the .dmg file

# Set JAVA_HOME environment variable
Now you need to set the `JAVA_HOME` environment variable to point at our new JDK 8 install. This is the environment variable that Maven looks for.
To add the environment variable, you need to add it to your zsh profile. This can be done by adding the following line to your `.zshrc` file.
The `.zshrc` file should be located in home directory.
You can navigate to it via 
```
# Navigate to directory
cd ~
# Editing the file
vim .zshrc
```

Add the following line to the file and then save
```
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
```

Now restart your terminal

# That's it!
When running Maven from your terminal then now it will use JDK8
I made an app for Scissors Shogi.
Published: 2021-05-23 00:05:35

## What is Scissors Shogi?
Scissors Shogi is a game played with Shogi tools, using only foot soldiers to remove the opponent's pieces.

See the following link for the rules
https://www.shogi.or.jp/knowledge/hasami_shogi/

## Features
Computer games, online games, and friend games are supported.

## Technology used
The game uses [Phaser3](https://phaser.io/phaser3).
[PlayFab](https://playfab.com/) and [Firebase](https://firebase.google.com/) are used for the backend.

Link
iOS
https://apps.apple.com/app/id1542437319

Android
https://play.google.com/store/apps/details?id=jp.co.kotakestudio.hasami

Web
https://necohasami.com
Web is still only available in Japanese. If there are many requests, we will support English as well!
Oracle Tuxedo MSSQ vs. SSSQ
Tags: oracle, tuxedo, ipc
Published: 2021-11-03 06:24:26

---
title: Oracle Tuxedo MSSQ vs. SSSQ
published: true
date: 2021-05-23 00:00:00 UTC
tags: oracle,tuxedo,ipc
canonical_url: http://aivarsk.com/2021/05/23/mssq-vs-sssq/
---

Servers in Oracle Tuxedo can be configured either in Multiple Servers - Single Queue (MSSQ) setup or Single Server - Single Queue (SSSQ) mode. More in-detail information about SSSQ and MSSQ setup can be found in [my book “Modernizing Oracle Tuxedo Applications with Python”](https://amzn.to/3ljktiH).

When it comes to the performance aspect of these setups, Tuxedo documentation recommends using the MSSQ setup when:

- You have a “reasonable” number of servers (2..12)
- Message sizes are less than 75% or the queue size

The MSSQ setup is discouraged when:

- Message sizes are large and exhaust the queue
- You have a large number of servers

Oracle itself uses SSSQ setup for the [TPC-C](http://www.tpc.org/tpcc/) performance tests where it demonstrated more than 500,000 business transactions/second.

However, this list of recommendations does not take the Operating System into account. One of the Pros for MSSQ can be found in the implementation of the Linux kernel. Calling a service in Oracle Tuxedo results in `msgsnd` system call. And [`msgsnd` has a shortcut](https://github.com/torvalds/linux/blob/master/ipc/msg.c#L931) called [`pipelined_send`](https://github.com/torvalds/linux/blob/master/ipc/msg.c#L808) for sending a message to a queue when there is a process waiting to receive a message. Message can be sent directly to the receiver process instead of being put in the queue. Since the MSSQ setup has multiple servers receiving messages, the fast path will be taken more often and will result in less overhead. It also means that the first message in an empty queue will be delivered faster. As soon as the queue fills up, all new request messages will be stored in the kernel queue and the shortcut will not be taken.
Supercharging Codeigniter 4 http request to another website with curlrequest
Tags: codeigniter4, php, httprequest, curlrequest
Published: 2021-05-22 22:19:30

In this article I will walk you on how I refactor my api request from curl to Codeigniter 4 curlrequest, which in turns gives a more maintainable codes.

##What is Curlrequest in Codeigniter 

The CURLRequest class is a lightweight HTTP client based on CURL that allows you to talk to other web sites and servers. It can be used to get the contents of a Google search, retrieve a web page or image, or communicate with an API, among many other things.

Without much ado let look at the curl library I was using before refactoring.

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://api.example.com");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData)); //Post Fields
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 200);
        curl_setopt($ch, CURLOPT_TIMEOUT, 200);

        $headers = array('Content-Type: application/json', 'Authorization:' . $token);

        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

        $request = curl_exec($ch);
        $result = json_decode($request, true);
        return $result;

Converting this to the curlrequest class, the first thing is to load the class.

      $client = \Config\Services::curlrequest();
     $response = $client->request('POST', 'api.example.com', [
            'json' => $postData,
            'headers' => [
                'content-type' => 'application/json',
                'cache-control' => 'no-cache',
                'Authorization' => "Bearer xxxxxxxx",
            ],
        ]);

##Explanation
On the first line we load the class
the $client->request() accept three arguments, first is the request method which in this case is POST, the url and the third is array where we pass our data.
To read more on visit [Codeigniter 4 documentation](https://codeigniter4.github.io/userguide/libraries/curlrequest.html#loading-the-library) 

##Conclusion
It is obvious that the codeigniter 4 curlrequest class is more concise and readable compare to the traditional CURL Library.

If there is any difficulty, of course you can comment.
$400+ of essential Python programming knowledge
Tags: python, webdev, codenewbie, gamedev
Published: 2021-05-22 22:00:15

![Humble Book Bundle: Learn You More Python by No Starch Press](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pe9zf0z6bi2irchxjfwh.png)

[Humble Book Bundle: Learn You More Python by No Starch Press](https://www.humblebundle.com/books/learn-you-more-python-books?partner=indiekings)

Humble and No Starch Press are bringing you the best and brightest information on Python programming with the newest eBooks bundle! If you’ve always wanted to automate, code, and program your way to a more effective and efficient digital life, eBooks like Python Crash Course: A Hands-On, Project-Based Introduction to Programming, Automate the Boring Stuff with Python: Practical Programming for Total Beginners, and Beyond the Basic Stuff with Python: Best Practices for Writing Clean Code will help you get there!

Your purchase of this bundle will support the Python Software Foundation and the No Starch Press Foundation, so not only will you master your coding skills — you’ll also be supporting two great organizations!

This bundle launched on May 17 at 11:00 am PST and lasts through June 07, 2021. Pay what you want and support charity!
Writing Comments in "multiline" commands in Bash Scripts
Tags: bash, tricks
Published: 2021-05-22 21:54:29

For example, you have the following code:

```
curl https://example.com \
     --request "POST" \
     --data "foo=42"
```

You want to comment on the request argument.
Use next solution:

```
curl https://example.com \
     `# request is HTTP method`
     --request "POST" \
     --data "foo=42"
```
Trying to be productive...
Tags: beginners, html, android, ios
Published: 2021-05-22 21:48:55

Today, I tried to work on developing an Andrioid app only to find out my laptop doesn't support VT-x(whatever that may mean). So, I tried to develop an IOS app. That didnt workout either...so I tried to do an intro to React. My mind was just not grasping it. Maybe I need to read slower? I dont expect to get things right off the bat but at least some comprehension of what is going on. So, now I'm just going to try and watch a review video on HTML and CSS since I haven't touched it in a couple months. I was trying to have a productive day...
Launch of Mastershot V1, a revolutionary browser-based video editor
Published: 2021-05-22 21:35:08

![Mastershot product illustration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8q8n36vjf2tmxi8a6f4.png)
I'm excited to announce that after months of work, I'm finally ready to unveil Mastershot to the world!

Mastershot is a revolutionary browser-based video editor. Now you may be thinking to yourself, "Huh? What's so revolutionary about this? I've seen multiple browser based video editors before" and that's a valid question. The answer is that Mastershot runs completely in the browser, this includes the rendering as well!

The fact that your browser renders the video is important for multiple reasons, the most important of which is speed. With other online video editors, you need to wait for your files to upload before you can start editing your video. With Mastershot, however, you can simply add files to a project and start working immediately!

Another important factor is privacy. With websites being hacked left, right, and center your privacy has never been more at risk. Videos can be extremely private and have devastating effects if leaked. That's why, with Mastershot your files never leave the browser. Ever!

Yet another important aspect is bandwidth costs. In some places that are costs associated with large files uploads/downloads. With Mastershot, these costs are dropped to $0.

Another primary focus of mine was usability. Let's face it, video editing is hard. The interface is confusing, there are millions of little options and buttons that nobody except for the real pros know what they do. With Mastershot, I've distilled the interface down into the most useful functions of a video editor into a simple interface while still allowing for more control if necessary.

And to add the icing to the cake, at this stage, I'm looking for users to get feedback on this first version. So for now, I'm making it available to the public for free!

To summarize a brief overview of what this version contains:

* Trimming audio/video/images
* Combining clips, images, and audio
* Create slideshow from images with music
* Add text to videos and images
* Full HD output resolution
* Extracting audio from any video into a separate track

Check it out at https://mastershot.app. I'm looking forward to hearing what you think about it so don't hesitate to reach out.

Jacob - Founder of Mastershot
Granting Cross-Account Permissions Using Lake Formation and Glue Policy
Tags: aws
Published: 2021-05-22 21:00:28

The Data Lake in the company that I work is managed by AWS Lake Formation, and recently we need to setup a Glue Policy to deny a couple of tables in a specific database, but Lake Formation you don't have this feature yet(Helloooo AWS!!) … Lake Formation have some feature to allow all tables except a few tables, you have the option to allow All tables or each table.

Ok but in my case I (and others too) have a lot of tables, and some of them with overwrite process what cause another issue, the overwrite tables looses their previous granted access, so you need to grant all the access again, and again, this approach is unacceptable.

So our solution was to setup a Glue Policy denying just the couple of tables that we want to deny access, this works seamlessly BUT we have a collateral effect, when you set a Glue Policy and try to do a new Cross Account sharing you need to setup another Glue Policy to allow Cross Account permissions using Lake Formation.

# When Granting Cross-Account Permissions Using Lake Formation ?

If there is no Data Catalog resource policy in your account, Lake Formation cross-account grants that you make proceed as usual. However, if a Data Catalog resource policy exists, you must add the following statement to it to permit your Lake Formation cross-account grants to succeed. Replace `<region>` with a valid Region name and `<account-id>` with your AWS account ID.

```
{
      "Effect": "Allow",
      "Action": [
        "glue:ShareResource"
      ],
      "Principal": {"Service": [
        "ram.amazonaws.com"
      ]},
      "Resource": [
        "arn:aws:glue:<region>:<account-id>:table/*/*",
        "arn:aws:glue:<region>:<account-id>:database/*",
        "arn:aws:glue:<region>:<account-id>:catalog"
      ]
}
```

Documentation link: https://docs.aws.amazon.com/lake-formation/latest/dg/hybrid-cross-account.html
Sync Obsidian Notes with Github Using Windows 10
Tags: bash, productivity, github
Published: 2021-05-22 20:12:43

This post provides the information needed to save your Obsidian notes to Github using a bash script and cronjob for Windows. With this setup you still can author your notes in Obsidian and every hour in the background your changes will be synced with Github. 

To sync Obsidian notes with Github read: 

[How to Schedule task/script in Windows 10 ?](https://dev.to/sunilaleti/how-to-schedule-task-script-in-windows-10-1o40)

[How I Put My Mind Under Version Control](https://medium.com/analytics-vidhya/how-i-put-my-mind-under-version-control-24caea37b8a5)