Skip to content

Instantly share code, notes, and snippets.

View lanzafame's full-sized avatar

Adrian Lanzafame lanzafame

View GitHub Profile
@lanzafame
lanzafame / singularity-workshop.md
Last active February 8, 2024 10:42 — forked from SgtCoin/singularity-workshop.md
Singularity Workshop

Singularity Workshop Guide

Welcome to the Singularity Workshop!

Getting Started

This instruction will guide you through all steps necessary to use Singularity to

  1. Prepare an open dataset from S3
  2. Send deal to a local emulated storage provider f02815405
  3. Make retrievals from the emulated storage provider using HTTP and Bitswap
@lanzafame
lanzafame / git_fzf_key_bindings.fish
Created August 30, 2018 04:39 — forked from aluxian/git_fzf_key_bindings.fish
Key bindings for git+fzf ported to Fish shell https://junegunn.kr/2016/07/fzf-git/
function __git_fzf_is_in_git_repo
command -s -q git
and git rev-parse HEAD >/dev/null 2>&1
end
function __git_fzf_git_status
__git_fzf_is_in_git_repo; or return
git -c color.status=always status --short | \
fzf -m --ansi --preview 'git diff --color=always HEAD -- {-1} | head -500' | \
cut -c4- | \
@lanzafame
lanzafame / nmcli-toggle.py
Last active July 11, 2016 06:37 — forked from un-def/nmcli-toggle.py
Toggle network connection up/down using nmcli
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import subprocess
if len(sys.argv) < 2:
print("Usage: nmcli-toggle.py connection_id")
sys.exit()
conn_id = sys.argv[1]
active = subprocess.check_output(['nmcli', 'connection', 'show', '--active'])
up_down = ('up', 'down')[bytes(conn_id, 'utf-8') in active]
@lanzafame
lanzafame / check.go
Last active June 17, 2016 01:44 — forked from mattes/check.go
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); err == nil {
// path/to/whatever exists
}
@lanzafame
lanzafame / pr.md
Created June 15, 2016 00:32 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@lanzafame
lanzafame / auth.py
Created June 14, 2016 02:28 — forked from ibeex/auth.py
Python LDAP (ActiveDirectory) authentication
import ldap
def check_credentials(username, password):
"""Verifies credentials for username and password.
Returns None on success or a string describing the error on failure
# Adapt to your needs
"""
LDAP_SERVER = 'ldap://xxx'
# fully qualified AD user name
LDAP_USERNAME = '%[email protected]' % username
@lanzafame
lanzafame / ssh_agent_start.fish
Last active April 23, 2016 05:04 — forked from rsff/ssh_agent_start.fish
ssh agent for fish
#this script can never fail
#i use it in the fish_config
#call it with start_agent
setenv SSH_ENV $HOME/.ssh/environment
function ssh_agent_start
if [ -n "$SSH_AGENT_PID" ]
ps -ef | grep $SSH_AGENT_PID | grep ssh-agent > /dev/null
if test -n $HOME
set -l NIX_LINK $HOME/.nix-profile
if test ! -L $NIX_LINK
echo "creating $NIX_LINK" >&2
set -l _NIX_DEF_LINK /nix/var/nix/profiles/default
/nix/store/cdybb3hbbxf6k84c165075y7vkv24vm2-coreutils-8.23/bin/ln -s $_NIX_DEF_LINK $NIX_LINK
end
set -x PATH $NIX_LINK/bin $NIX_LINK/sbin $PATH
@lanzafame
lanzafame / taskgit
Created October 29, 2015 04:47 — forked from unode/taskgit
#!/bin/sh
# copyright 2014 Renato Alves
# distributed under the GPL licence
if [ -z "$TASKDIR" ]; then
#TODO Look for data location in rc:location instead of assuming ~/.taskrc
TASKDIR="$(grep data.location $HOME/.taskrc | cut -d '=' -f 2)"
fi
@lanzafame
lanzafame / main.go
Created October 20, 2015 14:08 — forked from mattetti/main.go
Go's reflection example
package main
import(
"fmt"
"reflect"
)
func main(){
// iterate through the attributes of a Data Model instance
for name, mtype := range attributes(&Dish{}) {