Skip to content

Instantly share code, notes, and snippets.

View jomifepe's full-sized avatar
:shipit:

José Pereira jomifepe

:shipit:
View GitHub Profile
@pffigueiredo
pffigueiredo / NestedKeyOf.ts
Created December 17, 2021 15:38
NestedKeyOf
type NestedKeyOf<ObjectType extends object> =
{[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object
? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}`
: `${Key}`
}[keyof ObjectType & (string | number)];
@eddiemoore
eddiemoore / optionalKeys.d.ts
Created March 14, 2019 01:36
Typescript get optional keys from interface
type Undefined<T> = { [P in keyof T]: P extends undefined ? T[P] : never }
type FilterFlags<Base, Condition> = {
[Key in keyof Base]:
Base[Key] extends Condition ? Key : never
};
type AllowedNames<Base, Condition> =
FilterFlags<Base, Condition>[keyof Base];
@schmich
schmich / ducky.md
Last active April 5, 2024 14:20
Programming media keys on the Ducky One 2 Skyline

Programming Media Keys on the Ducky One 2 Skyline

To use media keys on the Ducky One 2 Skyline, you must record a macro to bind the media function to a hotkey combination, i.e. Fn plus some key.

Example

Important: In the instructions below, "Press X+Y+Z" means press and hold key X, press and hold key Y, press and hold key Z in that order, and then release all three.

As an example, to bind Fn+PgUp to the play/pause media function:

@Yatoom
Yatoom / setup.md
Last active May 15, 2024 07:34
Thinkfan configuration

Thinkfan setup

Note: I configured this thinkfan setup for my old Thinkpad w520 on Ubuntu 17.10.

1. Install necessary programs

Install lm-sensors and thinkfan.

sudo apt-get install lm-sensors thinkfan
@sorenlouv
sorenlouv / determine-changed-props.js
Last active April 18, 2024 16:21
Determine which props causes React components to re-render
import React, { Component } from 'react';
export default function withPropsChecker(WrappedComponent) {
return class PropsChecker extends Component {
componentWillReceiveProps(nextProps) {
Object.keys(nextProps)
.filter(key => {
return nextProps[key] !== this.props[key];
})
.map(key => {
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 20, 2024 17:58
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@Rich-Harris
Rich-Harris / please-include-a-repro.md
Last active May 20, 2024 09:50
Please include a repro

Please include a repro

You probably arrived here because of a curt message in response to an issue you filed on a repo that I contribute to. Sorry about that (particularly if you filed the issue long ago and have been waiting patiently for a response). Let me explain:

I work on a lot of different open source projects. I really do like building software that makes other people's lives easier, but it's crazy time-consuming. One of the most time-consuming parts is responding to issues. A lot of OSS maintainers will bend over backwards to try and understand your specific problem and diagnose it, to the point of setting up new test projects, fussing around with different Node versions, reading the documentation for build tools that we don't use, debugging problems in third party dependencies that appear to be involved in the problem... and so on. I've personally spent hundreds of hours of my free time doing these sorts of things to try and help people out, because I want to be a responsible maintainer and I

set $win Mod4
set $alt Mod1
##
## resize mode
##
bindsym $win+r mode "resize"
mode "resize" {
# same bindings, but for the arrow keys
bindsym Left resize shrink width 1 px or 1 ppt
@Zauberfisch
Zauberfisch / audio-switch.sh
Created October 12, 2016 03:44
shell script to switch pulseaudio output device
#!/bin/sh
# based on a script from a now deleted askubuntu answer on this question http://askubuntu.com/questions/71863/how-to-change-pulseaudio-sink-with-pacmd-set-default-sink-during-playback
# the script linked in the answer is still available at https://github.com/mpapis/home_dotfiles/blob/master/bin/mypa though
# dependencies: pulseaudio pacmd awk xargs grep volumeicon
# optional dependencies: zenity (for gui switch)
# this script assumes you are using volumeicon as a tray icon and will restart it on switch
# if you do not use volumeicon you should remove the 2 lines in switch_sink()
@emotality
emotality / duplicate_line_xcode.md
Last active April 6, 2024 04:23
Xcode - Duplicate Line key binding

NOTE (2022-07-09): Xcode finally added this functionality in Xcode 14, please see release notes here:

New Features in Xcode 14 Beta 3
When editing code, the Edit > Duplicate menu item and its corresponding keyboard shortcut now duplicate the selected text — or the line that currently contains the insertion point, if no text is selected. (8614499) (FB5618491)


Xcode line duplicate

Bind keys to duplicate lines in Xcode