Skip to content

Instantly share code, notes, and snippets.

View ivanlemeshev's full-sized avatar
👨‍💻

Ivan Lemeshev ivanlemeshev

👨‍💻
  • Espoo, Finland
View GitHub Profile
@ivanlemeshev
ivanlemeshev / gist:55a1b05f3ad1dd09baea
Created January 17, 2016 20:26 — forked from moraes/gist:2141121
LIFO Stack and FIFO Queue in golang
package main
import (
"fmt"
)
type Node struct {
Value int
}
@ivanlemeshev
ivanlemeshev / install-hook.md
Last active January 20, 2016 00:07
Golang codebase commit validation

Golang codebase commit validation

It hook checks out that commit message contains [touch: %i] (for example [touch: 1]).

Install from binary file

Run next commands in terminal in order to install this hook:

$ wget https://gist.github.com/ivanlemeshev/be044d12f55d8437617e/raw/29223cc8a9d3e63930e6e62c7e4ded7a47560b09/commit-msg
@ivanlemeshev
ivanlemeshev / pre-commit
Created April 14, 2016 16:28 — forked from tmaiaroto/pre-commit
A Go Commit Hook for Less Future Headaches
#!/bin/bash
#
# Check a "few" things to help write more maintainable Go code.
#
# OK, it's fairly comprehensive. So simply remove or comment out
# anything you don't want.
#
# Don't forget to install (go get) each of these tools.
# More info at the URLs provided.
#
@ivanlemeshev
ivanlemeshev / scanval.go
Last active April 21, 2016 19:46 — forked from husobee/scanval.go
Scanner and Valuer example in Go
package main
import (
"database/sql"
"database/sql/driver"
"errors"
"fmt"
_ "github.com/mattn/go-sqlite3"
)
@ivanlemeshev
ivanlemeshev / vsc_zsh.md
Last active April 21, 2016 19:44
Visual Studio Code in Zsh

~/.zshrc

function code {  
    if [[ $# = 0 ]]
    then
        open -a "Visual Studio Code"
    else
        local argPath="$1"
 [[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
@ivanlemeshev
ivanlemeshev / vsc_bash.md
Created April 21, 2016 19:44
Visual Studio Code in Bash

~/.bash_profile

code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}  
  • code - opens Visual Studio Code
  • code . - opens current directory in Visual Studio Code
  • code somefile - opens somefile in Visual Studio Code
@ivanlemeshev
ivanlemeshev / JapaneseRegex.js
Created April 26, 2016 09:03 — forked from ryanmcgrath/JapaneseRegex.js
Regex to test for presence of Japanese characters
// REFERENCE UNICODE TABLES:
// http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml
// http://www.tamasoft.co.jp/en/general-info/unicode.html
//
// TEST EDITOR:
// http://www.gethifi.com/tools/regex
//
// UNICODE RANGE : DESCRIPTION
//
// 3000-303F : punctuation
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
([一-龯])
Regex for matching Hirgana or Katakana
([ぁ-んァ-ン])
Regex for matching Non-Hirgana or Non-Katakana
([^ぁ-んァ-ン])
Regex for matching Hirgana or Katakana or basic punctuation (、。’)

Installing SSHPASS

SSHPass is a tiny utility, which allows you to provide the ssh password without using the prompt. This will very helpful for scripting. SSHPass is not good to use in multi-user environment. If you use SSHPass on your development machine, it don't do anything evil.

Installing on Ubuntu

apt-get install sshpass

Installing on OS X

@ivanlemeshev
ivanlemeshev / first-and-last-aggregate-functions-psql.sql
Created November 22, 2016 11:24 — forked from seanbehan/first-and-last-aggregate-functions-psql.sql
First and last aggregate functions for Postgresql
-- Create a function that always returns the first non-NULL item
CREATE OR REPLACE FUNCTION public.first_agg ( anyelement, anyelement )
RETURNS anyelement LANGUAGE SQL IMMUTABLE STRICT AS $$
SELECT $1;
$$;
-- And then wrap an aggregate around it
CREATE AGGREGATE public.FIRST (
sfunc = public.first_agg,
basetype = anyelement,