Skip to content

Instantly share code, notes, and snippets.

View kosciolek's full-sized avatar

kosciolek

  • Poland - Małopolskie
View GitHub Profile
[
{
"name": "Erik",
"surname": "Perez",
"address": {
"country": "BJ",
"city": "Gekavenu",
"street": "Icni Square"
},
"birth": "1970-08-27T08:41:30.587Z",
@kosciolek
kosciolek / asd.java
Created December 17, 2021 12:07
some uni homework project
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;
// Troche pozmienialem nazwy metod/interfejsow ale poza tym to struktura prawie taka sama
// Dziala troche jak reverse polish notation (op popuje argumenty ze stacku i wrzuca result na stack)
class Main {
@kosciolek
kosciolek / index.js
Last active August 11, 2021 21:52
Facebook, scrape conversation messages
;(async () => {
console.info('Type stop() to stop.')
const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
const msgSelector = ".j83agx80.jwdofwj8.pby63qed";
const msgTextSelector = ".oo9gr5id[dir=auto]";
const msgAuthorSelector = ".pfnyh3mw.r9r71o1u.m9osqain.fsrhnwul.dkr8dfph";
const scrollableSelector =
".buofh1pr.j83agx80.eg9m0zos.ni8dbmo4.cbu4d94t.gok29vw1";
const msgContainerSelector = '[aria-label=Messages]';
@kosciolek
kosciolek / Grid.tsx
Created July 25, 2021 13:25
responsive grid
import { css } from "@emotion/react";
import styled from "@emotion/styled";
export const breakpoints = {
xs: 0,
sm: 460,
md: 820,
lg: 1350,
xl: 1880,
};
@kosciolek
kosciolek / styled.ts
Last active July 19, 2021 13:06
Styled components variant and iif.
export const iif = <PROPS extends unknown, PROP_NAME extends keyof PROPS>(
prop: PROP_NAME,
val?: PROPS[PROP_NAME]
) => (propsInner: PROPS) => {
if (val !== undefined) return propsInner[prop] === val ? "&" : "&.__NEVER";
return propsInner[prop] ? "&" : "&.__NEVER";
};
export const variant = <PROPS extends unknown>(
prop: PROPS[keyof PROPS],
@kosciolek
kosciolek / query.ts
Last active July 18, 2021 11:54
Fancy media query hooks.
/* eslint-disable react-hooks/rules-of-hooks */
import {useLayoutEffect, useState} from "react";
export const firstToUppercase = (string: string) =>
string.charAt(0).toUpperCase() + string.slice(1);
export const breakpoints = {
xs: 0,
sm: 600,
md: 960,
@kosciolek
kosciolek / css
Last active July 14, 2021 19:54
fluid typography 1440px+
html {
font-size: max(8px, calc(8 / 1440 * 100vw));
font-family: 'Poppins', sans-serif;
line-height: 1;
letter-spacing: 0.02rem;
}
body {
font-size: max(18px, calc(18 / 1440 * 100vw));
margin: 0;
@kosciolek
kosciolek / measure.js
Last active July 3, 2021 13:38
Measure scrollbar width
function getScrollbarWidth() {
const outer = document.createElement('div');
outer.style.visibility = 'hidden';
outer.style.overflow = 'scroll';
document.body.appendChild(outer);
const inner = document.createElement('div');
outer.appendChild(inner);
import {useEffect, useState} from "react";
import {firstToUppercase} from "../utils/js";
export const breakpoints = {
xs: "0px",
sm: "600px",
md: "960px",
lg: "1280px",
xl: "1920px",
};
@kosciolek
kosciolek / query.ts
Created June 3, 2021 17:15
media query
export const breakpoints = {
xs: "0px",
sm: "600px",
md: "960px",
lg: "1280px",
xl: "1920px"
};
export const query = Object.entries(breakpoints).reduce(
(acc, [breakpoint, value]) => {