Skip to content

Instantly share code, notes, and snippets.

View guzmonne's full-sized avatar

Guzman Monne guzmonne

  • Uruguay
  • Montevideo, Uruguay
View GitHub Profile
@guzmonne
guzmonne / utils.js
Created June 24, 2017 21:56
cognito-auth.utils.js
(function(win){
// Simple JavaScript Templating
// John Resig - https://johnresig.com/ - MIT Licensed
// https://johnresig.com/blog/javascript-micro-templating/
//
// There are some minor modification done by me.
var cache = {};
function tmpl(str, data){
var fn;
@guzmonne
guzmonne / windowsjs_export.js
Created January 28, 2022 02:22
Export each animation frame to a `png` with `windowjs`
window.title = "Hello!";
window.visible = false;
const canvas = window.canvas;
const requestMonotonicAnimationFrame = (function () {
const fps = 60;
let start = 0;
const timestep = (function* () {
const step = 1000 / fps;
@guzmonne
guzmonne / windowsjs-exporter.js
Created January 14, 2022 02:51
WindowsJS PNG exporter
window.title = "Hello!";
window.visible = true;
const monotonicDelta = createMonotonicFPSGenerator(60);
function requestMonotonicAnimationFrame(callback) {
callback(monotonicDelta.next().value);
}
const canvas = window.canvas;
import React, {useState, useEffect} from 'react';
import keycloak from '../modules/keycloak.js';
function Keycloak({children}) {
// We'll use this variable to halt the app
// excecution until the user is Authenticated
const [isAuthenticated, setIsAuthenticated] = useState(false);
// The `init()` method we'll be in charge of starting
// the authentication flow.
useEffect(() => {
@guzmonne
guzmonne / gist.new.tsx
Created June 5, 2021 00:32
Created from Remix Form!
import React from "react"
import { redirect } from "remix"
import type { ActionFunction } from "remix"
export const action: ActionFunction = async ({ request }) => {
const token = "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"
const body = new URLSearchParams(await request.text())
const fileName = body.get("fileName") as string
const content = body.get("content")
@guzmonne
guzmonne / tips.sh
Last active November 13, 2020 23:09
Useful bash tips
# Fix locale error
# Put this into /etc/environment
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
# SSH agent
eval `ssh-agent -s`
# Add a key to the keychain
ssh-add ~/.ssh/id_rsa
@guzmonne
guzmonne / Signup-example.js
Created June 25, 2017 02:25
cognito-auth.Signup-example.js
/**
* Signup function that uses AWS Cognito SDK. It wraps its API into a promise
* to consume it easily from other parts of the app.
*/
function signUp(email, password) {
var attributes = [new CognitoUserAttribute({
Name: 'email',
Value: email,
})]
return new Promise(function(resolve, reject) {
function Welcome() {
return (
<div>
Welcome {keycloak.idTokenParsed.name}!
<button onClick={() => keycloak.accountManagement()}>
Account
</button>
<button onClick={() => keycloak.logout()}>
Logout
</button>
import React from 'react';
import Keycloak from './Keycloak.js';
import { keycloak } from '../modules/keycloak.js';
function Welcome() {
return (
<div>
Welcome {keycloak.idTokenParsed.name}!
<button onClick={() => keycloak.accountManagement()}>
Account
@guzmonne
guzmonne / App_v2.jsx
Created July 19, 2019 14:22
Keycloak SS0 - App_v2.jsx
import React from 'react';
import Keycloak from './Keycloak.js';
import { keycloak } from '../modules/keycloak.js';
function Welcome() {
return <div>Welcome {keycloak.idTokenParsed.name}!</div>
}
function App() {
return (