Skip to content

Instantly share code, notes, and snippets.

View edgardleal's full-sized avatar
💻
working from home

Edgard Rosberg Duarte Leal edgardleal

💻
working from home
View GitHub Profile
@edgardleal
edgardleal / find.vim
Last active July 29, 2016 01:10
A vimscript function o search and open for a file inside vim
function! PrompedFind()
let l:file = input("File name: ")
:call Find(l:file)
endfunction
nnoremap <Leader>t :call PrompedFind()<CR>
" Find file in current directory and edit it.
function! Find(name)
" " let l:list=system("find . -name '".a:name."' | perl -ne 'print \"$.\\t$_\"'")
" " replace above line with below one for gvim on windows
@edgardleal
edgardleal / Benchmark.java
Created July 27, 2016 20:06
A simple static class to mark duration of execution in same part of your Java code.
static class Benchmark {
static HashMap<String, Double> points = new HashMap<String, Double>();
public static void start(final String label) {
points.put(label, (double) System.nanoTime());
}
public static void end(final String label) {
points.put(label, System.nanoTime() - points.get(label));
}
public static void print() {
@edgardleal
edgardleal / import_bash_history_to_zshell_history.sh
Last active July 9, 2016 21:22
Import bash_history to your zshell history file ( ~/.zsh_history )
#!/bin/bash -
#title :import_bash_history_to_zshell.sh
#description :This script import all commands history finded in ~/.bash_history to ~/.zsh_history in zshell format
#author :Edgard Leal <[email protected]>
#date :20160705
#version :0.1
#usage :bash import_bash_history_to_zshell.sh
#notes :
#bash_version :4.1.5(1)-release
#==============================================================================
@edgardleal
edgardleal / gpg-import-and-export-instructions.md
Created April 24, 2016 20:51 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@edgardleal
edgardleal / .bashrc or .profile
Created September 21, 2015 15:39
My personal .bashrc file
#------------------------------------------////
# Aliases:
#------------------------------------------////
## make ls list by size
##alias ls='du -s */* | sort -n'
#!/bin/bash
# # ~/.netrc
# machine ftp.example.com
# login user
# password secret
declare -r last_deploy_file=".last_deploy"
declare -r exclude="*.swp"
declare -r stop_deploy_file=".stop_deploy"
declare -r running_file=".running"
@edgardleal
edgardleal / install.sh
Last active August 29, 2015 14:06 — forked from julesbou/install.sh
###
### Debian configuration
###
# --- Bashrc ---
echo "
@edgardleal
edgardleal / make_postgresql_bacula_tables
Created August 31, 2014 17:44
Script to create bacula tables on postgresql
CREATE TABLE Filename
(
FilenameId serial not null,
Name text not null,
primary key (FilenameId)
);
ALTER TABLE Filename ALTER COLUMN Name SET STATISTICS 1000;
CREATE UNIQUE INDEX filename_name_idx on Filename (Name);