Skip to content

Instantly share code, notes, and snippets.

@macintux
macintux / db_backup_commands.md
Created December 31, 2021 11:51 — forked from AtulKsol/db_backup_commands.md
Commands to backup & restore database
  1. pg_dump is a nifty utility designed to output a series of SQL statements that describes the schema and data of your database. You can control what goes into your backup by using additional flags.
    Backup: pg_dump -h localhost -p 5432 -U postgres -d mydb > backup.sql

    Restore: psql -h localhost -p 5432 -U postgres -d mydb < backup.sql

    -h is for host.
    -p is for port.
    -U is for username.
    -d is for database.

@macintux
macintux / beam_decompile.erl
Created November 20, 2015 15:36 — forked from andelf/beam_decompile.erl
Erlang BEAM file decompile to .erl file
#!/usr/bin/env escript
% -*- mode: erlang -*-
main([BeamFile]) ->
{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(BeamFile,[abstract_code]),
io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).
curl -XPOST http://localhost:8098/mapred
-H"Content-Type: application/json"
-d '{"inputs":"notifications","query":[{"map":{"language":"erlang","source":"fun(O,_,_) when element(1,O) == r_object -> S=byte_size(term_to_binary(riak_object:get_values(O))), if (S>1048576) -> {ok,C}=riak:local_client(),C:delete(riak_object:bucket(O),riak_object:key(O)),[riak_object:key(O)]; true -> [] end;(_,_,_) -> [] end."}}]}'