Skip to content

Instantly share code, notes, and snippets.

View rewop's full-sized avatar

Simone Potenza rewop

  • HousingAnywhere
  • Rotterdam
  • X @r3wop
View GitHub Profile
@rewop
rewop / README.md
Last active November 19, 2020 14:03
Go json diff

This is a simple piece of code that I used to show a friend how I would compare two json object in Go. It exposes a function to compare two JSON given as []byte.

The code assumes that the json object are small enough to be loaded in memory.

This gist shows why we should avoid register to the window load event inside a promise chain. I encountered this bug at work, and this is the demostration of how to reproduce it.

Notice how the console.log at line 19 of script.js is never called, and the console never prints Do something on load.

@rewop
rewop / Challenge.md
Last active August 5, 2018 21:07 — forked from dseelmann/.eslintrc
Test task

Task

Implement a page with a multi-step form, where each step shows when you have completed the previous one. In other words, we're not looking for previous/next buttons, but the next step should appear automatically.

Steps

  1. Two checkboxes with labels A1 and A2. Both are unchecked by default. Next step is available after at least one of them is checked.
  2. Two toggle buttons with labels B1 and B2. One button untoggles another (same as radio buttons behavior). Both are inactive by default. Next step is available when any option has been chosen.
  3. Text field with button Check. When button is pressed a value of the field will be send. Next step is available if a response from API is fine.
  4. Selectbox with C1, C2, C3 options. It is empty by default. Next step is available when any option has been chosen.
const handleScroll = _history => {
_history.listen(location => {
// Use setTimeout to make sure this runs after React Router's own listener
setTimeout(() => {
// Keep default behavior of restoring scroll position when user:
// - clicked back button
// - clicked on a link that programmatically calls `history.goBack()`
@rewop
rewop / rewop.zsh-theme
Created October 11, 2014 09:24
My favourite zsh theme
# the idea of this theme is to contain a lot of info in a small string, by
# compressing some parts and colorcoding, which bring useful visual cues,
# while limiting the amount of colors and such to keep it easy on the eyes.
# When a command exited >0, the timestamp will be in red and the exit code
# will be on the right edge.
# The exit code visual cues will only display once.
# (i.e. they will be reset, even if you hit enter a few times on empty command prompts)
typeset -A host_repr
#!/bin/sh
# A pre-commit hook for git to lint JavaScript files with jshint
# @see https://github.com/jshint/jshint/
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904