Favoritos #013


eww “pular para conteúdo”

[2017-02-06 Mon]
A new command ‘R’ (‘eww-readable’) will try do identify the main
textual parts of a web page and display only that, leaving menus and
the like off the page.

calc user-defined units

[2017-07-02 Sun]
man 1 units

;;; Custom units stored by Calc on Sat Sep 16 13:26:22 2017
(setq math-additional-units
        (bit    nil            "Bit")
        (bps    "bit / s"     "Bit per second")
        (byte   "8 * bit"      "Byte")
        (kilobyte    "1024 * byte"      "KiloByte")
        (megabyte    "1024 * kilobyte"  "MegaByte")
        (gigabyte    "1024 * megabyte"  "GigaByte")
        (terabyte    "1024 * gigabyte"  "MegaByte")
        (petabyte    "1024 * terabyte"  "PetaByte")
        (exabyte     "1024 * petabyte"  "ExaByte")
        (zettabyte   "1024 * exabyte"   "Zettabyte")
        (yottabyte   "1024 * zettabyte" "Yottabyte")
        (brontobyte  "1024 * yottabyte" "BrontoByte")
      math-units-table nil
;;; End of custom units


[2017-08-23 Wed]
ótima solução

C-x C-j => enable copy from term-mode

[2017-09-04 Mon]
‘C-c C-j’
Switch to line mode (‘term-line-mode’). Do nothing if already in
line mode.

info:emacs#Term Mode

Performance Index Everything

[2017-09-25 Mon]
A more generic solution is to place all data in a jsonb column and create a gin
index. The gin index indexes every json key and value, and only stores the keys and
values once in the index. This is a great “index everything” option for
administrators that aren’t sure of their indexing needs.
Bruce Momjian: Postgres Blog

Tracking and managing your Postgres connections – Craig Kerstiens

[2017-09-25 Mon]
1 SELECT count(*),
2 state
3 FROM pg_stat_activity

EXWM Wiki · GitHub

[2017-09-03 Sun]
howto create an X11 like CLI to automation?

  • wrappers
  • helpers
  • xdotool
  • […]


[2017-10-11 Wed]
undo-tree Treat undo history as a tree


  • Note taken on [2017-10-23 Mon 08:43]
    /home/jimmy/Downloads/movies/Emacs-Calc – The Poor Man’s Mathematica-14742598.mp4

<f1> ? (help-for-help)

[2017-12-07 Thu]
Here’s my Emacs cheat sheet:

<f1> ? (help-for-help)

A(nother) new cheatsheet : emacs

sql – How to use multiple WITH statements in one PostgreSQL query? – Stack Overflow

[2018-01-31 Wed 15:26]
, cte2 AS (SELECT…)


Standard SQL Features Where PostgreSQL Beats its Competitors

FILTER Since SQL::2003
SQL::2003 allows FILTER (WHERE…) after aggregates:


FROM sales


Standard SQL Features Where PostgreSQL Beats its Competitors

DOMAIN Since SQL::2003

A SQL domain is a set of permissible values.

OR: A way to manage CHECK constraints and DEFAULTs.


CREATE TABLE order_lines (
quantity positive_int NOT NULL,


PostgreSQL has a great extension: NOT VALID

ALTER DOMAIN unsigned_int

Enforced on INSERT & UPDATE but not for existing values

(justify-current-line ‘right)

Perl: Data Vizualization (Graphics)

  • Chart::Gnuplot – Plot graph using Gnuplot in Perl on the fly
  • Chart::Clicker – Powerful, extensible charting.
  • GD::Graph – Graph Plotting Module for Perl 5
  • Chart::Strip – Draw strip chart type graphs.
  • SVG::TT::Graph::Pie – Create presentation quality SVG pie graphs easily
  • Hypatia
  • […]

shr – Simple HTML Renderer

[2018-03-30 Fri 21:10]
shr is a built-in package.

Status: Built-In.
Summary: Simple HTML Renderer

This package takes a HTML parse tree (as provided by
libxml-parse-html-region) and renders it in the current buffer. It
does not do CSS, JavaScript or anything advanced: It’s geared
towards rendering typical short snippets of HTML, like what you’d
find in HTML email and the like.

fix tramp zsh connection issue

[[ $TERM == "dumb" ]] && unsetopt zle && PS1='$ ' && return

ssh connection struggling · Issue #1945 · syl20bnr/spacemacs · GitHub

K (magit-file-untrack) does git rm –cached

swiper: isearch with an overview.

yasnippet – Yet another snippet extension for Emacs.

numbering a list

C-x – Repeat most recently executed command.

find-file-literally – Visit file FILENAME with no conversion of any kind.

A First Look

use PDL;
use PDL::Graphics::Prima::Simple;
matrix_plot( sin( rvals( 200, 200 ) + 1 ) );

use PDL;
use PDL::Graphics::Prima::Simple;
matrix_plot( rvals( 200, 200 ) );

use PDL;
[ 2.8284271 2.236068 2 2.236068 2.8284271]
[ 2.236068 1.4142136 1 1.4142136 2.236068]
[ 2 1 0 1 2]
[ 2.236068 1.4142136 1 1.4142136 2.236068]
[ 2.8284271 2.236068 2 2.236068 2.8284271]
use PDL;
[ 0 1 2 3 4]
[ 5 6 7 8 9]
[10 11 12 13 14]
[15 16 17 18 19]
[20 21 22 23 24]

postgresql – Database “frozen” on ALTER TABLE – Database Administrators Stack Exchange

[2018-08-02 Thu 09:38]
David Spillett

add a comment |
up vote 18 down vote

The command you wish to run does take an ACCESS EXCLUSIVE lock on the table,
preventing all other access to that table. But the duration of this lock should be
just a few milliseconds, as adding a column like the one you want to add does not
require the table to be re-written, it just requires metadata to be updated.

Where the problem can come in, and I bet you dollars to donuts that it is the
problem you are seeing, is in lock priorities. Someone has a weak lock, like ACCESS
SHARE lock, on that table, and they are camping on it indefinitely (maybe an
idle-in-transaction connection which has been leaked? Someone who opened psql,
started a query in a repeatable read mode, and then went on vacation?).

The ADD COLUMN tries to take the ACCESS EXCLUSIVE it needs, and it queues up behind
the first lock.

Now all future lock requests queue up behind the waiting ACCESS EXCLUSIVE request.

Conceptually, incoming lock requests which are compatible with the already-granted
lock could jump over the waiting ACCESS EXCLUSIVE and be granted out of turn, but
that is not how PostgreSQL does it.

You need to find the process which is holding the long-lived weak lock.

You can do this by querying the pg_locks table.

select * from pg_locks where
granted and relation = ‘cliente’::regclass \x\g\x

If you do this while everything is locked up, you should get only one answer
(unless there are multiple long-lived culprits). If you do this after you already
killed the ADD COLUMN, then you might see lots of granted locks, but if you repeat
it a few times there should one or a few which are staying around each time.

You can then take the PID that you got from pg_lock, and query with that into
pg_stat_activity to see what the offender is doing:

select * from pg_stat_activity where pid=28731 \x\g\x

backend_start | 2016-03-22 13:08:30.849405-07
xact_start | 2016-03-22 13:08:36.797703-07
query_start | 2016-03-22 13:08:36.799021-07
state_change | 2016-03-22 13:08:36.824369-07
waiting | f
state | idle in transaction
backend_xid |
backend_xmin |
query | select * from cliente limit 4;

So, it ran a query, inside a transaction, and then went idle without ever closing
the transaction. It is now 13:13, so they have been idle for 5 minutes.

Is there a way to use the <=> operator in a perl if statement? – Stack Overflow

[2018-08-04 Sat 22:50]
It’s kind of obscure, but you can use the <=> operator to get an element of a dispatch table:

( sub { say ‘they are the same’ },
sub { say ‘x is greater’ },
sub { say ‘x is lesser’ }
)[$x <=> $y]->();

It’s based on the fact that the index -1 returns the last element of a list.

Using a hash might be more readable.

{ 0 => sub { say ‘they are the same’ },
1 => sub { say ‘x is greater’ },
-1 => sub { say ‘x is lesser’ }
}->{ $x <=> $y }->();

Textricator is a tool for extracting text from computer-generated PDFs and generating structured data (CSV or JSON)

Favoritos #012


Como Aprendi a Fazer Dinheiro no Jogo Suikoden Tierkreis

Demorei a entender alguns macetes desse jogo e estava enfrentando sérias restrições orçamentárias, sofrendo muitas privações, passando por necessidades, matando cachorro a gritos, na pindaíba, amargando a realidade, com o bucho apregado no espinhaço etc e “tals”… Até que finalmente aprendi como o acesso ao único deus deste mundo é feito dentro do jogo 😁.

continue lendo…

Trabalhando com arquivos JSON no PostgreSQL

json_logo.png & postgres.jpg

Recentemente, um amigo meu encontrou problemas para trabalhar com arquivos json por estar habituado apenas à arquivos csv. Embora existem várias formas automatizadas para converter arquivos json para csv (mas não existem garantias de que a saída seria aceitável) o foco era o de carregar os dados no PostgreSQL para sumarizações e outros tipos de tratamentos e cruzamentos, e este também é o foco deste post.

Continue lendo…

Favoritos #011


Favoritos #010


Favoritos #009


Tropeçando nos próprios erros… #001

Bem não é normal alguém falar sobre os próprios erros. Um erro não é algo socialmente bem visto e tando no ambiente familiar quanto no escolar eles costumam ser rechaçados e, junto doutros fatores, criam uma cultura anti-erros onde até erros críticos dentro de empresas são escondidos até as últimas consequências… Bem, comigo nada disso aí funciona…

Continue lendo…