Skip to content

Instantly share code, notes, and snippets.

View daGrevis's full-sized avatar
⌨️
Keyboard operator

Raitis Stengrevics daGrevis

⌨️
Keyboard operator
View GitHub Profile
let g:ctrlp_user_command = {
\ 'types': {
\ 1: ['.git', 'cd %s && git ls-files -oc --exclude-standard'],
\ 2: ['.hg', 'hg --cwd %s locate -I .'],
\ },
\ 'fallback': 'find %s -type f -o -type l'
\ }
let g:ctrlp_map = ''
function! CtrlP()
if (getcwd() == $HOME)
echo "Won't run in ~"
return
endif
if (getcwd() == '/')
echo "Won't run in /"
return
let g:ctrlp_map = ''
function! CtrlP()
if (getcwd() == $HOME)
echo "Won't run in ~"
return
endif
if (getcwd() == '/')
echo "Won't run in /"
return
local filter = hs.window.filter.new():setDefaultFilter{}
filter:subscribe(hs.window.filter.windowCreated, function(window)
local windowFrame = window:frame()
local screenFrame = window:screen():frame()
windowFrame.x = screenFrame.x
windowFrame.y = screenFrame.y
windowFrame.w = screenFrame.w
windowFrame.h = screenFrame.h
window:setFrame(windowFrame)
end)
config_path = os.getenv("HOME") .. "/.hammerspoon/"
hs.pathwatcher.new(config_path, function(paths, flagTables)
paths = hs.fnutils.ifilter(paths, function(path)
return not path:ends('.git/index.lock')
end)
if #paths > 0 then
hs.reload()
end
end):start()
video-to-gif() {
FPS="${FPS:-10}"
SCALE="${SCALE:-640}"
ffmpeg -i "$@" -vf fps=$FPS,scale=$SCALE:-1:flags=lanczos,palettegen palette.png
ffmpeg -i "$@" -i palette.png -filter_complex "fps=10,scale=640:-1:flags=lanczos[x];[x][1:v]paletteuse" recording.gif
rm palette.png
}
@daGrevis
daGrevis / init.lua
Created November 27, 2018 15:34
Hammerspoon + AirPods
function airPods(deviceName)
local s = [[
activate application "SystemUIServer"
tell application "System Events"
tell process "SystemUIServer"
set btMenu to (menu bar item 1 of menu bar 1 whose description contains "bluetooth")
tell btMenu
click
]]
..
@daGrevis
daGrevis / .vimrc
Last active November 20, 2018 10:49
Improved h & l
nnoremap <expr> h col('.') == match(getline('.'), '\S') + 1 ? 'k$' : 'h'
nnoremap <expr> l col('.') == strlen(getline('.')) ? 'j^' : 'l'
snippet if
if (${1}) {
}
endsnippet
snippet sw
switch (${1}) {
case '':
break
default:
const postgres = require('../index')
const getMessagesQuery = (serverId, channelName, connectionId) =>
postgres('ircMessages')
.where({ serverId, to: channelName })
.where(function() {
this.where({ isPublic: true })
if (connectionId) {
this.orWhere({ connectionId })
}