Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# Generates a very opinionated `tasks.json` for Elixir projects.
#
# Usage (from the root of your project)
#
# mkdir .vscode
# cp .vscode/tasks.json .vscode/tasks.backup.json
# task-maker > .vscode/tasks.json
#
@laggardkernel
laggardkernel / startup-time-of-zsh.md
Last active April 12, 2024 13:24
Comparison of ZSH frameworks and plugin managers

Comparison of ZSH frameworks and plugin managers

Changelog

  • update 1: add a FAQ section
  • update 2: benchmark chart and feature comparison table
  • update 3:
    • improve the table with missing features for antigen
    • new zplg times result

TLDR

@lornajane
lornajane / mac.md
Last active May 8, 2024 18:08
Keyboard Only OS X

Keyboard-only Mac Cheatsheet

Hi, I'm Lorna and I don't use a mouse. I have had RSI issues since a bad workstation setup at work in 2006. I've tried a number of extra hardware modifications but what works best for me is to use the keyboard and only the keyboard, so I'm in a good position and never reaching for anything else (except my coffee cup!). I rather unwisely took a job which required me to use a mac (I've been a linux user until now and also had the ability to choose my tools carefully) so here is my cheatsheet of the apps, tricks and keyboard shortcuts I'm using, mostly for my own reference. Since keyboard-only use is also great for productivity, you may also find some of these ideas useful, in which case at least something good has come of this :)

Apps List

There's more detail on a few of these apps but here is a quick overview of the tools I've installed and found helpful

Tool Link Comments
def fd(canvas, pos_x, pos_y, units, dir)
units.times do
pos_y = if dir == "N" || dir == "NE" || dir == "NW"
pos_y - 1
elsif dir == "S" || dir == "SE" || dir == "SW"
pos_y + 1
else
pos_y
end
pos_x = if dir == "E" || dir == "NE" || dir == "SE"
@orenbenkiki
orenbenkiki / enhanced_extension.ex
Last active February 21, 2022 22:29
Elixir module inheritance
defmodule Extension do
defmacro extends(module) do
# As above...
end
defmacro implements(module, protocol: protocol) do
quote do
defimpl unquote(protocol), for: unquote(module) do
import Extension
@ku1ik
ku1ik / gist:3930651
Created October 22, 2012 09:38
You don't need bundle exec, rbenv-bundler and other bundler integration scripts

You don't need bundle exec, rbenv-bundler or other bundler integration scripts

You just need 2 things

Just prepend $PATH with .bundle/bin:

$ cat ~/.bashrc
...
export PATH=".bundle/bin:$PATH"

...

@kconragan
kconragan / keyrepeat.shell
Last active December 4, 2023 03:40
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@avdi
avdi / match_method.rb
Created December 6, 2011 21:27
Defining method_missing and respond_to? in one fell swoop
# Do you ever define #method_missing and forget #respond_to? I sure
# do. It would be nice if we could do them both at the same time.
module MatchMethodMacros
def match_method(matcher, &method_body)
mod = Module.new do
define_method(:method_missing) do |method_name, *args|
if matcher === method_name.to_s
instance_exec(method_name, *args, &method_body)
else
# Fast specs
#
# To run from the command line for my_model in your app:
#
# rspec -Ifast_specs fast_specs/models/my_model
#
require 'rspec'
RSpec.configure do |config|
config.mock_with :rspec