Skip to content

Instantly share code, notes, and snippets.

View ezioruan's full-sized avatar
🏠
Working from home

ezio ruan ezioruan

🏠
Working from home
View GitHub Profile
package main
import (
//"bufio"
"bytes"
"crypto/md5"
"fmt"
"io"
"os"
"runtime"
package main
import (
"io"
"log"
"mime/multipart"
"net/http"
"os"
"path/filepath"
"runtime"

Setting up Vim as your Go IDE

The final IDE

Intro

I've been wanting to do a serious project in Go. One thing holding me back has been a my working environment. As a huge PyCharm user, I was hoping the Go IDE plugin for IntelliJ IDEA would fit my needs. However, it never felt quite right. After a previous experiment a few years ago using Vim, I knew how powerful it could be if I put in the time to make it so. Luckily there are plugins for almost anything you need to do with Go or what you would expect form and IDE. While this is no where near comprehensive, it will get you writing code, building and testing with the power you would expect from Vim.

Getting Started

I'm assuming you're coming with a clean slate. For me this was OSX so I used MacVim. There is nothing in my config files that assumes this is the case.

"""
Simple forking echo server built with Python's SocketServer library. A more
Pythonic version of http://gist.github.com/203520, which itself was inspired
by http://tomayko.com/writings/unicorn-is-unix.
"""
import os
import SocketServer
class EchoHandler(SocketServer.StreamRequestHandler):
@ezioruan
ezioruan / tree.md
Created March 31, 2014 05:05 — forked from hrldcpr/tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@ezioruan
ezioruan / gist:9806430
Created March 27, 2014 12:27
golang type func
package main
import (
"fmt"
)
type myFunc func(int, int)
func (m myFunc) do(a int, b int) {
m(a, b)
package main
import (
"net/http"
)
type SingleHost struct {
handler http.Handler
allowedHost string
}
/**
* A generic confirmation for risky actions.
* Usage: Add attributes: ng-really-message="Are you sure"? ng-really-click="takeAction()" function
*/
angular.module('app').directive('ngReallyClick', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
var message = attrs.ngReallyMessage;
@ezioruan
ezioruan / gist:9777589
Created March 26, 2014 06:01
angular-redactor js
angular.module('angular-redactor', []).directive("redactor", function() {
return {
require : '?ngModel',
link : function($scope, elem, attrs, controller) {
controller.$render = function() {
elem.redactor({
buttons : ['formatting', 'bold', 'italic', 'deleted', 'fontcolor', 'backcolor', 'table'],
keyupCallback : function() {