Skip to content

Instantly share code, notes, and snippets.

View AnuchitO's full-sized avatar

Anuchit Prasertsang AnuchitO

View GitHub Profile
@AnuchitO
AnuchitO / .vimrc
Last active July 21, 2016 09:10
- replace .vimrc on home - Open .vimrc - :PlugInstall -$cd ~/.vim/plugged/YouCompleteMe -$brew search cmake -$./install.py --clang-completer --tern-completer --gocode-completer
set nocompatible
" let mapleader = "\<space>"
let mapleader = ","
filetype plugin indent on
call plug#begin('~/.vim/plugged')
Plug 'Valloric/YouCompleteMe'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'neomake/neomake'
@AnuchitO
AnuchitO / translate.go
Created June 22, 2016 11:38 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
package com
type MacBook struct {
}
package com
type Computer interface {
GetOwner() string
GetName() string
PowerOn()
Shutdown() error
Restart() error
SetGreetingMsg()
PlaySong(s string)
package embedding
import "testing"
type mockMacBook struct {
}
func (s mockMacBook) GetOwner() string {
return "Mock Anuchit MacBook"
}
package embedding
type Computer interface {
GetOwner() string
GetName() string
PowerOn()
Shutdown() error
Restart() error
SetGreetingMsg()
PlaySong(s string)
package embedding
import "testing"
type mockMacBook struct {
Computer
}
func (s mockMacBook) GetOwner() string {
return "Mock Anuchit MacBook"
package main
import "testing"
func mockGetName() string {
return "Mock Get Name"
}
func TestMockGetStudentName(t *testing.T) {
funcGetName = mockGetName
@AnuchitO
AnuchitO / variable_mocking.go
Created February 17, 2016 06:32
variable_mocking
package main
func getName() string {
return "Anuchit Prasertsang"
}
var funcGetName = getName
func GetStudentName() string {
name := funcGetName()
@AnuchitO
AnuchitO / .vimrc
Created November 10, 2015 08:13 — forked from wingyplus/.vimrc
"
" activate pathogen
"
set runtimepath+=~/.vim/autoload/pathogen.vim
execute pathogen#infect()
filetype on
filetype plugin indent on
"