Monday, August 24, 2015

How to issue a time resynchronization in Windows - cmd/batch

 Hello again, I'm back. I found some spare time to add some updated tricks concerning technology, and general tips for Windows or GNU/Linux. :)

I've been having some problems with the time synchronization in Windows 7, which required more often synchronization. So after some googling around, I came up with this little batch commands:
echo Current date/time: %date%_%time%
%windir%\system32\sc.exe start w32time task_started
%windir%\system32\w32tm.exe /resync
echo Fixed date/time: %date%_%time%
pause

Save it as a .bat file and run it as an administrator (right-click on file > Run as administrator).
It's nothing much, pretty dirty scripting I confess, but it does get the job done, at least in my case. I hope it will help someone else too.

See ya!

Thursday, October 11, 2012

Icon 'gtk-close' not present in theme

I recently started to use screenlets again, especially FreeMeteo for weather forecast. But on ubuntu 12.04 every time I login I get a crash message:

FreemeteoWeatherScreenlet.py crashed with GError in load_buttons(): Icon 'gtk-close' not present in theme

If you have a similar crash message, you can simply install the gnome-icon-theme-full package which contains the gtk-close.png file.

Source: https://bugs.launchpad.net/ubuntu/+source/indiv-screenlets/+bug/807129

Kernel mainline ppa downloader (aka kmpd / kmp-downloader)


About

kmp-downloader is a simple program that allows you to install fresh new kernel versions from the ubuntu kernel mainline ppa.

As it is, the mainline is not an actual "ppa" (personal package archive) and doesn't allow people to use apt-get to upgrade.

Requirements

You may need python beautifoul soup (python-bs4) or execute:
sudo apt-get install python-bs4

How to use it

You may download it using this quick link: https://github.com/medigeek/kmp-downloader/tarball/master

Save the archive and extract the files. Double click on kmpd.py (execute in terminal). If you're not sure about an option, press Enter and it will select the default answer.

You may also execute this command (one-liner):

cd /tmp; rm -rf medigeek-kmp*; wget --no-check-certificate https://github.com/medigeek/kmp-downloader/tarball/master -O kmpd.tar.gz; tar xzf kmpd.tar.gz; cd medigeek-*; python kmpd.py

You will be asked a series of questions, where you either reply by "Y" or "N" (yes or no) or simply press enter and let the program figure out the default reply (mentioned in square [] brackets). It will then install the appropriate debian packages.

Note: it will not fix the problems with other packages. I suggest running linux ppa packages without dkms package (without closed source packages like nvidia driver or virtualbox driver), in order to have a smooth, errorless installation.

Uninstall

To uninstall the kernel packages, remember to boot to a different kernel image first. Then you can use your favourite package manager to uninstall the packages.

If you prefer the command line, if you installed version 3.5.3, you can uninstall it using this command:

sudo apt-get purge linux-image-3.5.3.* linux-image-extra-3.5.3.* linux-headers-3.5.3.*


Thursday, July 26, 2012

python: download url to file with progress bar

This is an alternative answer for a question on stackoverflow:
http://stackoverflow.com/a/22776/286994

I modified the answer a bit, using .format instead of % string formatting and sys.stdout.write(), and posted it on gist github: https://gist.github.com/3176958

#!/usr/bin/python
# Improve http://stackoverflow.com/a/22776/286994
# (using .format() instead of % string formatting)

import sys
import urllib2

file_name = url.split('/')[-1]
u = urllib2.urlopen(url)
f = open(file_name, 'wb')
meta = u.info()
file_size = int(meta.getheaders("Content-Length")[0])
print("Downloading: {0} Bytes: {1}".format(url, file_size))

file_size_dl = 0
block_sz = 8192
while True:
    buffer = u.read(block_sz)
    if not buffer:
        break

    file_size_dl += len(buffer)
    f.write(buffer)
    p = float(file_size_dl) / file_size
    status = r"{0}  [{1:.2%}]".format(file_size_dl, p)
    status = status + chr(8)*(len(status)+1)
    sys.stdout.write(status)

f.close()

I'm using this solution for the kernel mainline ppa downloader: https://github.com/medigeek/kmp-downloader

Monday, April 02, 2012

Hiren's boot cd using unetbootin (missing boot options)



If you try to use unetbootin to copy Hiren's bootcd on a usb flash drive and you boot using the flash disk, you'll notice that some options are missing, especially the "mini windows xp" boot option.

To overcome this problem you have to copy the file "HBCD/isolinux.cfg" to the main folder and replace the file "syslinux.cfg"

Then everything will work as expected.

Bug report: https://bugs.launchpad.net/unetbootin/+bug/971403