Skip to content

Instantly share code, notes, and snippets.

@mislav
mislav / gh-rename-master
Last active April 24, 2022 10:02
Rename the default branch of a repository using GitHub CLI https://github.com/cli/cli/releases/tag/v0.10.0
#!/bin/bash
# Usage: gh-rename-master <newbranch> [<remote>]
#
# Renames the "master" branch of the current repository both locally and on GitHub.
#
# dependencies: GitHub CLI v0.10
set -e
newbranch="${1?}"
remote="${2:-origin}"
@jaibeee
jaibeee / brew-perms.sh
Last active January 4, 2025 01:23
Configure homebrew permissions to allow multiple users on MAC OSX. Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
#!/bin/sh
# Configure homebrew permissions to allow multiple users on MAC OSX.
# Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
# allow admins to manage homebrew's local install directory
chgrp -R admin /usr/local
chmod -R g+w /usr/local
# allow admins to homebrew's local cache of formulae and source files
chgrp -R admin /Library/Caches/Homebrew
@cszentkiralyi
cszentkiralyi / context_quick_scope.vim
Last active April 16, 2016 07:15
Only enable the quick-scope plugin's highlighting when using the f/F/t/T movements
" Insert into your .vimrc after quick-scope is loaded.
" Obviously depends on <https://github.com/unblevable/quick-scope> being installed.
" Thanks to @VanLaser for cleaning the code up and expanding capabilities to include e.g. `df`
let g:qs_enable = 0
let g:qs_enable_char_list = [ 'f', 'F', 't', 'T' ]
function! Quick_scope_selective(movement)
let needs_disabling = 0

A guide on syn region and conceal.

First, when is it appropiate to use syn region instead of syn match? As a rule of thumb: whenever you would expect the matched text to span several lines (and you don't know how many). If you see yourself using .* in the middle of a syn match rule, you should probably consider using syn region instead.

So let's suppose we want to highlight "{{{begin ... end}}}" blocks, such as this:

{{{begin "But I must explain to you how all this mistaken idea of

@mislav
mislav / change_current_object.vim
Last active December 17, 2015 20:39
Defines the `;` motion to select whatever object starts below the cursor
" Defines `;` to select the object currently below the cursor.
" Intended for use when positioned above an opening or closing quote/bracket.
"
" Examples:
"
" Move to a string, change inside it: f" ci;
" Search for a bracket, delete whole object: /{ da;
onoremap a; :<c-u>call <SID>TextObjectCursorCharacter('a')<cr>
xnoremap a; :<c-u>call <SID>TextObjectCursorCharacter('a')<cr>
gem "rails", "~> 3.2.0"
require "active_record"
require "logger"
ActiveRecord::Base.establish_connection(
adapter: "sqlite3",
database: ":memory:"
)
puts ActiveRecord::VERSION::STRING
@mislav
mislav / dynamic_dnsimple.sh
Last active December 10, 2015 22:38
Use DNSimple API to update a DNS record using your current IP. When configured as a cron job, it makes for a good poor man's dynamic DNS solution.
#!/bin/bash
set -e
domain=mislav.net
record=511770 # mysubdomain.mislav.net
ip="$( curl -s icanhazip.com )"
payload="{ \"record\": { \"content\": \"${ip}\" } }"
curl -fsS --netrc \
@kana
kana / realtime.diff
Created December 4, 2012 09:58
Realtime keystroke recording for Vim
--- src/main.c~ 2012-10-23 12:35:34.000000000 +0900
+++ src/main.c 2012-12-04 18:42:25.000000000 +0900
@@ -2315,6 +2315,7 @@
mch_errmsg("\"\n");
mch_exit(2);
}
+ setvbuf(scriptout, NULL, _IONBF, 0);
break;
#ifdef FEAT_GUI_W32
@mpiche
mpiche / gist:3906919
Created October 17, 2012 17:34 — forked from mharju/gist:3805082
Unknown pleasures album cover visualization for Processing. This is the version in http://www.youtube.com/watch?v=nYOh_laT4_Q
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer player;
AudioInput input;
FFT fft;
@SeanTAllen
SeanTAllen / gist:3790659
Created September 26, 2012 21:21
The many things I ended up bookmarking at StrangeLoop 2012
Many of these are from Strangeloop talks and tweets, I can't promise all are as it was a fast paced mess (if anyone cares, these are in reverse order):
I found this last night: blueprints graph db adapter for datomic:
https://github.com/datablend/blueprints/tree/master/blueprints-datomic-graph
The Boundary crew continue building great things & sharing their experience via excellent blogging:
http://boundary.com/blog/2012/09/26/incuriosity-killed-the-infrastructur/
Disruptor Workshop Materials:
http://mechanitis.blogspot.com/2012/09/strangeloop-disruptor-workshop-materials.html