We moved to a new home.
http://hackingbits.github.io/
See you there.
Hacking bits
0101011101101000011110010010000001101110011011110111010000111111
sexta-feira, 23 de outubro de 2015
segunda-feira, 18 de maio de 2015
How to find out the current (in use) XServer DISPLAY number!
Well, just the hack of the day.
$ ps u | awk -v tty=$(cat /sys/class/tty/tty0/active) '$0 ~ tty { print $2 }' | while read pid && [[ "$display" == "" ]]; do display="$(awk -v RS='\0' -F= '$1=="DISPLAY" { print $2 }' /proc/$pid/environ)"; if [ "$display" != "" ]; then echo "$display"; fi; done 2>/dev/null
:0
Can you improve it? So tell me how. o/
The discussion about the theme on Quora and Linkedin.
Edited with improvement:
http://www.commandlinefu.com/commands/view/14259/find-out-the-active-xorg-server-display-number-from-outside
$ for p in $(pgrep -t $(cat /sys/class/tty/tty0/active)); do d=$(awk -v RS='0' -F= '$1=="DISPLAY" { print $2 }' /proc/$p/environ 2>/dev/null); [[ -n $d ]] && break; done; echo $d
The discussion about the theme on Quora and Linkedin.
__________________________
Edited with improvement:
http://www.commandlinefu.com/commands/view/14259/find-out-the-active-xorg-server-display-number-from-outside
$ for p in $(pgrep -t $(cat /sys/class/tty/tty0/active)); do d=$(awk -v RS='0' -F= '$1=="DISPLAY" { print $2 }' /proc/$p/environ 2>/dev/null); [[ -n $d ]] && break; done; echo $d
quinta-feira, 18 de setembro de 2014
A book to study C, or NOT!
As promised I'm back to talk about the Programming in C (4th Edition) book. Well, I'll paste my amazon's review, to be short.
"When I started this reading soon I became absorbed by the formation of the writer's words. Unfortunately that feeling did not persist throughout the work. I still read until functions chapter, but the book is not renewed in style. There's much prolonged talk for bit subjects... For me a boring approach. The author uses many almost useless, in day-to-day, mathematical examples. A beginner will give up of C language or seek another book that is more aimed.
I still prefer the Expert C Programming: Deep C Secrets by Peter van der Linden that invites you to understand language with real facts about C, and The C Programming Language by the creators of the Language that despite being old and summarized, informs the reader about the language accurately."
It's yours choice.
Cheers.
terça-feira, 26 de agosto de 2014
A book to study C
I received my copy of Programming in C (4th Edition) (Developer's Library) from Pearson today.
The book is dense with 548 pages and, at first glance, a great resource for beginners and advanced C coders. I'll let you know more about my reading. Just wait.
The book is dense with 548 pages and, at first glance, a great resource for beginners and advanced C coders. I'll let you know more about my reading. Just wait.
sexta-feira, 15 de agosto de 2014
Odd ways to zeroing some x86_64 registers
Hi there! Here are some ways (retrocompatible instructions [1-2] and xmm) to fill registers with zero (NULL) bytes without have any zero bytes in bytecode.
400093: 58 pop %rax
400094: ff c8 dec %eax
Zeroing (1) %RAX at 5 bytes cost (very known indeed).
40008b: 97 xchg %eax,%edi
40008c: 48 c1 c8 20 ror $0x20,%rax
400090: 97 xchg %eax,%edi
Zeroing (1) %RDI at 6 bytes cost.
40008b: 92 xchg %eax,%edx
40008c: 48 99 cqto
Zeroing (1) %RDX at 3 bytes cost.
40008b: 92 xchg %eax,%edx
40008c: 48 99 cqto
40008e: 52 push %rdx
40008f: 58 pop %rax
Zeroing (2) %RDX e %RAX at 5 bytes cost.
40008b: 48 31 ff xor %rdi,%rdi
40008e: 48 f7 e7 mul %rdi
Zeroing (3) %RAX, %RDX e %RDI at 6 bytes cost (however, widely known).
40008b: 97 xchg %eax,%edi
40008c: 48 c1 c8 20 ror $0x20,%rax
400090: f7 e7 mul %edi
400092: 50 push %rax
400093: 5f pop %rdi
Zeroing (3) %RAX, %RDX e %RDI at 9 bytes cost.
400090: c5 fc 77 vzeroall
400093: 66 48 0f 7e c2 movq %xmm0,%rdx
Zeroing (1) general-purpose reg %RDX and (all) YMM at 8 bytes cost.
400090: 66 0f df c0 pandn %xmm0,%xmm0
400094: 66 48 0f 7e c2 movq %xmm0,%rdx
Zeroing (1) general-purpose reg %RDX and (1) %XMM0 at 9 bytes cost.
400090: 50 push %rax
400091: 5a pop %rdx
400092: 48 f7 d2 not %rdx
400095: 48 21 d0 and %rdx,%rax
Zeroing (1) %RAX at 8 bytes cost.
400097: 52 push %rdx
400098: 58 pop %rax
400099: f7 d0 not %eax
40009b: 21 c2 and %eax,%edx
Zeroing (1) %RDX at 6 bytes cost.
Use them at will.
[1] - How NOP nearly became a non-NOP on AMD64
[2] - x86oddities
sexta-feira, 25 de julho de 2014
Você Fiscal!!! Eleições...
Temos a oportunidade de sermos fiscais de verdade nas próximas eleições. Para isso, o mínimo que podemos fazer, neste momento, é contribuir com o Projeto Você Fiscal (Diego Aranha) e divulgá-lo o máximo possível.
Eu, no momento, não acredito na discussão política atual; antes, ao meu ver, teríamos que discutir o homem em si, para só depois adentrarmos na sua política. Contudo, a iniciativa do Diego Aranha é fantástica, pois nos permite acompanhar de perto esse processo até então obscuro.
Compartilhem!!!
segunda-feira, 26 de maio de 2014
Uzumaki.el - a simple Emacs buffers cycler
I always complained about the buffer switching procedures in Emacs. So I decided to create my own method to do that, and it rocks (to me ;D ).
Check it: https://github.com/geyslan/uzumaki/
And it's also available through MELPA archive: http://melpa.milkbox.net/#/uzumaki
If you do like it, or don't, feel free to do pull requests on git.
Assinar:
Postagens (Atom)