Skip to content

Instantly share code, notes, and snippets.

Avatar

Przemek Sobstel sobstel

View GitHub Profile
@sobstel
sobstel / autofill.ts
Last active Sep 30, 2022
React: handle browser-autofilled password in Chrome
View autofill.ts
// Problem: when remembered, Chrome auto-fills the password input, but in fact it doesn't
// set the value and doesn't fire onChange event until there's any kind of interaction.
// If password value is empty, then submit button is still disabled yet password looks filled,
// which looks bad. See: https://bugs.chromium.org/p/chromium/issues/detail?id=813175
const [isAutofilled, setIsAutofilled] = useState(false);
const passwordElRef = useRef<HTMLInputElement | null>(null);
useEffect(() => {
const element = passwordElRef.current;
@sobstel
sobstel / shapeup-pitch.md
Last active Sep 30, 2022
Shape Up: Write the Pitch
View shapeup-pitch.md

Problem

The raw idea, a use case, or something we’ve seen that motivates us to work on this

Appetite

How much time we want to spend and how that constrains the solution

Solution

@sobstel
sobstel / CODE_delorean_clock.ino
Last active Nov 16, 2021
CODE_delorean_clock_V4_SUMMER.ino [UPDATED]
View CODE_delorean_clock.ino
#include "SevenSegmentTM1637.h"
#include "SevenSegmentExtended.h"
#include "RTClib.h"
// Sortie horloge Rouge
const byte PIN_CLK_Red = A0; // define CLK pin
// Sortie horloge Verte
const byte PIN_CLK_Green = A1; // define CLK pin
// Sortie horloge Orange
const byte PIN_CLK_Orange = A2; // define CLK pin
View mapDuplicates.test.ts
import mapDuplicates from "./mapDuplicates";
describe("mapDuplicates", () => {
it("addresses duplicate surnames", () => {
const surnames = ["González", "González", "Martínez", "González"];
expect(
mapDuplicates(surnames, (name, index) => `${name} ${index}`)
).toEqual(["González 0", "González 1", "Martínez", "González 3"]);
});
@sobstel
sobstel / unmount_animation_example.js
Created Mar 8, 2021
react-native-animatable unmount animation with hooks
View unmount_animation_example.js
// https://github.com/oblador/react-native-animatable/issues/132#issuecomment-786870602
const MyComponent = (props) => {
const ref = React.useRef();
React.useEffect(() => {
ref?.current?.fadeIn();
return () => ref?.current?.fadeOut(); // as you know, this is the same as unmount ;)
}, [props.id]); // track some prop that changes
@sobstel
sobstel / deploy.yml
Created Oct 1, 2020
Deploy Ruby AWS lambda with github action
View deploy.yml
on:
push:
branches:
- "master"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@sobstel
sobstel / win10vm_apple_keyboard.txt
Last active Nov 2, 2020
win10vm_apple_keyboard
View win10vm_apple_keyboard.txt
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetScrollLockState, AlwaysOff
;following section remaps alt-arrow and command-arrow
;keys to mimic OSX behaviour
#Up::SendInput {Lctrl down}{Home}{Lctrl up}
@sobstel
sobstel / page-speed-report.md
Last active May 7, 2020
Google page speed report 2018
View page-speed-report.md

Google page speed report 2018

  • Time spent on mobile vs desktop 
    • 2015 -> Google started getting more search queries from mobile than desktop
    • 2018 -> Time spent on mobile 2-3x bigger than on desktop (and growing...)
  • Users reaction
    • 46% dislike waiting for slow pages to load 
    • 53% abandon a site that loads in more than 3 seconds
  • As of July 2018, page speed will become an important ranking factor for mobile searches 
  • Page speed will also influence ad rank and the CPC that you pay 
@sobstel
sobstel / createSequentialNavigator.js
Created Apr 29, 2020
React Navigation (v4) sequential navigator
View createSequentialNavigator.js
// @flow
import React, { Component } from 'react';
import _ from 'lodash';
import createStackNavigator from './createStackNavigator';
type Props = {
navigation: *,
};
const DEFAULT_CONFIG = {
@sobstel
sobstel / typescript-cheatsheet.ts
Last active Oct 11, 2019
TypeScript cheatsheet
View typescript-cheatsheet.ts
// same arg type and return type
withUID<T>(obj: T)
// "extends" helps providing some constraints
// eg <T extends object>
withUID({a: 1}) // valid
withUID("wrong way") // NOT valid
// default value type (string)
A<T=string> { name: T }