Skip to content

Instantly share code, notes, and snippets.

View lanzafame's full-sized avatar

Adrian Lanzafame lanzafame

View GitHub Profile
@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 = git@github.com: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 = '%s@xxx.xx' % username
@lanzafame
lanzafame / touchfileinalldirs.bash
Created June 6, 2016 01:43
Create file in all the directories in the current directory.
# Create __init__.py in all the directories in the current directory.
# .
# ├── clique
# │   └── clique.py
# ├── __init__.py
# ├── metro
# │   └── metro.py
# ├── pop
# │   └── pop.py
# ├── service
@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

Keybase proof

I hereby claim:

  • I am Lanzafame on github.
  • I am lanzafame (https://keybase.io/lanzafame) on keybase.
  • I have a public key whose fingerprint is EF20 ADEC 164F 872B 23A2 EF3B BD9F 078F 3E60 560B

To claim this, I am signing this object:

@lanzafame
lanzafame / Test.java
Last active January 22, 2016 03:58
Java vs Golang AWS t2.micro
public class Test {
public static void main(String[] args) throws InterruptedException {
String numberList[] = {
"1",
"2",
"3",
"4",
"5",
"6",
@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{}) {
@lanzafame
lanzafame / concurrency-in-go.md
Last active September 4, 2015 03:11 — forked from kachayev/concurrency-in-go.md
Channels Are Not Enough or Why Pipelining Is Not That Easy