Skip to content

Instantly share code, notes, and snippets.

View madhukar93's full-sized avatar

Madhukar Mishra madhukar93

View GitHub Profile
from django.db import models
from django.db.models import F
class TestModel(models.Model)
uid = models.IntegerField()
big_complicated_name = models.CharField()
TestModel.objects.annotate(name=F('big_complicated_name'))
@madhukar93
madhukar93 / flask_profiler.py
Created February 2, 2016 04:11 — forked from shreyansb/flask_profiler.py
A profiler for Flask apps
"""
This module provides a simple WSGI profiler middleware for finding
bottlenecks in web application. It uses the profile or cProfile
module to do the profiling and writes the stats to the stream provided
To use, run `flask_profiler.py` instead of `app.py`
see: http://werkzeug.pocoo.org/docs/0.9/contrib/profiler/
and: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvi-debugging-testing-and-profiling
"""
module Learn where
x = 10
* 5
+ y -- why is this not a parse error, isn't this incorrect indentation
myResult = x * 5
y = 10
module Pg81 where
x + 9001
where x = 10
-- c where a = b
-- is the same as
-- let a = b in c
-- is the same as
-- (\a -> c) b
set-option -g default-command "reattach-to-user-namespace -l zsh"
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-open'
#set -g @plugin 'jimeh/tmux-themepack'
# Key bindings
@madhukar93
madhukar93 / branchname.groovy
Created July 26, 2018 07:57
branch name should contain issue type and issue ID
def check_branch_name = { name ->
jira_issue_re = /.*\(((?<!([A-Z]{1,10})-?)[A-Z]+-\d+)\)$/ // any chars followed by jira issue ID at the end
pr_type_re = /^(?i)(bugfix|enhancement|feature|hotfix)-.*/ // pr type followed by any chars
name =~ jira_issue_re && name =~ pr_type_re
}
check_branch_name "BGfix-hello world-(CN-85)"
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
Plug 'https://github.com/tpope/vim-sensible'
Plug 'https://github.com/tpope/vim-surround'
Plug 'https://github.com/tpope/vim-repeat'
Plug 'https://github.com/kien/ctrlp.vim'
Plug 'https://github.com/vim-scripts/auto-pairs-gentle'
Plug 'https://github.com/airblade/vim-gitgutter'
Plug 'https://github.com/eagletmt/ghcmod-vim.git'
"Plug 'https://github.com/c0r73x/neotags.nvim.git' < using tagbar instead
# open streams
```
stdin_open: true
tty: true
```
# run this to get into console
docker attach <instance>
@madhukar93
madhukar93 / .zshrc
Created November 12, 2018 10:07 — forked from bmhatfield/.zshrc
OSX Keychain Environment Variables
# If you use bash, this technique isn't really zsh specific. Adapt as needed.
source ~/keychain-environment-variables.sh
# AWS configuration example, after doing:
# $ set-keychain-environment-variable AWS_ACCESS_KEY_ID
# provide: "AKIAYOURACCESSKEY"
# $ set-keychain-environment-variable AWS_SECRET_ACCESS_KEY
# provide: "j1/yoursupersecret/password"
export AWS_ACCESS_KEY_ID=$(keychain-environment-variable AWS_ACCESS_KEY_ID);
export AWS_SECRET_ACCESS_KEY=$(keychain-environment-variable AWS_SECRET_ACCESS_KEY);
from influxdb import InfluxDBClient
db = "ci-metrics-testing"
client = InfluxDBClient("localhost", 8086, "root", "root", db)
client.create_database(db) # TODO: check if this overrites previous db
days = [
# 1
{
"measurement": "commits",