Skip to content

Instantly share code, notes, and snippets.

Working from home

Hugo Schmitt hugows

Working from home
View GitHub Profile
hugows / component.js
Created Dec 10, 2021
A trick to detect re-renders in React
View component.js
// Add a random background to the component
// On a re-render, the component gets a new color
// Source of this snippet:
const random255 = () => Math.floor(Math.random() * 255)
const randomRGBA = () => {
const r = random255()
const g = random255()
const b = random255()
hugows / Monitor new files on a folder
Last active Dec 9, 2021
MacOs: Monitor new files, announce events, add new files to Yoink
View Monitor new files on a folder
This didn't work with fswatch, but chokidar with poll monitor was fine:
`chokidar '*.json' -p --poll-interval 1000 -c 'say "{event}" && open -a Yoink {path}'`
I was using this to debug a HTTP server that generated log files every X minutes, so I didn't have to keep checking the terminal.
Another useful idea is to send results of a script to yourself via [Telegram](
`chokidar '*.json' -p --poll-interval 1000 -c ' {path} | telegram -'`
View kinto and pop os

Pop_OS! and Kinto configuration

After installing Kinto, I needed some additional tweaks:

  1. Disable the Super key behavior (source)
gsettings set overlay-key-action 'WORKSPACES'
gsettings set org.gnome.mutter overlay-key ''
hugows / kinto.ahk
Last active Jun 9, 2021
Config. adicionais do kinto.ahk
View kinto.ahk
;; Teclados de Mac no Windows/Linux usando
; Fixos pra sempre na minha memoria muscular...
!r::Send #r
!e::Send #e
!d::Send #d
!l::Send #l
; PC-style control movement
#Backspace::Send ^{Backspace}
hugows / index.js
Created May 6, 2020 — forked from magbicaleman/index.js
Dynamic imports are very interesting..
View index.js
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import registerServiceWorker from './registerServiceWorker';
class Dynamic extends Component {
constructor(props) {
this.state = { module: null };
hugows / proxy.js
Created Apr 16, 2020
proxy objects reminds me of lua's metatables
View proxy.js
const user = {
firstName: 'John',
lastName: 'Doe',
email: '',
const handler = {
get(target, property) {
return target[property] || (property + "-not-found");
hugows / Text.js
Last active Dec 11, 2019
Easy way to replace use custom font in React Native projet
View Text.js
// First install font like:
import React from 'react';
import {Text as RNText, StyleSheet} from 'react-native';
export default class Text extends React.Component {
constructor(props) {
hugows /
Last active Dec 2, 2019
nemo file manager - set it to open zip files with this script by default = quick way to handle zip files
parentdir=$(dirname "$@")
cd $parentdir
if [[ $@ == *.zip ]]; then
outputdir=$(basename "$@" ".zip")
if [[ $@ == *.rar ]]; then
outputdir=$(basename "$@" ".rar")
hugows / tptacek.go
Created Nov 23, 2019
Alternative to jwt-go
View tptacek.go
package main
import (
func main() {
plaintext := "Hello folks!"
# Script should be run daily to move Downloads/ files to an archived folder.
YESTERDAY=$(date -d "yesterday 13:00" '+%Y-%m-%d')
mkdir -p $HOME/ArchivedDownloads/$YESTERDAY
mv $HOME/Downloads/* $HOME/ArchivedDownloads/$YESTERDAY