Tools
Backup Your Facebook Data
This post includes “Thoughts about Facebook and You”, and a link to a great tool to backup your Facebook data.
If you use Facebook, the first thing you should know is: Never trust these bastards! They don’t give a shit on your privacy, they want (and do) own YOUR data, they can “deactivate” your account without a warning, without an explanation, and even without a good reason.
A Bash Script to Convert brainfuck Code Into C
Brainfuck is a minimalist Turing Complete language. You can read about it here.
The following bash script takes a file with brainfuck code (legal characters are >< ,.+-[] any other characters are ignored), and generates its C equivalent code, which can then be compiled with a C compiler and executed.
The output of this script lacks indentation. If you insist on having the C code indented you can achieve this by passing the output through a pipe to “indent”, “astyle” or similar programs.
The script should be called in the following way:
./bf.sh code.bf > code.c
Where code.bf is the file containing the brainfuck code.
Tiny Bash Functions to Convert Between Numeric Representations
I have these functions in my aliases file. They make it easy to convert between hex, binary and decimal representations of numbers. You might find it useful.
Just add these to your aliases file (imported from ~/.bashrc):
1 2 3 4 5 6 | function h2d { echo "obase=10; ibase=16; $( echo "$*" | sed -e 's/0x//g' -e 's/\([a-z]\)/\u\1/g' )" | bc; } function h2b { echo "obase=2; ibase=16; $( echo "$*" | sed -e 's/0x//g' -e 's/\([a-z]\)/\u\1/g' )" | bc; } function b2d { echo "obase=10; ibase=2; "$*"" | bc; } function b2h { echo "0x$(echo "obase=16; ibase=2;"$*"" | bc)"; } function d2b { echo "obase=2; ibase=10; "$*"" | bc; } function d2h { echo "0x$(echo "obase=16; ibase=10; "$*"" | bc)"; } |
Now you should be able to use it like this:
h2d 0xff
The output will be 255 in this case.
h2b is for “hex to binary”, the others are similar (h: hex, b: binary, d: decimal)
Enjoy
A Program for Bit-Slicing
I wrote this short program in C because I needed to do some bit-slicing in some homework. It's not too generic (accepts only 32 bit integers) but it can help in most cases.
An example usage of the program:
bs 0x12345678 31 4
Will give the following output:
0x12345678[31:4] = 0x1234567› Continue reading
About Me
Tags
Categories
- Algorithms
- Bash
- BlackBerry
- Collaboration
- Command Line
- Cool Tricks
- Easter Eggs
- Ebooks
- Firefox
- Hardware
- Humor
- iPhone
- Linux
- Linux Development
- Linux Kernel
- Networks
- Open Knowledge
- Other
- Productivity
- Programming
- Regular Expressions
- Science
- Security
- Shell Scripts
- Short Posts
- Social Networks
- Thoughts
- Tools
- Vim
- Web Development
- Websites
Popular Posts
Calendar
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| « Sep | ||||||
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | |||
Archives
- September 2010 (2)
- August 2010 (2)
- July 2010 (5)
- June 2010 (1)
- May 2010 (1)
- April 2010 (3)
- March 2010 (1)
- January 2010 (1)
- December 2009 (2)
- September 2009 (13)
- July 2009 (1)
- June 2009 (6)
- May 2009 (4)
- March 2009 (18)
- February 2009 (10)
- January 2009 (10)
- December 2008 (7)
- November 2008 (8)
- October 2008 (1)
- August 2008 (1)
- July 2008 (1)
- June 2008 (1)
