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 / r2d2-couchdb-example.rs
Created September 4, 2016 06:15
Using a connection pool for CouchDB in Rust with r2d2-couchdb
extern crate r2d2;
extern crate r2d2_couchdb;
extern crate serde_json;
use r2d2_couchdb::{CouchdbConnectionManager};
use std::thread;
use std::time::Duration;
fn main() {
@scorphus
scorphus / ipip.fish
Created June 6, 2016 17:24
Jus a pip wrapper
function ipip -d "Indexes-aware pip"
if test (count $argv) -ge 2
if test $argv[1] = "install"
if test (count $PIP_INDEX_URLS) -ge 1
set index_urls "--index-url"=$PIP_INDEX_URLS[1]"simple/"
set trusted_host (__extract_domain $PIP_INDEX_URLS[1]"simple/")
set trusted_hosts "--trusted-host" $trusted_host
if test (count $PIP_INDEX_URLS) -ge 2
for index_url in $PIP_INDEX_URLS[2..-1]
set index_urls $index_urls "--extra-index-url"=$index_url"simple/"
@scorphus
scorphus / memoize.py
Created May 13, 2016 21:35
Memoize with timeout
class memoize(dict):
def __init__(self, func, timeout=15):
logger.info('Initiating cache for %s', func)
self.func = func
self.timeout = None
if timeout:
self.timeout = float(timeout)
def __call__(self, *args):
@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
@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 / 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 / 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 / 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 / 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 / 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"