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
heridev / content.md
Last active March 20, 2024 21:39
How to create your own HTTP API client gem in Ruby
@heridev
heridev / content.md
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:

Using Rack::Request.new

app/middleware/user_token_authenticator_middleware.rb

class UserTokenAuthenticatorMiddleware
  def initialize(app)
@heridev
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
orbs:
cypress: cypress-io/cypress@1
jest: blimmer/jest@1.1.1
executors:
with-cypress-node-14-17:
docker:
- image: cypress/base:14.17.0
jobs:
@heridev
heridev / amazon-bounces-management.md
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
heridev / 0_unique_data.md
Last active March 9, 2022 16:01 — forked from DmitryTsepelev/0_unique_data.md
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
heridev / content.md
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

Background

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.

Goals

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

@heridev
heridev / exceptions.md
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):

DatabaseBooksRepository.java

public class DatabaseBooksRepository implements BooksRepository {
  private final DatabaseHelper databaseHelper;
  public DatabaseBooksRepository(Content context) {
   databaseHelper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
  }
@heridev
heridev / third_part.md
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

BooksActivityPresenterTest.java

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

Implementing the database thing

OpenHelperManager.java

/* 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
heridev / first_part.md
Last active August 11, 2018 14:46
Refactoring the app into MVP : First part