Skip to content

Instantly share code, notes, and snippets.

View rpdelaney's full-sized avatar
🏠
Working nomad

Ryan Delaney rpdelaney

🏠
Working nomad
View GitHub Profile
@gullyn
gullyn / flappy.html
Last active May 4, 2024 15:35
Flappy bird in 205 bytes (improved!)
<body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c>

Vim will move the cursor to the beginning of an object after invoking operator upon it. From an interactive editing perspective this may be considered annoying however it is the consistent choice as operators can be destructive. As such restoring the cursor to its prior position after invoking an operator on an object may not make sense.

There are many ways possible to alter this behaviour to your preference with mappings and/or scripting. But with custom operator mappings this can be particularly ugly.

@romainl
romainl / gq.vim
Last active August 21, 2022 17:17
Formatting without moving
" gq wrapper that:
" - tries its best at keeping the cursor in place
" - tries to handle formatter errors
function! Format(type, ...)
normal! '[v']gq
if v:shell_error > 0
silent undo
redraw
echomsg 'formatprg "' . &formatprg . '" exited with status ' . v:shell_error
endif
@vaibhav93
vaibhav93 / auto_brightness.py
Last active August 11, 2020 23:16
Adjust brightness when switching to chrome workspace in i3
import i3ipc
import os
SET_BRIGHTNESS = 'xbacklight -set '
GET_BRIGHTNESS = 'xbacklight'
i3 = i3ipc.Connection()
class BrightnessController:
def __init__(self):
self.brightness_map = {}
@fnky
fnky / ANSI.md
Last active May 28, 2024 16:24
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@scmx
scmx / using-details-summary-github.md
Last active May 26, 2024 16:59
Using <details> <summary> expandable content on GitHub with Markdown #details #summary #markdown #gfm #html

How to use <details> <summary> expandable content on GitHub with Markdown

Firstly, what is <details> <summary>?

The HTML Details Element (<details>) creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label can be provided using the <summary> element. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details.

Example

@marceloalmeida
marceloalmeida / .gitattributes
Last active December 7, 2023 14:26
How to show diffs for gpg-encrypted files?
*.gpg filter=gpg diff=gpg
*.asc filter=gpg diff=gpg
@rogeruiz
rogeruiz / vim-everywhere-or-how-i-abstracted-away-my-workflow-and-cant-use-regular-computers-anymore.markdown
Last active September 10, 2021 19:36
18F Tech Talk Lite! 2017: How to Vim Everywhere. Or, how I abstracted away my workflow and can't use regular computers anymore

Preface

Hey there folks, I'm Roger and I use the terminal for just about everything text related. I really like using a keyboard over a mouse.

Let's begin our journey into my workflow with two things in mind. First off, there is very little research here in terms of actual productivity gains. I did this mostly for fun.

This is just how one person decided to hit the dopamine part of their brain

@pkarman
pkarman / stretch-bench.rb
Created October 5, 2016 18:14
password hashing comparisons
require 'benchmark/ips'
require 'bcrypt'
require 'openssl'
require 'securerandom'
def sha512_digest(*tokens)
Digest::SHA512.hexdigest('--' << tokens.flatten.join('--') << '--')
end
Benchmark.ips do |x|
@romainl
romainl / isdiff.vim
Created August 13, 2016 12:24
Diff detection in vimscript
" this should echo '1' when entering 'diff mode' and '0' otherwise
function! IsDiff(opt)
let isdiff = 0
if v:progname =~ "diff"
let isdiff = isdiff + 1
endif
if &diff == 1