Skip to content

Instantly share code, notes, and snippets.

View dkarter's full-sized avatar

Dorian Karter dkarter

View GitHub Profile
@reinh
reinh / README.md
Last active February 20, 2016 00:39

Syntax highlight SQL inside Ruby <<-SQL heredocs

Embeds SQL syntax highlighting inside Ruby heredocs labeled SQL. This will also work to embed other syntaxen, e.g., HTML.

Optional PGSQL enhanced syntax:

(requires https://github.com/exu/pgsql.vim)

 syntax include @SQL syntax/pgsql.vim
@Integralist
Integralist / Hash Keys to Symbols.rb
Last active September 2, 2020 08:50
Convert Ruby Hash keys into symbols
hash = { 'foo' => 'bar' }
# Version 1
hash = Hash[hash.map { |k, v| [k.to_sym, v] }]
# Version 2
hash = hash.reduce({}) do |memo, (k, v)|
memo.tap { |m| m[k.to_sym] = v }
end
@kristopherjohnson
kristopherjohnson / pasteboard.swift
Created January 11, 2015 00:58
Utility functions to copy/paste text
import Foundation
#if os(iOS)
import UIKit
#else
import AppKit
#endif
/// Return string value currently on clipboard
func getPasteboardContents() -> String? {
@mknabe
mknabe / README.md
Last active September 18, 2021 09:14
React component to warn users about unsaved changes to forms when they attempt navigate away from the page using redux-form

Use with the following

  • react-router
  • redux-form

You must use this compontent on the route component where the form is shown not on the form component itself. This is because this.props.route is only added to route components, and I didn't want to pass that down through props.

Inspired by this Codepad

Feedback appreciated

@ryancdotorg
ryancdotorg / frag32.py
Created August 20, 2015 16:27
A FAT32 fragmenter, because I am a horrible person.
#!/usr/bin/env python
import random
import struct
import sys
# Most of the Fat32 class was cribbed from https://gist.github.com/jonte/4577833
def ppNum(num):
return "%s (%s)" % (hex(num), num)
@kizzx2
kizzx2 / commitlint.vim
Created March 7, 2018 08:17
ALE Linter for commitlint
function! ale_linters#gitcommit#commitlint#Handle(buffer, lines) abort
" Matches patterns line the following:
let l:pattern = '^\(✖\|⚠\)\s\+\(.*\) \(\[.*\]\)$'
let l:output = []
let l:line = getline(1)
if l:line[0] != '#'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:item = {
\ 'lnum': 1,
@alexyoung
alexyoung / .vimrc
Created May 16, 2012 11:12
mouse-vimrc
" vim:fdm=marker
" Editor basics {{{
" Behave like Vim instead of Vi
set nocompatible
" Show a status line
set laststatus=2
" Show the current cursor position
@romainl
romainl / devdocs.md
Last active June 19, 2023 04:31
Look up keywords on https://devdocs.io from Vim
@sos4nt
sos4nt / xterm-256color-italic.terminfo
Created July 27, 2012 12:13
A xterm-256color based TERMINFO that adds the escape sequences for italic
# A xterm-256color based TERMINFO that adds the escape sequences for italic.
#
# Install:
#
# tic xterm-256color-italic.terminfo
#
# Usage:
#
# export TERM=xterm-256color-italic
#
@charlietran
charlietran / TerminalVim.scpt
Last active October 14, 2023 06:50
Open file in iTerm vim for MacOS Sierra
-- TerminalVim.app
-- This creates a shim Application that will enable you to open files from the Finder in vim using iTerm
-- To use this script:
-- 1. Open Automator and create a new Application
-- 2. Add the "Run Applescript" action
-- 3. Paste this script into the Run Applescript section
-- 4. Save the application as TerminalVim.app in your Applications folder
-- 5. In the Finder, right click on a file and select "Open With". In that window you can set TerminalVim as a default