Skip to content

Instantly share code, notes, and snippets.

View stphn's full-sized avatar
💻
coding

Stéphane Goeuriot stphn

💻
coding
View GitHub Profile
# change window focus within space
alt - j : yabai -m window --focus south
alt - k : yabai -m window --focus north
alt - h : yabai -m window --focus west
alt - l : yabai -m window --focus east
#change focus between external displays (left and right)
alt - s: yabai -m display --focus west
alt - g: yabai -m display --focus east
// TMUX
C-a C-o Rotate through the panes
C-a C-z Suspend the current client
C-a Space Select next layout
C-a ! Break pane to a new window
C-a # List all paste buffers
C-a $ Rename current session
C-a & Kill current window
C-a ' Prompt for window index to select
@stphn
stphn / React Keydown addEventListener.js
Created November 20, 2021 22:26
How to add keyboard shortcuts to your React app
import { useCallback, useEffect } from 'react';
export default function App() {
// handle what happens on key press
const handleKeyPress = useCallback((event) => {
console.log(`Key pressed: ${event.key}`);
}, []);
useEffect(() => {
// attach the event listener
@stphn
stphn / isTouchDevice _helper.js
Created November 19, 2019 00:29
Detect Touch Devices
export const isTouchDevice = () => {
let prefixes = ' -webkit- -moz- -o- -ms- '.split(' ')
let mq = function(query) {
return window.matchMedia(query).matches
}
if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
return true
{
"editor.renderWhitespace": "all",
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": true,
"editor.cursorStyle": "line-thin",
"workbench.iconTheme": "file-icons-colourless",
"editor.fontFamily": "BlexMono Nerd Font Mono",
"editor.fontLigatures": true,
"editor.renderControlCharacters": true,
"editor.fontWeight": "400",
@stphn
stphn / text
Created November 11, 2019 07:26
nginx
X-Frame-Options: DENY
Cache-Control: max-age=31557600
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
add_header 'Access-Control-Max-Age' 31536000 always;
@stphn
stphn / detect.js
Created October 12, 2019 12:46 — forked from 4ndrej/detect.js
detect mobile device using javascript
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
@stphn
stphn / javascript.json
Last active August 22, 2019 09:19
vscode snippets
{
"require": {
"prefix": "require",
"body": [
"$1: require('../$1/$1.data')"
],
"description": "Require data"
}
}
@stphn
stphn / mixins.scss
Last active December 7, 2022 21:04
scss mixins
// aspect ratio
@mixin ratio($width:16, $height:9) {
width: 100%;
overflow: hidden;
padding-top: ($height / $width) * 100%;
position: relative;
> * {
position: absolute;
width: 100%;
@stphn
stphn / user_settings.json
Created November 7, 2018 13:28
Visual code studio settings
{
"editor.renderWhitespace": "all",
"eslint.autoFixOnSave": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": true,
"workbench.colorCustomizations": {
"tab.activeBorder": "#00E5E5",
"list.inactiveSelectionForeground": "#00E5E5",
"list.activeSelectionBackground": "#00a6a9"
},