Skip to content

Instantly share code, notes, and snippets.

View scorphus's full-sized avatar
Brewing at 🏡 office

Pablo Aguiar scorphus

Brewing at 🏡 office
View GitHub Profile
@scorphus
scorphus / cmd_args.go
Created July 24, 2014 19:26
Iteratively add arguments to a Command
cmd := exec.Command(commandPath, "foo", bar, spam)
if len(egg) > 0 {
cmd.Args = append(cmd.Args, egg)
}
@scorphus
scorphus / UnzipMultipartFile.go
Last active August 29, 2015 14:04
Unzip multipart zipfile and return a slice [file_name]file_content
func UnzipMultipartFile(f *multipart.FileHeader) (map[string]*bytes.Buffer, error) {
file, err := f.Open()
if err != nil {
return nil, err
}
defer file.Close()
size, err := file.Seek(0, 2)
if err != nil {
return nil, err
}
@scorphus
scorphus / multipartzip.go
Created August 7, 2014 17:56
multipartzip.go
// Copyright 2014 gandalf authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package multipartzip
import (
"archive/zip"
"bytes"
"io"
@scorphus
scorphus / multipartzip_test.go
Created August 7, 2014 17:58
multipartzip_test.go
// Copyright 2014 gandalf authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package multipartzip
import (
"fmt"
"io/ioutil"
@scorphus
scorphus / maxmemory.go
Created August 11, 2014 20:40
maxMemory from conf
var maxMemory int
func maxMemoryValue() int {
if maxMemory > 0 {
return maxMemory
}
var err error
maxMemory, err = config.GetInt("api:request:maxMemory")
if err != nil {
panic("You should configure a api:request:maxMemory for gandalf.")
@scorphus
scorphus / bare.go
Created August 11, 2014 20:44
bare.go
var bare string
func bareLocation() string {
if bare != "" {
return bare
}
var err error
bare, err = config.GetString("git:bare:location")
if err != nil {
panic("You should configure a git:bare:location for gandalf.")
@scorphus
scorphus / tempdir.go
Created August 11, 2014 20:52
tempdir.go
var tempDir string
func tempDirLocation() string {
if tempDir == "" {
tempDir, _ = config.GetString("repository:tempDir")
}
return tempDir
}
@scorphus
scorphus / maxmemory.go
Created August 11, 2014 20:55
maxmemory.go
var maxMemory int
func maxMemoryValue() int {
if maxMemory <= 0 {
maxMemory, _ = config.GetInt("api:request:maxMemory")
}
return maxMemory
}
@scorphus
scorphus / gist:c03f1912d75c0f501899
Last active September 16, 2015 21:29 — forked from Bouke/gist:11261620
Brew multiple versions of Python

The brew versions command has been removed. The instructions are no longer valid.

Prerequisites

Make sure you don't have any Python 3.x installed:

$ brew uninstall python3

Then cd into your brew directory, this is /usr/local normally:

@scorphus
scorphus / fish_prompt.fish
Last active February 11, 2016 01:34
Prompt with virtualfish support for the pure theme
#!/usr/bin/env fish
# vim: set ft=sh:
# Pure
# by Rafael Rinaldi
# https://github.com/rafaelrinaldi/pure
# MIT License
# Whether or not is a fresh session
set -g fresh_session 1