Skip to content

Instantly share code, notes, and snippets.

View davidabram's full-sized avatar
🐊
Work, work.

David Abram davidabram

🐊
Work, work.
View GitHub Profile
@JLarky
JLarky / IsolateCSS.tsx
Last active July 10, 2023 09:23
How to use shadow dom to isolate CSS of React component https://twitter.com/JLarky/status/1657989891526123520
export function IsolateCSS(props: { children: React.ReactNode }) {
const onceRef = useRef(false);
const [shadowRoot, setShadowRoot] = useState<ShadowRoot>();
const ref = useCallback((ref: HTMLDivElement | null) => {
if (ref && onceRef.current === false) {
onceRef.current = true;
setShadowRoot(ref.attachShadow({ mode: 'open' }));
}
}, []);
@fabiospampinato
fabiospampinato / fast_css_reset.css
Last active July 18, 2023 18:07
The fastest CSS reset possible
:where(abbr), :where(address), :where(area), :where(article), :where(aside), :where(audio), :where(b), :where(base), :where(bdi), :where(bdo), :where(big), :where(blockquote), :where(body), :where(br), :where(caption), :where(cite), :where(code), :where(col), :where(colgroup), :where(data), :where(datalist), :where(dd), :where(del), :where(details), :where(dfn), :where(dialog), :where(dl), :where(dt), :where(em), :where(embed), :where(fieldset), :where(figcaption), :where(figure), :where(footer), :where(form), :where(h1), :where(h2), :where(h3), :where(h4), :where(h5), :where(h6), :where(head), :where(header), :where(hgroup), :where(hr), :where(i), :where(input), :where(ins), :where(kbd), :where(keygen), :where(label), :where(legend), :where(li), :where(link), :where(main), :where(map), :where(mark), :where(menu), :where(menuitem), :where(meta), :where(meter), :where(nav), :where(object), :where(ol), :where(optgroup), :where(option), :where(output), :where(param), :where(picture), :where(pre), :where(progress
@wybiral
wybiral / noscript-tracking.go
Last active September 11, 2023 08:53
Tracking cursor position in real-time with remote monitoring (without JavaScript)
// Tracking cursor position in real-time without JavaScript
// Demo: https://twitter.com/davywtf/status/1124146339259002881
package main
import (
"fmt"
"net/http"
"strings"
)
@mbaitelman
mbaitelman / README.md
Last active February 20, 2024 22:31
Automated Terraform Deployments Using Bitbucket Pipelines
@zdeslav
zdeslav / porezi.md
Last active April 16, 2023 20:53
O poreznom opterećenju rada u Hrvatskoj

Svakih nekoliko tjedana u medijima nas netko uvjerava kako hrvatske firme ne mogu biti konkurentne zbog prevelikog poreznog opterećenja rada, pa se onda prijeti selidbom firmi u Irsku ili kuka kako se po pitanju oporezivanja trebamo ugledati na Poljsku "u kojoj su davanja na plaće 30 posto, dok su u Hrvatskoj 60 posto."

OK, hajdemo malo pogledat kako stoje stvari u tim zemljama u kojima se, izgleda, država magično financira kišom novčanica koje padaju s neba.

U tablici ispod uspoređeni su neto i bruto 2 iznosi prosječne plaće, dvostruke prosječne neto plaće i plaće u protuvrijednosti 2000 EUR za nekoliko zemalja u kategorijama interesantnima za usporedbu

@EyMaddis
EyMaddis / whatsapp-send-in-current-chat.js
Created November 4, 2016 12:50
Sending messages programmatically on web.whatsapp.com
// this allows to send arbitrary messages. The chat conversation you want to send messages to has to be open.
// just run this in the JS console
// http://stackoverflow.com/a/39165137/1249001
function findReactComponent(dom) {
for (var key in dom)
if (key.startsWith("__reactInternalInstance$")) {
var compInternals = dom[key]._currentElement;
var compWrapper = compInternals._owner;
var comp = compWrapper._instance;
@anaisbetts
anaisbetts / stat-cache.js
Last active April 11, 2019 05:07
Make your Electron apps load faster, with this One Weird Trick
// Include this at the very top of both your main and window processes, so that
// it loads as soon as possible.
//
// Why does this work? The node.js module system calls fs.realpathSync a _lot_
// to load stuff, which in turn, has to call fs.lstatSync a _lot_. While you
// generally can't cache stat() results because they change behind your back
// (i.e. another program opens a file, then you stat it, the stats change),
// caching it for a very short period of time is :ok: :gem:. These effects are
// especially apparent on Windows, where stat() is far more expensive - stat()
// calls often take more time in the perf graph than actually evaluating the
@jfromaniello
jfromaniello / gist:8418116
Last active September 19, 2023 23:38
Example of authenticating websockets with JWTs.
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({port: 8080});
var jwt = require('jsonwebtoken');
/**
The way I like to work with 'ws' is to convert everything to an event if possible.
**/
function toEvent (message) {
try {
@rantav
rantav / README.md
Created August 23, 2012 06:13
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...