Skip to content

Instantly share code, notes, and snippets.

View jdevera's full-sized avatar

Jacobo de Vera jdevera

View GitHub Profile
@jdevera
jdevera / ssh-agent-start.sh
Created October 13, 2016 10:03
Function to start an ssh agent or load a running one into the current environment
function ssh-agent-start()
{
local agentfile=~/.ssh/agent
if [[ -f $agentfile ]]
then
source $agentfile > /dev/null
if ps -p "$SSH_AGENT_PID" > /dev/null
then
echo "Agent running with PID $SSH_AGENT_PID"
return
@jdevera
jdevera / tmux.terminfo
Last active November 16, 2015 11:37 — forked from tarruda/tmux.terminfo
tmux terminfo for italics
# Custom terminfo for better using tmux with urxvt, 256colors and italics
# Compile/install with `tic tmux.terminfo`, then set $TERM to "tmux"
# (it requires a program that uses `tgetent` to obtain terminal
# information)
tmux|tmux with rxvt-unicode-256color client,
use=rxvt-unicode-256color,
use=screen,
@jdevera
jdevera / VundleWeb
Created April 5, 2015 21:35
Visit the github page of a Vundle managed plugin
function! VundleVisitPluginPage(plugin_name)
if !exists('g:vundle#bundles')
echomsg 'Could not find Vundle plugins'
return
endif
if !exists('g:web_browser')
echomsg 'Set your web browser executable to g:web_browser'
return
endif
let uri = ''
@jdevera
jdevera / pr.md
Last active August 29, 2015 14:17 — forked from piscisaureus/pr.md

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:

@jdevera
jdevera / matcher.py
Last active December 29, 2015 07:58
A python class to do saner "if..match"
class Matcher(object):
"""
A more convenient way to check regex matches. It holds the latest match
result for further checks.
The current regex match mechanism does not allow for checking matches in
if/elif chains. Thanks to Matcher now one can do this:
>>> m = Matcher()
>>> s = "ba"
@jdevera
jdevera / sub-sh-evalme
Created June 4, 2013 23:58
Structure for subs that output code to be eval'ed
#!/usr/bin/env bash
set -e
if [[ $1 != '__testrun__' ]]; then
sed '1,/^#BEGINEVAL/d' "$BASH_SOURCE"
exit 0
fi
#BEGINEVAL
@jdevera
jdevera / objectify.py
Created November 15, 2012 11:08
Python Data Structure Objectifier
#!/usr/bin/env python
"""
An objectifier for python data structures based on standard containers.
Based on sveral answers to this stackoverflow question:
http://stackoverflow.com/q/1305532/116957
Licensed under Creative Commons Attribution-ShareAlike
http://creativecommons.org/licenses/by-sa/3.0/
"""
@jdevera
jdevera / new_bashrc.sh
Created August 11, 2012 12:39 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful.
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
# Are you tired of trying to remember how darwin/mac-osx treat them differently from linux?
# Are you tired of not having your ~/.bash* stuff work the way you expect?
#
# Symlink all of the following to this file:
# * ~/.bashrc
@jdevera
jdevera / tree.md
Created April 24, 2012 08:36 — forked from hrldcpr/tree.md
one-line tree in python

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!

@jdevera
jdevera / gist:1481602
Created December 15, 2011 15:56
Sm completion error
# sm --trace=all --call=api/extensions/completion/extension_action_completion -- sm
+/opt/sm/core/sm/shell/core/cli:124 /opt/sm/core/sm/shell/core/cli():124 > debug_flags=-search
+/opt/sm/core/sm/shell/core/cli:125 /opt/sm/core/sm/shell/core/cli():125 > trace_flags=all
+/opt/sm/core/sm/shell/core/cli:127 /opt/sm/core/sm/shell/core/cli():127 > export debug_flag debug_flags trace_flag trace_flags verbose_flag extension_args sm_script var_debug_flags var_debug_type_flag
+/opt/sm/bin/sm:29 /opt/sm/bin/sm():29 > . /opt/sm/core/sm/shell/core/initialize
+/opt/sm/core/sm/shell/core/initialize:4 /opt/sm/core/sm/shell/core/initialize():4 > setopt EXTENDED_GLOB NULL_GLOB HASH_CMDS WARN_CREATE_GLOBAL
+/opt/sm/core/sm/shell/core/initialize:6 /opt/sm/core/sm/shell/core/initialize():6 > saved_sm_path=/opt/sm
+/opt/sm/core/sm/shell/core/initialize:9 /opt/sm/core/sm/shell/core/initialize():9 > file=/etc/smrc
+/opt/sm/core/sm/shell/core/initialize:11 /opt/sm/core/sm/shell/core/initialize():11 > [[ -s /etc/smrc ]]
+/opt/sm/c