Skip to content

Instantly share code, notes, and snippets.

@microft
microft / gist:4566260
Created January 18, 2013 17:18
Vim function to forget undo history. Very usefull.
" A function to clear the undo history
function! <SID>ForgetUndo()
let old_undolevels = &undolevels
set undolevels=-1
exe "normal a \<BS>\<Esc>"
let &undolevels = old_undolevels
unlet old_undolevels
endfunction
command -nargs=0 ClearUndo call <SID>ForgetUndo()
@microft
microft / gist:5213590
Created March 21, 2013 14:46
my ~/.gitconfig
[user]
name = Luis Miguel Braga
email = luismiguel@silvabraga.com
[color]
ui = true
[alias]
lol = log --oneline --graph --decorate
pullall = submodule foreach git pull origin master
[core]
excludesfile = ~/.gitignore_global
javascript:location.href='http://attentive.us/api/article/new/?url='+encodeURIComponent(location.href)
@microft
microft / gideon.py
Created November 29, 2016 09:34
a small Flask service
from __future__ import division
import logging
from flask import Flask, request, jsonify
from gensim import corpora, models, similarities
SIMILARITY_THRESHOLD = 0.5
INDUSTRIES = {
'funding': {},
'txt50': {}
@microft
microft / 50-marblemouse.conf
Created February 9, 2019 14:41
xorg configuration for left handed logitech marble mouse (middle click and scroll) - Ubuntu 18.04
Section "InputClass"
Identifier "Logitech USB Trackbal"
MatchProduct "Logitech USB Trackball"
Driver "libinput"
Option "MiddleEmulation" "on"
Option "ScrollMethod" "button"
#Option "ButtonMapping" "1 2 3 4 5 6 7 8 9" # right handed
#Option "ScrollButton" "8" # right handed
Option "ScrollButton" "9" # left handed
Option "ButtonMapping" "3 9 1 4 5 6 7 2 8" #left handed
@microft
microft / covid.py
Created April 4, 2020 09:31
get the data from worldometers coronavirus page and display in console
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from tabulate import tabulate
chrome_options = Options()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(options=chrome_options)
driver.get('https://www.worldometers.info/coronavirus/')
output_table = []
table = driver.find_element_by_xpath('//*[@id="main_table_countries_today"]/thead[1]')
row = table.find_elements_by_tag_name("tr")[0] # get all of the rows in the table
@microft
microft / .zshrc
Created April 9, 2020 09:26
smileyface in zsh PS1
function smileyface
{
case $? in
0 )
echo -ne "$fg[green] :)"
;;
1 )
echo -ne "$fg[red] ;("
;;* )
echo -ne "$fg[yellow] %%("
@microft
microft / code.py
Created March 19, 2024 15:08
serialize a Model to JSON
from .models import YourModel
from .serializers import YourModelSerializer
from rest_framework.renderers import JSONRenderer
# Assuming you have a YourModel instance
instance = YourModel.objects.get(pk=1)
# Serialize the instance using the serializer
serializer = YourModelSerializer(instance)
@microft
microft / templated config example
Last active March 31, 2024 15:59
pydantic BaseSettings example
from pydantic import Field
from pydantic import BaseSettings
class Config(BaseSettings):
x: int
y: str | None
z: str = 'Xpto'
_config = Config()
@microft
microft / keybase.md
Last active March 31, 2024 16:00
keybase proof

Keybase proof

I hereby claim:

  • I am microft on github.
  • I am luisbraga (https://keybase.io/luisbraga) on keybase.
  • I have a public key ASBF7WEt1jT8maY_cOou8Lm_cxv8y1N0ayQ6t00tQqQTfgo

To claim this, I am signing this object: