Skip to content

Instantly share code, notes, and snippets.

View andresgcarmona's full-sized avatar
🎯
Focusing

Andrés G. Carmona andresgcarmona

🎯
Focusing
View GitHub Profile
@andresgcarmona
andresgcarmona / contrast.coffee
Created July 25, 2020 19:34 — forked from lerouxb/contrast.coffee
The W3C's suggested color contrast algorithm
# http://www.w3.org/TR/AERT#color-contrast
getBrightness = (rgb) ->
sum = parseInt(rgb[0])*299 + parseInt(rgb[1])*587 + parseInt(rgb[2])*114
brightness = Math.round(sum / 1000) # 0 (dark) to 255 (light)
colorDifference = (a, b) ->
max = Math.max
min = Math.min
d0 = max(a[0], b[0]) - min(a[0], b[0])
@andresgcarmona
andresgcarmona / service-worker.js
Created September 13, 2020 14:47 — forked from jeffposnick/service-worker.js
Example of InjectManifest in Workbox v5
// Add any other logic here as needed.
import { CacheableResponsePlugin } from 'workbox-cacheable-response/CacheableResponsePlugin';
import { CacheFirst } from 'workbox-strategies/CacheFirst';
import { createHandlerForURL } from 'workbox-precaching/createHandlerForURL';
import { ExpirationPlugin } from 'workbox-expiration/ExpirationPlugin';
import { NavigationRoute } from 'workbox-routing/NavigationRoute';
import { precacheAndRoute } from 'workbox-precaching/precacheAndRoute';
import { registerRoute } from 'workbox-routing/registerRoute';
/*!
* Bootstrap v3.3.5 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*!
* Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=3356eb28a4f746ca1528)
* Config saved to config.json and https://gist.github.com/3356eb28a4f746ca1528
*/
/*!
* Bootstrap v3.3.5 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*!
* Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=3356eb28a4f746ca1528)
* Config saved to config.json and https://gist.github.com/3356eb28a4f746ca1528
*/
@andresgcarmona
andresgcarmona / login.dart
Created September 29, 2020 03:18
Login form for Flutter
import 'package:flutter/material.dart';
class LoginForm extends StatefulWidget {
@override
_LoginFormState createState() => _LoginFormState();
}
class _LoginFormState extends State<LoginForm> {
final _formKey = GlobalKey<FormState>();
final _emailController = TextEditingController();
@andresgcarmona
andresgcarmona / README.md
Last active March 17, 2021 18:58
First gist to test Github gists

It works!

From Wikipedia:

Epicyclic gearing or planetary gearing is a gear system consisting of one or more outer gears, or planet gears, revolving about a central, or sun gear. … Epicyclic gearing systems also incorporate the use of an outer ring gear or annulus, which meshes with the planet gears.

Use the menu in the top-left to change the frame of reference, fixing the specified gear in-place.

@andresgcarmona
andresgcarmona / App.js
Created March 24, 2021 03:33
Three.js startup project.
import Scene from './Scene'
export default class App {
constructor () {
this.onResize()
this.bindEvents()
this.scene = new Scene(this)
}

Keybase proof

I hereby claim:

  • I am andresgcarmona on github.
  • I am andres_gcarmona (https://keybase.io/andres_gcarmona) on keybase.
  • I have a public key ASDmwr-p10yss5aPZX6v1CCaiBcBJGws2zM5LOFCEZGAAgo

To claim this, I am signing this object:

import React, { useState, useEffect, useCallback, startTransition } from "react";
// library code
const createStore = (initialState) => {
let state = initialState;
const getState = () => state;
const listeners = new Set();
const setState = (fn) => {
state = fn(state);
@andresgcarmona
andresgcarmona / humanFileSize.js
Created September 28, 2022 11:26
File size human readable
function humanFileSize(bytes, si=false, dp=1) {
const thresh = si ? 1000 : 1024;
if (Math.abs(bytes) < thresh) {
return bytes + ' B';
}
const units = si
? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];