In my apartment we had pppoe connection that I could configure with “
sudo pppoeconf“. However, when I moved to a new place where a direct connection was provided without pppoe, my network settings didn’t work. My laptop still wanted to connect through pppoe… I tried to execute
pppoeconf again, but it said “no pppoe is available”. Great!
Remove pppoe settings manually. First, edit
/etc/network/interfaces and comment out the pppoe part:
auto lo iface lo inet loopback # auto dsl-provider # iface dsl-provider inet ppp # pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf # provider dsl-provider auto eth0 iface eth0 inet manual
Then change the last line from
iface eth0 inet dhcp
Remove the file
/etc/ppp/peers/dsl-provider. Finally, restart networking: “
sudo /etc/init.d/networking restart“.
This tip was taken over from here.
When you visit a subreddit on reddit.com, for instance http://www.reddit.com/r/python, at the bottom of the page you will find just a “next” link to the next page. Needless to say, browsing older entries like that is a PITA…
I made a simple script that generates a static HTML page with links to all the older pages:   …
You can find the script
reddit_get_all_pages.py in my Bash-Utils collection, in the
Customize the constant
This script made me figure out that reddit lists only the last 1000 posts! Older posts are hidden. If you have a direct link to them, fine, otherwise they are gone :( So this script will only list 40 pages. This is a limitation of reddit.
If you used DOS, you must have had Norton Commander on your machine, which was the first orthodox file manager. The first version was released in 1986.
Today I learned that there exists Norton Commando too, which was a British made motorcycle with a twin cylinder engine, produced by the Norton Motorcycle company. During the ten years it was in production it was popular all over the world. In the United Kingdom it won the MCN “Machine of the Year” competition for five successive years from 1968-1972. Some regard it as the British Motorcycle Industry’s swan song, selling well from its introduction in 1967 through the end of the British bike industry as a commercial concern in the mid 1970s. (from wikipedia)
“Marakana‘s raison d’être is to help people get better at what they do professionally. We accomplish this by organizing software training courses (both public and private) as well as publishing learning resources, sharing knowledge from industry leaders, providing a place to share useful tidbits and supporting the community. Our focus is open source software.”
You have an unreadable JSON file from which you want to extract some data… How to prettify it, i.e. how to make it human readable?
There are web-based and command-line solutions. As an extra, we show you how to do it in Vim too.
- http://chris.photobooks.com/json/default.htm (it can show you the path of a tag too)
- http://jsonformatter.curiousconcept.com/ (formatter and validator)
curl -s http://www.reddit.com/r/nsfw/.json | python -mjson.tool
sudo apt-get install edit-json; prettify_json myfile.json
This tip is based on this post: Editing json files in vim.
.vimrc file I had to add the following lines:
" pretty-print JSON files autocmd BufRead,BufNewFile *.json set filetype=json " json.vim is here: http://www.vim.org/scripts/script.php?script_id=1945 autocmd Syntax json sou ~/.vim/syntax/json.vim " json_reformat is part of yajl: http://lloyd.github.com/yajl/ autocmd FileType json set equalprg=json_reformat
When opening a
.json file, it will be colored using the
json.vim syntax file. Selecting a text and pressing the “
=” button will indent the marked text using
There are several JSON visualizer add-ons for Firefox, e.g. JSONView.
You want to download a webpage and print its content to the standard output. For instance you want to push it through a pipe for further processing.
The easiest way is to use “curl” since by default it prints the downloaded content to the stdout:
curl http://www.python.org | less
You might want to add the switch “
-s” to make curl silent, i.e. hide the progress bar.
wget” it’s a bit more complicated:
wget -qO- http://www.python.org | less
If you want to add syntax highlighting to
less, see this post.
This entry is based on this post: Redirecting wget to STDOUT – now with Syntax Highlighting.
Less is a program similar to more, but it allows backward movement in the file as well as forward movement. Example:
cat big_text_file.txt | less
If you have vim installed, it comes with a script called
less.sh that acts as a replacement of
less providing syntax highlighting. Here is how to use it:
$ locate less.sh /usr/share/vim/vim73/macros/less.sh $ sudo ln -s /usr/share/vim/vim73/macros/less.sh /usr/bin/vless $ curl http://www.python.org | vless
You have a binary sqlite3 database file and you want to make some queries on it: find out what tables it has, look at the content of the tables, etc.
There is a command called “
sqlite3” which is a client for sqlite3 databases. Let’s say our database is stored in a file called “
database.sqlite“. (Here “
.sqlite” is the file extension.)
# open database.sqlite with the client: sqlite3 database.sqlite # let's get the list of tables in this database: .tables # Say it has a table called "images". Let's see its content: select * from images;
To learn more about the commands, just type “
.help” in the client. You can dump a database in SQL text format, you can get the schema of a table, etc.
.sqlite database files are binary files, you can open them with a text editor too. At the top you can see the schemas of the tables in text format. Just be careful not to modify it.
Create a database from a schema (update 20111120)
sqlite3 database.sqlite < schema.sql