Skip to content

Instantly share code, notes, and snippets.

View abadongutierrez's full-sized avatar
💻
working

Rafael Gutiérrez abadongutierrez

💻
working
View GitHub Profile
#!/bin/bash
URL="https://prep2024.ine.mx/publicacion/nacional/assets/presidencia/presidenciaNacional.json"
fetch_and_print() {
echo "------------------------------------------------------------------------------------"
JSON_FILE="presidenciaNacional_$(date +%Y-%m-%d_%H-%M-%S).json"
curl --compressed -o "$JSON_FILE" "$URL"
if [ $? -ne 0 ]; then
+-----------------+--------+-----------+
| Column | Type | Modifiers |
|-----------------+--------+-----------|
| employee_id | bigint | not null |
| corporate_email | text | not null |
| first_name | text | not null |
| last_name | text | not null |
+-----------------+--------+-----------+
Indexes:
"employee_pkey" PRIMARY KEY, btree (employee_id)
@abadongutierrez
abadongutierrez / application.yml
Created February 4, 2021 04:35
Micronaut Tutorial - Login with Microsoft - application.yml final look
micronaut:
application:
name: <your-application-name>
security:
authentication: cookie
token:
jwt:
signatures:
secret:
generator:
@abadongutierrez
abadongutierrez / UserDetailsMapper.java
Created February 1, 2021 06:38
Micronaut Tutorial - Login with Microsoft - UserDetailsMapper class
package com.jabaddon.tutorials.micronaut.loginwithmicrosoft;
import edu.umd.cs.findbugs.annotations.Nullable;
import io.micronaut.core.async.publisher.Publishers;
import io.micronaut.security.authentication.AuthenticationResponse;
import io.micronaut.security.authentication.UserDetails;
import io.micronaut.security.oauth2.endpoint.authorization.state.State;
import io.micronaut.security.oauth2.endpoint.token.response.OauthUserDetailsMapper;
import io.micronaut.security.oauth2.endpoint.token.response.TokenResponse;
import io.reactivex.Single;
@abadongutierrez
abadongutierrez / MicrosoftGraphApiClient.java
Last active February 1, 2021 06:37
Micronaut Tutorial - Login with Microsoft - MicrosoftGraphApiClient class
package com.jabaddon.tutorials.micronaut.loginwithmicrosoft;
import io.micronaut.core.type.Argument;
import io.micronaut.http.HttpRequest;
import io.micronaut.http.MutableHttpRequest;
import io.micronaut.http.client.RxHttpClient;
import io.micronaut.http.uri.UriBuilder;
import io.reactivex.Flowable;
import io.reactivex.Single;
@abadongutierrez
abadongutierrez / MicrosoftUser.java
Last active February 1, 2021 05:59
Micronaut Tutorial - Login with Microsoft - MicrosoftUser class
package com.jabaddon.tutorials.micronaut.loginwithmicrosoft;
import io.micronaut.core.annotation.Introspected;
@Introspected
public class MicrosoftUser {
private String id;
private String surname;
private String givenName;
private String userPrincipalName;
@abadongutierrez
abadongutierrez / home.html
Last active February 1, 2021 06:37
Micronaut Tutorial - Login with Microsoft - Home Page
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Home Page</title>
</head>
<body>
<h1>Micronaut Tutorial - Login with Microsoft</h1>
<h2 th:if="${security}">Welcome authenticated user: <span th:text="${security.attributes.user['userPrincipalName']}"></h2>
@abadongutierrez
abadongutierrez / HomeController.java
Created January 27, 2021 05:59
Micronaut Tutorial - Login with Microsoft - HomeController
package com.jabaddon.tutorials.micronaut.loginwithmicrosoft;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.security.annotation.Secured;
import io.micronaut.security.rules.SecurityRule;
import io.micronaut.views.View;
import java.util.HashMap;
import java.util.Map;
@abadongutierrez
abadongutierrez / mix_cheatsheet.md
Last active January 2, 2018 07:17
Mix cheatsheet

To create new projects:

mix new kv

mix new kv --module KV

To load iex with mix project files:

use Mix.Config
# ...
config :ecto_101_migrations_schemas, Ecto101MigrationsSchemas.Repo,
adapter: Ecto.Adapters.Postgres,
database: "ecto_test",
username: "postgres",
password: "",
hostname: "localhost"
config :ecto_101_migrations_schemas, ecto_repos: [Ecto101MigrationsSchemas.Repo]