Skip to content

Instantly share code, notes, and snippets.

View vitalk's full-sized avatar
🔥
🎶

Vital Kudzelka vitalk

🔥
🎶
View GitHub Profile
@vitalk
vitalk / account.json
Last active April 16, 2016 08:42
Refine schema
{
"data": {
"type": "account",
"attributes": {
"name": "Виталий",
"phone": "+375 29 335-86-79"
}
}
}
@vitalk
vitalk / pew
Created May 8, 2015 19:06
passpie (https://github.com/marcwebbie/passpie) wrapper which easy to use
#!/usr/bin/env bash
#: usage: pew [<options>] [<command>]
#:
#: Manage vault with easy.
#:
#: The most commonly used commands are:
#: pew Show vault
#: pew <re> Search by regular expression
#: pew --help Show list of available commands and exit.
@vitalk
vitalk / mac
Created July 29, 2014 06:51
Returns the unique and valid MAC address in format 00:16:3E:xx:xx:xx.
#!/usr/bin/env bash
#
#: usage: mac <string>
#:
#: Returns the unique and valid MAC address in format 00:16:3E:xx:xx:xx.
#: The <string> uses to create an unique part of the address.
function help() {
sed -En 's/^#:[[:space:]]?//p' $0
}
@vitalk
vitalk / bump
Created July 22, 2014 20:12
Bump new version
#!/usr/bin/env bash
#
#: usage: bump <version> <upcoming>
#:
#: For each file in current directory and subdirectories
#: update any <version> string to the new <upcoming> value.
function help() {
sed -En 's/^#:[[:space:]]?//p' $0
}

How To Use Dnsmasq on Local Development

Rationale

Access your local development servers by human-readable domain name instead of numerical IP without touching your /etc/hosts.

How To

@vitalk
vitalk / api.js
Last active August 29, 2015 13:56
Example of the client-side API wrapper
// Define variables in one `var` statement
var
// The our API implementation
api = {},
// The basic API endpoint
apiRoot = document.location.protocol + '//' + document.location.host + '/api/v1/',
// Verb aliases
function _tr() {
local cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-sessions | cut -f 1 -d ':')" -- "${cur}") )
}
complete -F _tr tr
@vitalk
vitalk / tmux
Created February 5, 2014 11:22
#!/bin/bash
# tmux completion
# See: http://www.debian-administration.org/articles/317 for how to write more.
# Usage: Put "source bash_completion_tmux.sh" into your .bashrc
# Based upon the example at http://paste-it.appspot.com/Pj4mLycDE
function _tmux_complete_client() {
local IFS=$'\n'
local cur="${1}"
@vitalk
vitalk / git-branch-status
Created January 26, 2014 21:42
Show how many commits each branch is ahead or behind its upstream.
#!/usr/bin/env bash
# Usage: git-branch-status
# Show how many commits each branch is ahead or behind its upstream.
branch=`git rev-parse --abbrev-ref HEAD`
git for-each-ref --format='%(refname:short) %(upstream:short)' refs/heads | \
while read local upstream; do
@vitalk
vitalk / amd.js
Created December 19, 2013 10:44
Unified Javascript module loader
!(function(name, definition) {
var hasDefine = typeof define === 'function',
hasExports = typeof module !== 'undefined' && module.exports;
if (hasDefine) {
define(name, definition);
} else if (hasExports) {
module.exports = definition();
} else {
this[name] = definition();