Skip to content

Instantly share code, notes, and snippets.

View giacomorebonato's full-sized avatar

Giacomo Rebonato giacomorebonato

View GitHub Profile
{
"title": "Giacomo qwerty to functional",
"rules": [
{
"description": "lctrl + qwerty > F keys",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "q",
@giacomorebonato
giacomorebonato / Auth.d.ts
Created May 30, 2020 13:24
useAuth authentication hook for React and Apollo
interface Auth {
user?: UserData
login(
email: string,
password: string
): Promise<ExecutionResult<{ login: LOGIN_USER_DATA }>>
logout(): Promise<ExecutionResult<any>>
}
import { FieldNode } from 'graphql'
export const doesPathExists = (
nodes: readonly FieldNode[],
path: string[]
): boolean => {
if (!nodes) {
return false
}
@giacomorebonato
giacomorebonato / personal.sh
Created October 7, 2019 13:22
Personal shell
alias cbn="git branch | grep '^\*' | cut -d' ' -f2 | pbcopy && echo \"branch name copied to clipboard\""
alias burp="brew upgrade && brew update"
### Keybase proof
I hereby claim:
* I am giacomorebonato on github.
* I am grebonato (https://keybase.io/grebonato) on keybase.
* I have a public key ASCjqKFvulYeQyfZVXCFg1kBEiTMXMvyJyuDMqRrR4grtAo
To claim this, I am signing this object:
@giacomorebonato
giacomorebonato / rotateMatrix.js
Last active February 29, 2024 18:27
Rotate matrix clockwise 90
function rotateMatrix (matrix = []) {
return matrix[0].map(
(_row, i) => getRotatedRow(i, matrix)
)
}
function getRotatedRow (i, matrix) {
return matrix.map(
(_row, y) => matrix[(matrix.length - 1) - y][i]
)
@giacomorebonato
giacomorebonato / server.js
Created September 29, 2016 11:55
simple ExpressJS spa
const express = require('express')
const bodyParser = require('body-parser')
const path = require('path')
const app = express()
// assets. Static JS, CSS, fonts
app.use('/public', express.static(path.join(__dirname, '../public')))
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
@giacomorebonato
giacomorebonato / Component_With_Loader.js
Last active August 17, 2016 12:33
ReactJS Component with Loader
import React from 'react'
class Component_1 extends React.Component {
constructor (props) {
super(props)
this.state = {
loading: true
}
}
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
var data = {{data | safe}}
</script>
<title>Typescript boilerplate</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel='stylesheet' />
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css' />
import { observable, action } from 'mobx'
import objectAssign = require('object-assign')
class SampleStore {
constructor (data?) {
if (data) {
this.setData(data)
} else if (window['data']) {
let wData = window['data'] as any