Skip to content

Instantly share code, notes, and snippets.

View guillermo's full-sized avatar
😍
Processing request ...

Guillermo Álvarez guillermo

😍
Processing request ...
View GitHub Profile
@guillermo
guillermo / twitter_oauth2.go
Last active July 13, 2023 13:17
twitter golang oauth2
// Package twitter allows to do twitter oauth2 calls with the standard oauth2 package
// I created this public gist after hours spent trying to find something that works.
// This is copy paste from production code, with all database and framework specifics removed by hand,
// so I don't know if it works "as is".
package twitter
var (
TWITTER_CONFIG = &oauth2.Config{
@guillermo
guillermo / tsnode
Created September 10, 2021 13:53
tsnode
#!/bin/bash
esbuild --bundle --platform=node $* | node
@guillermo
guillermo / 0 Figma Keyboard Shortcuts for windows.md
Last active September 24, 2024 16:35
Figma keyboard shortcuts for windows cheat sheet
@guillermo
guillermo / svg2pdf.bash
Created December 1, 2020 16:57 — forked from s417-lama/svg2pdf.bash
Reliable way to convert an SVG file to a PDF file using headless Chrome
#!/bin/bash
#
# Convert an SVG file to a PDF file by using headless Chrome.
#
if [ $# -ne 2 ]; then
echo "Usage: ./svg2pdf.bash input.svg output.pdf" 1>&2
exit 1
fi
@guillermo
guillermo / 1 - useMousePosition.js
Created May 9, 2019 14:19
React Hooks relative mouse position used in kalena.app https://blog.kalena.app/day-6/
// Inspired by
// https://github.com/rehooks/window-mouse-position/blob/master/index.js
import {useState,useEffect} from 'react'
export default function useMousePosition(){
let [mousePosition, setMousePosition] = useState([0,0])
function handleMouseMove(e) {
setMousePosition( [e.pageX, e.pageY] );
@guillermo
guillermo / 1 - userContext.js
Last active May 9, 2019 15:09
React Hooks and Context for user in Kalena.app http://blog.kalena.app/day-6
// We create a context interface with a reducer
import React, {createContext, useContext, useReducer} from 'react'
export const UserContext = createContext();
export const UserProvider = ({reducer, initialState, children}) =>(
<UserContext.Provider value={useReducer(reducer,initialState)}>
{children}
</UserContext.Provider>
)
@guillermo
guillermo / life.js
Last active May 9, 2019 07:27
Get windows size inside the component.
import React from 'react'
import Logo from '../Logo';
import Background from '../Background';
import Header from '../Header';
import Stats from '../Stats';
import Timeline from '../Timeline';
import useWindowSize from '../../effects/useWindowSize';
#cloud-config
preserve_hostname: false
fqdn: blog.kalena.app
hostname: blog.kalena.app
package_update: true
package_upgrade: true
package_reboot_if_required: true
packages: ['docker.io', 'ntp','libcap2-bin']
resolv_conf:
#cloud-config
preserve_hostname: false
fqdn: blog.kalena.app
hostname: blog.kalena.app
package_update: true
package_upgrade: true
package_reboot_if_required: true
packages: ['docker.io', 'ntp','libcap2-bin']
resolv_conf:
@guillermo
guillermo / verbs.go
Last active December 12, 2016 10:32
Package verbs provides a simple method to filter request method with the net/http ServeMux
// Copyright 2015 Guillermo Alvarez. All rights reserved.
// Use of this source code is governed by standard BSD license.
/*
Package verbs provides a simple method to filter request method with the net/http ServeMux
func createUser(w http.ResponseWriter, r *http.Request) {
...
}
mux := http.NewServeMux()