Skip to content

Instantly share code, notes, and snippets.

View snipets.sql
Getting the list of rows per table
```
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;
```
search_columns
```
@mberrueta
mberrueta / Dokerfile
Last active Oct 20, 2018
InsecureProgramming
View Dokerfile
FROM debian:stable
RUN apt update
RUN apt install -y git gcc gcc-multilib g++-multilib python vim gdb
# RUN sysctl -w kernel.randomize_va_space=0 # disable secuty flags
RUN git clone https://github.com/gerasdf/insecureProgramming/
WORKDIR /insecureProgramming/exercises/
# copy Host to container ADD /my_app_folder /my_app_folder
@mberrueta
mberrueta / bin-squash_migrations
Created May 10, 2018 — forked from bf4/bin-squash_migrations
Squash Rails migrations in this one easy step
View bin-squash_migrations
#!/usr/bin/env bash
git ls-files db/migrate/*.rb | sort | tail -1 | \
ruby -e "schema_version=STDIN.read[/\d+/]; init_schema=%(db/migrate/#{schema_version}_init_schema.rb);
%x(git rm -f db/migrate/*.rb;
mkdir db/migrate;
git mv db/schema.rb #{init_schema};
rake db:migrate;
git add db/schema.rb; git commit -m 'Squashed migrations')"
@mberrueta
mberrueta / git-recover-branch.md
Created Sep 21, 2017 — forked from jbgo/git-recover-branch.md
How to recover a git branch you accidentally deleted
View git-recover-branch.md

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
View slack_heroku_notifier.py
import httplib, json
import getopt, sys, os
import subprocess
def get_data_from_git(format_string, commit):
return subprocess.check_output(['git', 'log', '-1', '--format=format:%s' % format_string, commit])
def get_author(commit):
return get_data_from_git('%an', commit)
View slack_notifier.py
import httplib, json
import getopt, sys, os
import subprocess
def get_data_from_git(format_string, commit):
return subprocess.check_output(['git', 'log', '-1', '--format=format:%s' % format_string, commit])
def get_author(commit):
return get_data_from_git('%an <%ae>', commit)
You can’t perform that action at this time.