Skip to content

Instantly share code, notes, and snippets.

View atesgoral's full-sized avatar

Ateş Göral atesgoral

View GitHub Profile
import { useSignal, signal, effect } from '@preact/signals';
import { useLayoutEffect, useMemo, useRef } from 'preact/hooks';
/** @template T @typedef {T extends (infer U)[] ? U : never} Items */
/** @param {{ v, k?, f }} props */
const Item = ({ v, k, f }) => f(v, k);
/**
* Like signal.value.map(fn), but doesn't re-render.
@marutypes
marutypes / gitmoji.md
Last active March 12, 2022 20:38
Mallen's Simplified Gitmoji

Mallen's Simplified Gitmoji

Inspired by gitmoji, stripped down to an easier to remember and less granular subset. Include these in your commits and PR titles to enhance you communication and mood.

  • 🎉 :tada: first commit
  • :sparkles: adds a feature
  • 💥 :boom: breaking change
  • 📝 :memo: adds docs
  • :heavy_plus_sign: adds dependency(s)
  • :heavy_minus_sign: removes dependency(s)
@nebadon2025
nebadon2025 / gist:3143d837350ab443482b0f5a6faccd6b
Last active May 11, 2024 07:03
Full Screen Youtube Autoplay URL format
https://www.youtube.com/embed/HH0zOJVOzxs?rel=0&autoplay=1;fs=0;autohide=0;hd=0;mute=1;
@monoblaine
monoblaine / validate.js
Last active March 28, 2016 09:17 — forked from ssg/validate.js
Turkish ID Validator in a Tweet Attempt
tc=n=>{if(n=n.split('').map(Number),o=n[e=i=0],c=n[9],t=10,o)for(;++i<9;)eval((i%2?'e':'o')+'+=n[i]');return!((7*o-e+t)%t-c|(o+e+c)%t-n[t])}
@travellingprog
travellingprog / 00 When Static Prototypes Go Wrong.md
Last active February 23, 2016 03:06
When Static Prototypes Go Wrong - some of the lessons learned

When Static Prototypes Go Wrong - Styling

For my part of the presentation, I will talk about some of the lessons learned around styling.

Short URL for this page: http://git.io/vgO0C

There's a ton of links embedded in this gist. I invited you to click through them to help you follow along.

@burtlo
burtlo / son_lint.rb
Created November 18, 2015 00:57
Find all the JSON files in the local directory and any subdirectories and attempt to parse them with a Ruby JSON parser. If any of them fail to load an error message will be displayed.
require 'json'
Dir["**/*.json"].each do |json_file|
JSON.parse(File.read(json_file))
end
@iar-wain
iar-wain / gist:5acd042fc8ce336d0198
Created October 22, 2015 03:24
Human Resource Machine - Level 20 - speed (67)
-- HUMAN RESOURCE MACHINE PROGRAM --
BUMPUP 9
BUMPUP 9
ADD 9
COPYTO 8
ADD 8
JUMP k
a:
b:
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 5
COPYFROM 9
COPYTO 0
COPYTO 1
BUMPUP 1
b:
@paulirish
paulirish / what-forces-layout.md
Last active May 20, 2024 06:33
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@qbein
qbein / netcat
Created July 11, 2015 10:01
Replay pcap/pcapng TCP traffic using netcat
For development it may be useful to be able to replay TCP traffic (e.g. HTTP). The dump can be created using WireShark or tcpdump:
$ tcpdump -s 0 port http -i en0 -w dump.pcap
To generate data files that can be replayed through netcat we use tcptrace:
$ tcptrace -e input.pcapng
Finally replay the HTTP traffic using netcat to host 192.168.1.1 port 80
$ cat a2b_contents.dat | nc -v 192.168.1.1 80
If you need to replay the raw network traffic, we need to do some massaging using tcpprep and tcprewrite before using tcpreplay to replay the raw packages. Note that due to limitation of tcprewrite this will not replay any traffic to the network: http://tcpreplay.synfin.net/wiki/FAQ#Doestcpreplaysupportsendingtraffictoaserver.