Skip to content

Instantly share code, notes, and snippets.

😍
Processing request ...

Guillermo Álvarez guillermo

😍
Processing request ...
Block or report user

Report or block guillermo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@guillermo
guillermo / 1 - useMousePosition.js
Created May 9, 2019
React Hooks relative mouse position used in kalena.app https://blog.kalena.app/day-6/
View 1 - useMousePosition.js
// 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
React Hooks and Context for user in Kalena.app http://blog.kalena.app/day-6
View 1 - userContext.js
// 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
Get windows size inside the component.
View life.js
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';
View cloud-config.yaml
#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:
View cloud-config.yaml
#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 Dec 12, 2016
Package verbs provides a simple method to filter request method with the net/http ServeMux
View verbs.go
// 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()
View iosvalidation.rb
#!/usr/bin/env ruby
def trace(msg)
$stderr.puts msg
end
begin
require "rest"
rescue LoadError => e
trace("Install nap dependency")
View designer.html
<link href="../paper-toggle-button/paper-toggle-button.html" rel="import">
<polymer-element name="my-element">
<template>
<style>
#design_host {
position: absolute;
width: 100%;
height: 100%;
@guillermo
guillermo / domain_filter.rb
Created Jun 24, 2014
Rack Middleware for filtering domains
View domain_filter.rb
class DomainFilter
def initialize(app, domain, &block)
@external_app = app
@domain_app = Rack::Builder.new(&block)
@domain = domain
end
def call(env)
if env["HTTP_HOST"].match(@domain)
@domain_app.call(env)
@guillermo
guillermo / my_app.sh
Created Jan 15, 2014
This is a unix wrapper around the erlang vm.
View my_app.sh
#!/bin/bash
# This is a unix wrapper around the erlang vm. It provides the following functionality:
#
# * Spawns in foreground
# * Handle SIGHUP and call RELOADFUNC
# * Handle SIGTERM SIGQUIT and SIGINT telling to the vm to quit
# * Dies if the vm dies (for example kernel killing because out of memory)
#
# Forks and improvements are welcome.
You can’t perform that action at this time.