Skip to content

Instantly share code, notes, and snippets.

View heridev's full-sized avatar
Exploring GraphQL with the Github explorer

Heriberto Magaña heridev

Exploring GraphQL with the Github explorer
View GitHub Profile
heridev /
Last active March 20, 2024 21:39
How to create your own HTTP API client gem in Ruby
heridev /
Last active March 29, 2024 21:53
How to access request headers in a Rack middleware application? (Rails, Sinatra, etc)

In a Rack-based application, including frameworks built on top of Rack like Ruby on Rails and Sinatra, middleware plays a crucial role in processing HTTP requests and responses. When you're working within a Rack middleware, accessing request headers is straightforward because the request is represented as an environment hash (env) passed to the call method of your middleware.

Here's how to access request headers in different ways within a Rack middleware:



class UserTokenAuthenticatorMiddleware
  def initialize(app)
heridev / 999-circleci.yml
Last active October 27, 2022 19:30
Code for blog post - How to architect integration or End-to-end(E2E) or system tests for frontend Single Page Applications
# Jest and Cypress(e2e) tests configuration for CircleCi
version: 2.1
cypress: cypress-io/cypress@1
jest: blimmer/jest@1.1.1
- image: cypress/base:14.17.0
heridev /
Last active May 2, 2022 22:14
Elevated email bounce rates through your Amazon SES account

Elevated email bounce rates through your Amazon SES account

In this article, I'm going to be sharing how we got notified of our elevated email bounce rates, how we made a first big reduction by enabling the suppression list functionality on AWS SES, and then how we were able to identify bounced accounts and the commands and CLI tools you can use for managing your suppression list.

It is Friday, and all of a sudden you receive an Amazon support email saying that your account has been moved under review. 😱

We placed your SES account in the US xxx (City) Region under review. You can still use this account to send emails, but you should fully address the problems that led to your account being placed under review.

So, what are the steps that we followed in order to fix this problem?

heridev /
Last active March 9, 2022 16:01 — forked from DmitryTsepelev/
Active record duplicates, prevent duplicates, benchmark on duplicates with active record, single file ruby with rails active record benchmark, single file benchmarking active record duplicates
heridev /
Created October 13, 2021 00:29
Third party SAML Single Sign On (SSO) integration/implementation - Tech spec

Third party SAML Single Sign On (SSO) integration/implementation - Tech spec

  • Author: Heriberto Perez


The implementation of SSO in order to connect with other services/providers/sites is a common requirement these days

For those cases when you have the need to integrate a third party service and embed some widgets in your site, and in order to make it in a secure way and based on dynamic data for the current authenticated, that is when the SSO integration comes handy for you.


This Tech spec will serve as a reference a SAML Single Sign On (SSO) integration.

heridev /
Last active August 11, 2018 15:24
Refactoring the app into MVP : Fourth part - Exceptions

Let's start changing the repository to trigger an exception(typo in the orderby clause):

public class DatabaseBooksRepository implements BooksRepository {
  private final DatabaseHelper databaseHelper;
  public DatabaseBooksRepository(Content context) {
   databaseHelper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
heridev /
Created August 11, 2018 14:50
Refactoring the app into MVP : Third part - Using Mockito

Seems to be pretty simple to install so now let's start with some examples with the same BooksActivityPresenterTest

import org.junit.Test;
import org.junit.Asserts;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
heridev /
Last active August 11, 2018 14:52
Refactoring the app into MVP : Second part

Implementing the database thing

/* this is not the complete example for the implementation
 but it is just a sample as I didn't write it all that
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
  private static final String DATABASE_NAME="Sniptit.rb";
heridev /
Last active August 11, 2018 14:46
Refactoring the app into MVP : First part