Skip to content

Instantly share code, notes, and snippets.

View RodrigoCMoraes's full-sized avatar

RodrigoCMoraes RodrigoCMoraes

  • São Paulo, SP, Brazil
View GitHub Profile

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 7, 2024 13:22
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@awidegreen
awidegreen / vim_cheatsheet.md
Last active June 17, 2024 03:41
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@jeekl
jeekl / gist:5083519
Created March 4, 2013 16:32
git pre-commit hook to validate json objects so you don't commit broken json.
#!/usr/bin/env bash
# Runs all .json or .js files through pythons json lint tool before commiting,
# to make sure that you don't commit broken json objects.
git_dir=$(git rev-parse --show-toplevel)
for file in $(git diff-index --name-only --diff-filter=ACM --cached HEAD -- \
| grep -P '\.((js)|(json))$'); do
python -mjson.tool $file 2> /dev/null
if [ $? -ne 0 ] ; then
@mislav
mislav / _readme.md
Last active June 28, 2024 15:16
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@ondrejh
ondrejh / mountnfs.sh
Created January 29, 2014 10:43
Bash script: Wakeup and mount NFS server.
#!/bin/bash
#
# This script should do:
#
# 1) test if nfs folder is mounted and exit 0 if yes
# 2) try to mount it and exit 0 if success
# 3) try to wake the server if not possible to mount
# 4) wait while its not woked (pinging)
# 5) try againt 2-4 several times
@mminer
mminer / cachedecorator.py
Created January 12, 2015 23:57
An example of a Python decorator to simplify caching a function's result.
"""An example of a cache decorator."""
import json
from functools import wraps
from redis import StrictRedis
redis = StrictRedis()
def cached(func):
@vbalnt
vbalnt / siamese.py
Last active March 1, 2019 01:50
train on siamese graph - custom mini batches
'''Train a Siamese MLP on pairs of digits from the MNIST dataset.
It follows Hadsell-et-al.'06 [1] by computing the Euclidean distance on the
output of the shared network and by optimizing the contrastive loss (see paper
for mode details).
[1] "Dimensionality Reduction by Learning an Invariant Mapping"
http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf
Run on GPU: THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python mnist_siamese_graph.py
@nikhilkumarsingh
nikhilkumarsingh / file_downloader.py
Last active June 24, 2024 12:15
A file downloader with progress bar for terminal
from tqdm import tqdm
import requests
chunk_size = 1024
url = "http://www.nervenet.org/pdf/python3handson.pdf"
r = requests.get(url, stream = True)
total_size = int(r.headers['content-length'])
@ashokpant
ashokpant / cuda_9.0_cudnn_7.0.sh
Last active November 16, 2023 21:42
Install CUDA Toolkit v9.0 and cuDNN v7.0 on Ubuntu 16.04
#!/bin/bash
# install CUDA Toolkit v9.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb)
CUDA_REPO_PKG="cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb"
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda-9-0