Skip to content

Instantly share code, notes, and snippets.

View airblade's full-sized avatar

Andy Stewart airblade

View GitHub Profile
@airblade
airblade / imap_with_move.rb
Created October 27, 2022 14:53
Adds IMAP move to Mail
require 'mail'
require 'net/imap'
# Add IMAP move to Mail.
module Mail
# In addition to the options supported by the IMAP class:
#
# move: mailbox to which to move emails. This makes the :delete_after_find flag irrelevant.
#
@airblade
airblade / karabiner.json
Created April 13, 2022 18:46
Karabiner rules elements
{
"description": "Left shift -> {",
"manipulators": [
{
"from": {
"key_code": "left_shift"
},
"to_if_alone": {
"key_code": "open_bracket",
"modifiers": ["left_shift"]
$ mkdir wrapper && cd wrapper
$ echo 'source "https://rubygems.org"' > Gemfile
$ echo 'gem "rails", github: "rails/rails", branch: "main"' >> Gemfile
$ bundle
$ cat ~/.railsrc
--database=postgresql
--skip-action-mailbox
--skip-action-text
--skip-sprockets
@airblade
airblade / upgrade.md
Last active October 7, 2021 13:33
Upgrading Rails 6.0 to 6.1
form_with HTTP request XHR / fetch()
6.0 local: true (default)
6.1 (default) local: false

link_to, form_for: defaults to local. Use remote: true to make remote.

@airblade
airblade / application.html.erb
Last active September 16, 2022 10:41
Simple page titles in Rails
<html>
<head>
<title><%= title %></title>
<!-- ... -->
</head>
<!-- ... -->
</html>
let s:async_sync_id = 0
let s:async_sync_outputs = {}
function! s:next_async_sync_id()
let async_sync_id = s:async_sync_id
let s:async_sync_id += 1
return async_sync_id
endfunction
function! s:async_sync_output(async_sync_id, output)
@airblade
airblade / raspbian.md
Last active January 7, 2020 11:38
Pi hole stuff
  • Download latest Raspbian Lite (currently Buster) from here.

  • Plug SD card into computer.

  • Unzip Raspbian image and install on SD card. This should overwrite everything on the SD card; it shouldn't be necessary to format first.

    diskutil list  # make note of disk of SD card; eg. disk4
    diskutil unmountDisk /dev/disk4
    sudo dd bs=1m if=<path of raspbian image> of=/dev/rdisk4 conv=sync  # rdisk4 is  faster than disk4
    
@airblade
airblade / vimrc
Created April 5, 2019 11:04
Using vim-gitgutter to achieve niklaas/lightline-gitdiff
let g:gitgutter_signs=0
function! GitStatus()
return join(filter(map(['A','M','D'], {i,v -> v.': '.GitGutterGetHunkSummary()[i]}), 'v:val[-1:]'), ' ')
endfunction
set statusline+=%{GitStatus()}
@airblade
airblade / karabiner.json
Last active January 18, 2018 17:24
Karabiner-Elements
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@airblade
airblade / export.rb
Created January 8, 2018 15:34
Exports Photos.app v1.5 albums and their photos to plain directories and files.
#!/usr/bin/env ruby
# Exports albums and their photos to plain directories and files.
#
# Built for Photos.app v1.5 on OS X 10.11.6.
#
# See also:
# https://github.com/koraktor/gallerist
#
# TODO: