Skip to content

Instantly share code, notes, and snippets.

View sdnts's full-sized avatar

Siddhant sdnts

View GitHub Profile
@matthewmueller
matthewmueller / protocol.ts
Last active November 13, 2023 22:13
Protocol example
export type API = {
'get /teams/:key': {
request: {
key: string
}
response: {
key: string
name: string
}
}
@beached
beached / C++ normal operators.md
Last active July 21, 2024 23:09
A list of the normal signatures of C++ operators that allow overloading

C++ Operator Signatures

This is a list of C++ operators that can be overloaded and their normal signatures(a.k.a what an int would do). The order is the preffered order to use them(The first one listed is often preffered)

Arithmetic

operator+ addition

  • free function -> T operator+( T const & lhs, T const & rhs )
  • member function -> T operator+( T const & rhs ) const

operator+ unary plus

  • member function -> T operator+( ) const
@lukejacksonn
lukejacksonn / gist:a5dd4bb03dc8dad3d489379fd5d26339
Created November 14, 2016 08:54
Download a screenshot of an HTML5 video
var screenshotVideo = (src, time) => {
// Create a video element with source and seek to time
var video = document.createElement('video');
video.src = src;
video.crossOrigin = "Anonymous";
video.currentTime = time;
video.play().then(() => {
// Pause the video at time
@gaearon
gaearon / connect.js
Last active January 16, 2025 06:10
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@paulirish
paulirish / what-forces-layout.md
Last active January 16, 2025 11:49
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
@oneohthree
oneohthree / quick-slugify.sh
Last active January 10, 2025 05:22
Quick bash slugify
echo "$STRING" | iconv -t ascii//TRANSLIT | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z