Skip to content

Instantly share code, notes, and snippets.

View mogelbrod's full-sized avatar

Victor Hallberg mogelbrod

View GitHub Profile
gbump () {
what=${1:-patch}
echo "Bumping $what version and pushing to origin"
changed=$(git diff-index --name-only HEAD --)
[ -n "$changed" ] && git stash
git pull --rebase && npm version $what && git push && git push --tags
[ -n "$changed" ] && git stash pop
}
@mogelbrod
mogelbrod / path-to-ref.coffee
Last active August 29, 2015 14:01
pathToRef implementation in various JavaScript dialects
###*
* Helper function which returns a reference to a value in an object hierarchy.
* Call with path to parent object if you wish to mutate a value in-place, as
* assignment on reference variables will only set the variable in the local scope.
*
* AngularJS: Available in 'app' module as 'pathToRef' constant.
*
* @param path {Array | String} Path components
* @param root {Object | Array} Root object to start at
* @param initIntermediary {Boolean} Initialize and continue on non-existant values (false = bail)
NAME = main
_DEPS =
_OBJ = $(NAME).o
SDIR = .
ODIR = .
CC = gcc
CFLAGS = -std=c99 -O2 -W -g -I.
@mogelbrod
mogelbrod / gist:4266297
Created December 12, 2012 09:13
Vim fold function which does indentation based folding.
function! IndentationFoldExpr(ln) " {{{
let line = getline(a:ln)
if line =~ '^\s*$'
return '-1' "'='
end
let ind = indent(a:ln) / &sw
let ind_next = indent(nextnonblank(a:ln+1)) / &sw
var data = {
id: trackID(track),
uri: track, // spotify:track:...
artists: [
{ name: 'Unknown', uri: 'spotify:artist:518rTAIFPwQjLUSi4Pdzzn' }
],
title: track, // track name (title)
requests: 1, // number of requests
requesters: [ // length == requests
{ user: 'Anonymous', url: 'http://', time: new Date() }
@mogelbrod
mogelbrod / relative-path.php
Last active May 19, 2016 13:18
Generate a relative URL from path A to B
<?php
function relativePath($from, $to) {
$fromAry = explode('/', $from);
$toAry = explode('/', $to);
while (count($fromAry) && count($toAry) && $fromAry[0] === $toAry[0]) {
array_shift($fromAry);
array_shift($toAry);
}
$up = count($fromAry);
@mogelbrod
mogelbrod / index.js
Created July 12, 2017 10:51
import tiny-cookie === undefined
import cookie from 'tiny-cookie'
console.log(cookie)
@mogelbrod
mogelbrod / redirects.php
Last active September 28, 2017 09:32
Simple Kirby redirects plugin (compatible with https://github.com/ivinteractive/kirbycms-redirects)
<?php
// src/plugins/redirects.php
function htmlRedirect($to) {
$to = esc($to);
echo <<<EOF
<html>
<head>
<meta http-equiv="Refresh" content="0; url=$to" />
</head>
@mogelbrod
mogelbrod / .zshrc
Created June 11, 2018 09:03
Make Ctrl-] copy current input to system clipboard
# Make Ctrl-] copy current input to system clipboard
pbcopy-whole-line() {
echo -n $BUFFER | pbcopy
}; zle -N pbcopy-whole-line
bindkey '^]' pbcopy-whole-line
diff --git a/autoload/csscomplete.vim b/autoload/csscomplete.vim
index 162171f..799aead 100644
--- a/autoload/csscomplete.vim
+++ b/autoload/csscomplete.vim
@@ -98,14 +98,10 @@ function! csscomplete#CompleteCSS(findstart, base)
let entered_property = matchstr(line, '.\{-}\zs[a-zA-Z-]*$')
for m in s:values
- let postfix = ''
- if strridx(after, ':') < 0