Skip to content

Instantly share code, notes, and snippets.

FWIW: I (@Rondy) am not the author of the content presented here, which is an outline from Edmond Lau's book. I've just copy-pasted it from somewhere and saved as a personal gist, before it got popular on newsnews.ycombinator.com. I don't remember where exactly the original source is from and neither could find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

@michalvichy
michalvichy / 55-bytes-of-css.md
Created September 30, 2022 07:36 — forked from JoeyBurzynski/55-bytes-of-css.md
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@michalvichy
michalvichy / multipleCtx.tsx
Created October 5, 2019 21:57
Multiple contexts with useReducer() and useMemo()
const ContextA = createContext(null);
const ContextB = createContext(null);
const ContextC = createContext(null);
const App = () => {
const [stateA, dispatchA] = useReducer(reducerA, initialStateA);
const [stateB, dispatchB] = useReducer(reducerB, initialStateB);
const [stateC, dispatchC] = useReducer(reducerC, initialStateC);
const valueA = useMemo(() => [stateA, dispatchA], [stateA]);
const valueB = useMemo(() => [stateB, dispatchB], [stateB]);

Keybase proof

I hereby claim:

  • I am michalvichy on github.
  • I am mskora (https://keybase.io/mskora) on keybase.
  • I have a public key ASADYNCQlhovcNVMgf4uoII2YTZg3MZaJZFhtN4WTfBi3Ao

To claim this, I am signing this object:

/**
* Created by michal on 21.03.2017.
*/
export function isMobile() {
let check = false;
(function (a) {
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(
@michalvichy
michalvichy / window-hash.js
Created December 12, 2017 14:17
Usefull piece of code when you're trying to e.g. change hash on tab change
export function getHash() {
return window.location.hash;
}
export function setHash(hash) {
window.location.hash = hash;
}
/**
*
/**
* Created by michal on 23.06.2017.
*/
export default function(func, wait, immediate) {
let timeout;
return (...args) => {
const context = this;
const later = () => {
@michalvichy
michalvichy / .scss-lint.yml
Created May 28, 2017 13:59
scss lint config file
scss_files: "**/*.scss"
linters:
Comment:
enablet: true,
allowed: '^[/* ]*'
HexLength:
style: long
@michalvichy
michalvichy / functions.php
Last active January 12, 2017 08:27
Remove slug from custom post type.
//Note: Replace 'edition' with name of your registered custom post type
/**
* Remove the slug from published post permalinks.
*/
function custom_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( 'edition' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}