Skip to content

Instantly share code, notes, and snippets.

View tmacam's full-sized avatar

Tiago Alves Macambira tmacam

View GitHub Profile
@tmacam
tmacam / git_prompt.sh
Created May 24, 2013 13:43
Git prompt in my bashrc
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_ps1 "\n(%s)")\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 "\n(%s)")\$ '
fi
@tmacam
tmacam / here.py
Created May 29, 2013 13:40
Handy python function to print the current executing python line number , function name and filename.
from inspect import getframeinfo, getouterframes, currentframe
def HERE():
info = getframeinfo(getouterframes(currentframe())[1][0])
print "\t__HERE: @%s %s:%d" % (info.function, info.filename, info.lineno)
@tmacam
tmacam / .vimrc
Created December 16, 2013 12:26 — forked from flaviotruzzi/.vimrc
" Sample .vimrc file by Martin Brochhaus
" Presented at PyCon APAC 2012
" ============================================
" Note to myself:
" DO NOT USE <C-z> FOR SAVING WHEN PRESENTING!
" ============================================
# just in case
curl -XDELETE http://localhost:9200/inall
curl -XPUT http://localhost:9200'/inall/' -d '{
"mappings": {
"thing": {
"include_in_all": false,
"type": "object",
"_all" : {
@tmacam
tmacam / es_uppercase_bug_curl_session.sh
Created May 15, 2014 14:36
Uppercase token filter not being correcly registerred?
#!/bin/bash
export ELASTICSEARCH_ENDPOINT="http://localhost:9200"
# Create indexes
# DELETE indexes consecutive tests
curl -XDELETE "$ELASTICSEARCH_ENDPOINT/play"
curl -XPUT "$ELASTICSEARCH_ENDPOINT/play" -d '{
@tmacam
tmacam / relatorio.sublime-syntax
Last active July 28, 2022 23:03
Aditional syntax config to make editing my org-like worklog easier.
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: relatorio
file_extensions: [md]
scope: text.html.markdown
contexts:
main:
- match: '\b(PENDING)\b'
scope: keyword.control.c
@tmacam
tmacam / README.md
Created July 20, 2022 17:12 — forked from tpitale/README.md
Sublime Text plugin to create a simple timestamp
  1. Go to Tools > New Plugin
  2. Paste timestamp.py contents and save in User as timestamp.py
  3. Open Preferences > Key Bindings - User (or Default, your call)
  4. Paste keybindings.json, or add a line to your keybindings
  5. Customize the keyboard shortcut to your liking and save
# -*- coding: utf-8 -*-
from datetime import datetime
import time
import sublime_plugin
class TimestampCommand(sublime_plugin.EventListener):
"""Expand `isoD`, `now`, `datetime`, `utcnow`, `utcdatetime`,
`date` and `time`
@tmacam
tmacam / state_for_all_components.py
Created August 3, 2022 22:47
Util script for dapr/dapr-docs project
from dataclasses import dataclass
import pathlib
import yaml
from operator import itemgetter
YAML_SUFFIX_LENGTH = len('.yaml')
@dataclass
class Component:
building_block: str
@tmacam
tmacam / chcluster.sh
Created September 29, 2023 22:20
dialog to change current kubectl context
#!/bin/bash
set -e
selected=$(
dialog --radiolist "Choose cluster" 0 0 0 $(
kubectl config get-contexts | sed -e 's/^ /off/' -e 's/^\*/on/' -e 1d | awk '{print $2,$3,$1 }'
) 2>&1 > /dev/tty
)