Saturday, August 19, 2017

downloading torrents in GNU/linux (magnet URIs)

Torrents have changed so much...

Nowadays they're greatly distributed in magnet:XXX-looking URIs.
Check more about that in http://www.vuze.com/about-torrents/magnet-links.
I guess it's better than getting lots of torrent files.

Anyway, to be able to open and use these files, here's my favorite torrent client and how to use it.
It's utorrent!

http://www.utorrent.com/downloads/linux

1. Get the utorrent server (it's a server because you can actually access it from the internet too, or your LAN, but you can just use it on localhost as a normal client).
2. cd to wherever the file "utserver" is, and run "./utserver -settingspath &"
3. login to http://localhost:8080/ (user = admin, blank password by default)
4. click the chain looking icon to add a random torrent URL and you're done.

For non GUI related stuffs I liked aria2c, but it stopped working... lots of data are now being encrypted and everything, kinda going out of the original scope of a bittorrent client, which has some good and bad sides.

Anyway, have fun with utorrent.

Monday, August 7, 2017

common lisp getting drakma working from default install

Basic clisp setup to get drakma working


drakma is a lisp html client.

I'm using GNU CLISP 2.49.

If you just try to install it with the default asdf and quicklisp installed under it on debian 8 it won't work...

Anyway,
1. Install asdf's latest version https://common-lisp.net/project/asdf/ (I have 3.1.4) 
This means just downloading the source, and doing make mostly.
2. load your new asdf every time by adding it to your ~/clisprc.lisp
something like
(load "/yourhomedir/bin/lisp/clisp/asdf/build/asdf.lisp")
3. Install quicklisp https://www.quicklisp.org/beta/#installation
This is mostly downloading the install file, and doing 
(load "/yourhomedir/bin/lisp/clisp/install_ql/quicklisp.lisp")
(ql:add-to-init-file)

4. Then you're ready to install drakma
(ql:quickload :drakma) (drakma:http-request "https://www.debian.org/" :connection-timeout 'nil)
(in common lisp you need the :connection-timeout 'nil thing or it won't work... that's not very nice)

And you should be getting something the requested page on stdout:

...
...!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd
...


debian change display output interface from vga to dvi

Updating your X output interface


I have an nvidia video card, and I'm finally switching from VGA to DVI... I didn't even know I had that port till a few days ago.
I'm not adding a new display for dual/triple display, but just switching the cables for the same one and only display I have.

1. Plug in the DVI cable to your monitor and video card.
2. When you do the xrandr command, you should be seeing something like:
$ xrandr
Screen 0: minimum 8 x 8, current 1440 x 900, maximum 16384 x 16384
DVI-I-0 disconnected primary (normal left inverted right x axis y axis)
VGA-0 connected 1440x900+0+0 (normal left inverted right x axis y axis) 410mm x 260mm
   1440x900      59.89*+  74.98  
   1400x1050     74.87  
   1280x1024     75.02    60.02  
   1152x864      75.00  
   1024x768      75.03    70.07    66.00    60.00  
   800x600       75.00    72.19    60.32    56.25  
   640x480       75.00    72.81    65.99    59.94  
DVI-I-1 connected (normal left inverted right x axis y axis)
   1440x900      59.89 +  74.98  
   1400x1050     74.87  
   1280x1024     75.02    60.02  
   1152x864      75.00  
   1024x768      75.03    70.07    66.00    60.00  
   800x600       75.00    72.19    60.32    56.25  
   640x480       75.00    72.81    65.99    59.94  
HDMI-0 disconnected (normal left inverted right x axis y axis)


3. Here you see the VGA-0 (your current display), and DVI-I-1 (your new one) are connected.
The only thing to do next is:

xrandr --output DVI-I-1 --auto


4. Your monitor should blink for a moment. Then you're probably ready to go! Disconnect your VGA cable, and if you still have something on your screen, it's working, yay.

5. Disconnect your old VGA cable, and give it a good burial.

Sunday, June 4, 2017

fixing B-frames ('packed B-frames') vids

mplayer warning

[mpeg4 @ 0xb7411fe0]Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using a tool like VirtualDub or avidemux to fix it.

You'd get this warning, and video wouldn't be playable (it'd be super slow in the video stream, while the audio is OK).

Suggested fix

ffmpeg -i input_vid.avi -codec copy -bsf:v mpeg4_unpack_bframes   output_vid.avi

(didn't work, still was super slow)

Work-around

You'll need: avidemux, ffmpeg

Steps
1. convert file to avi (mine were in ogm format)

ffmpeg -i $INPUT_FILE -codec copy $OUTPUT_FILE

2. separate audio

ffmpeg -i $INPUT_FILE  -vn $OUTPUT_FILE

3. open the avi file on avidemux -> choose audio -> disable sound tracks

4. merge audio and video in one final vid

ffmpeg -i $VID_FILE -i $AUDIO_FILE -codec copy -shortest $OUTPUT_FILE

You can then just remove all remaining files created during the process and just the one on step 4. It'll still show the warning, but the video will be watchable (it was for me at least).

Sunday, November 15, 2015

SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581) fix on debian 8

I'm using:

Debian GNU/Linux 8
Python 2.7.9
openssl 1.0.1k-3


Using python (pip) to access https stuff, I got the error
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/search.py", line 40, in run
pypi_hits = self.search(query, index_url)
File "/usr/lib/python2.7/dist-packages/pip/commands/search.py", line 54, in search
hits = pypi.search({'name': query, 'summary': query}, 'or')
File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1591, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1301, in single_request
self.send_content(h, request_body)
File "/usr/lib/python2.7/xmlrpclib.py", line 1448, in send_content
connection.endheaders(request_body)
File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 850, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 812, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 1212, in connect
server_hostname=server_hostname)
File "/usr/lib/python2.7/ssl.py", line 350, in wrap_socket
_context=self)
File "/usr/lib/python2.7/ssl.py", line 566, in __init__
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 788, in do_handshake
self._sslobj.do_handshake()
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)


Quick fix (can or cannot work... and not to be permanent as not
verifying the certificates is not very smart)
In your code, do:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context


Permanent solution


rmdir /usr/local/share/ca-certificates (was blank)
ln -s /usr/share/ca-certificates/mozilla /usr/local/share/ca-certificates
sudo apt-get install ca-certificates # in case you don't have it already
sudo update-ca-certificates

# the new files will be sym-linked here:
/etc/ssl/certs

That fixed it for me at least.

Sunday, December 8, 2013

emacs image-dired mode fixing "Thumb could not be created" thing

Ah, emacs's dired-mode... if you don't know it, do "C-h r m Dired" on your emacs right now (do Image-Dired instead for image dired mode too).

You need to have a few extra packages for image manipulation installed, but it's like the only descent/realistic way to manage (a large number of) image files I know...

"Thumb could not be created  for file ..."

This error can be annoying. In my system with:
GraphicsMagick 1.3.12 
emacs-24.3

If you have all the necessary packages and all, then probably it's because of the "strip" option used by default by image-dired-mode to make thumbnails/resize original files.


Adding this to your .emacs file should fix it.
(setq image-dired-cmd-create-thumbnail-options "%p -size %wx%h \"%f\" -resize \"%wx%h>\" jpeg:\"%t\"") ;; remove -strip option
(setq image-dired-cmd-create-temp-image-options "%p -size %wx%h \"%f\" -resize \"%wx%h>\" jpeg:\"%t\"");; remove -strip option
;;(setq image-dired-external-viewer "/usr/bin/xzgv");; a viewer I like, just in case you're interested

As an extra advice for image-dired noobs, having a 3 window emacs frame is probably the expected thing for having it working. One for dired-mode, the other for the thumbnails of image-dired, and the other for the larger preview/original size pic.
It let's you add comments/tags in an emacs exclusive "database" file, so you can manage/search for images pretty easily and fast.

Sunday, November 17, 2013

my "bodybulding" training

In results:
Before / After
  

These are my results for my 3.5 months of training.
Bulk up: 3 months ( +4 kg, +2% fat, +900g of muscle)
Reduce fat: 2~3 weeks (- 2.5kg, -1% of fat, -50g of muscle).

If you're like me and want to look more like Arnold Schwarzenegger, rather than a simple thin guy, please keep reading. If not, please leave the page.


After drinking alcohol pretty much 3~4 times a week and having a super unhealthy diet and lifestyle after being dumped by fiance, I looked a lot worst that in the "before" pic.
I hit the bottom of the bottom of my life so far at least in self-destructive/depressively speaking.
Leaving aside "why" I began training, it was something I had been wanting to do a long time, but didn't have the money/time/will till now.
Apparently I have good genes for muscle development, which helps. After 2~3 years, I expect to look more like a real bodybuilder.

There are many stories out there around how a certain diet/fitness training can help you do this kind of change in your body. But most of it is sh*t. And believe me, the worst thing you can do is do a ketosis diet, like eating once a day, or having days without eating anything. You only do that kind of thing if you have some kind of trauma for being a f*cking fatso for long, and having no idea of how to change that and being totally desperate.

You'll basically need:
  1. a gym subcription / + optional sport or fitness recreational activity (me: capoeira/brazilian jujitsu and mountain biking) 
  2. a microwave, fridge, and basic cooking skills (you'll begin bodybuilding cooking)
  3. time to rest and sleep
  4. track recording tool (notebook, etc. I use a database in my computer)
  5. calories calculating tool (notebook, etc. I use a lisp program I made)
  6. the will to improve yourself or kill someone so much you'll stick with the plan

About one third of all is in the gym, and how you develop your musculature using the progressive overload principle. Go to youtube or something, and watch the Joe Weider's training tapes. If you want to look a bodybuilder, you gotta train like one.
The other two thirds are about the time you take to rest your body /sleep, and how you calculate your diet.
You can do the diet change gradually, having to better have about 40%, 50%, and 10% of protein, carbohydrates, and fat daily. With the amount of calories being higher than the amount you need --- get in an over calories diet --- (in the bulk up phase, where you generate the amount of muscle you want, fat will be generated too, don't worry about it you can get thin anytime, it's super easy when you begin understanding your body and how it uses the food you take).

The basic cooking skills part is nice too. Especially since you're like me and never cooked before, and think the best food you have had is whatever your ex-gf or her mom had made for you. Everything will taste better when knowing that's what your body requires, and how it be used by it. Read in sites like bodybuilding.com about simple/complex carbs, protein, fat, and experiment on yourself about what suits your body better. You'll probably be making your food in bulk ilke twice a week, and heating stuffs with a microwave everyday. (From my second month of training, I started eating 5~7 times a day, bringing packed food to the office). Oatmeal, non-stick-spray (cooking oil spray) and baked chicken breast, brown rice, (especially sweet) potatoes, eggs/milk, and of course protein shakes and supplements will be your strongest allies.

Weight yourself everyday to keep record, as well as write down everything you eat, and it's nutrition values so you can make sure you're having enough calories and carbs/protein, or if you get too fat, how much is too much for you.
Also take pics of yourself once every 2 weeks, which will help keep record of how your body changes (you really don't notice when looking yourself at the mirror everyday, although probably your friends do).
An occasional junk food/eating out meal is OK. But if possible, stay away from alcohol, that's not only for bodybuilders, if you want to stay healthy in general...

Some people say I look ripped/muscular enough now, but I want to get bigger, so I'll keep bulking up again for a while. Really, this changes your life in so many ways I wish I had started it long time ago. Now I can cook pretty good (which also makes your life cheaper if you were used to eat it out), look a lot better, and feel a lot more confident of martial arts skills as well... which can't hurt (me).

Sociable