Linkshare rotating banner
Showing posts with label tip. Show all posts
Showing posts with label tip. Show all posts

Thursday, October 11, 2012

Aria2 shell script and batch file

I wrote a BASH shell script and a DOS batch file that can be used to download files using aria2 — Aria2 is a command-line tool for downloading files. The script and the batch file take 2 arguments; the first one is for the bittorrent hash in 40-digit hexadecimal number and the second one is for arbitrary one-word description.





aria2.bat can be used on Windows, and aria2.sh can be used on Linux and *BSD. Make sure that aria2c is in PATH. For example, if you want to download an ISO file for the OpenSUSE DVD, you would type something like:



aria2.bat 198472f5217d843cceb1a4c82233f009ed6608af opensuse-dvd-586


To find the value of a bittorrent hash (that long hex number), you can cut it from a magnet link you find on a Web site — Magnet links allow you to download actual files without first having to download bittorrent files (*.torrent). When you see a magnet sign, right-click on it to display the shortcut menu and select Copy Link Location.



btih-demo1

Then, paste it somewhere, for example, inside the URL address bar. The hash value comes after the btih: string.



btih-demo2

After you find the bittorrent hash, use it as the first argument to the script and make up anything for the second argument, as shown in the example above.


Saturday, July 18, 2009

GTK 2.6.10 Hack: To Make im-ime.dll etc.

I successfully compiled GTK+ 2.6.10 for Windows. GTK+ 2.6.10 is outdated but it is the last known release to support Windows 98/ME. For unknown reason, I couldn't find shared libraries of GTK+ 2.6.10 input modules. To fix this problem, I once again utilized the venerable dllwrap program. First, I switched to the subfolder modules/input/.libs/ of GTK+ source tree. Then, I created shared input modules, as follows:


dllwrap --export-all-symbols --add-stdcall-alias -o im-am-et.dll
--dllname im-am-et.dll imam-et.o -L../../../gtk/.libs -lgtk-win32-2.0 -L../../../gdk/.libs -lgdk-win32-2.0 -L../../../gdk-pixbuf/.libs -lgdk_pixbuf-2.0 -L/mingw/lib -limm32 -lshell32 -luuid -lwsock32 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lws2_32 -lole32 -lintl



dllwrap --export-all-symbols --add-stdcall-alias -o im-cedilla.dll --dllname im-cedilla.dll imcedilla.o -L../../../gtk/.libs -lgtk-win32-2.0 -L../../../gdk/.libs -lgdk-win32-2.0 -L../../../gdk-pixbuf/.libs -lgdk_pixbuf-2.0 -L/mingw/lib -limm32 -lshell32 -luuid -lwsock32 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lws2_32 -lole32 -lintl



dllwrap --export-all-symbols --add-stdcall-alias -o im-cyrillic-translit.dll --dllname im-cyrillic-translit.dll imcyrillic-translit.o -L../../../gtk/.libs -lgtk-win32-2.0 -L../../../gdk/.libs -lgdk-win32-2.0 -L../../../gdk-pixbuf/.libs -lgdk_pixbuf-2.0 -L/mingw/lib -limm32 -lshell32 -luuid -lwsock32 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lws2_32 -lole32 -lintl



dllwrap --export-all-symbols --add-stdcall-alias -o im-ime.dll --dllname im-ime.dll gtkimcontextime.o imime.o -L../../../gtk/.libs -lgtk-win32-2.0 -L../../../gdk/.libs -lgdk-win32-2.0 -L../../../gdk-pixbuf/.libs -lgdk_pixbuf-2.0 -L/mingw/lib -limm32 -lshell32 -luuid -lwsock32 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lws2_32 -lole32 -lintl



dllwrap --export-all-symbols --add-stdcall-alias -o im-inuktitut.dll --dllname im-inuktitut.dll iminuktitut.o -L../../../gtk/.libs -lgtk-win32-2.0 -L../../../gdk/.libs -lgdk-win32-2.0 -L../../../gdk-pixbuf/.libs -lgdk_pixbuf-2.0 -L/mingw/lib -limm32 -lshell32 -luuid -lwsock32 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lws2_32 -lole32 -lintl



dllwrap --export-all-symbols --add-stdcall-alias -o im-ipa.dll --dllname im-ipa.dll imipa.o -L../../../gtk/.libs -lgtk-win32-2.0 -L../../../gdk/.libs -lgdk-win32-2.0 -L../../../gdk-pixbuf/.libs -lgdk_pixbuf-2.0 -L/mingw/lib -limm32 -lshell32 -luuid -lwsock32 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lws2_32 -lole32 -lintl



dllwrap --export-all-symbols --add-stdcall-alias -o im-thai-broken.dll --dllname im-thai-broken.dll imthai-broken.o -L../../../gtk/.libs -lgtk-win32-2.0 -L../../../gdk/.libs -lgdk-win32-2.0 -L../../../gdk-pixbuf/.libs -lgdk_pixbuf-2.0 -L/mingw/lib -limm32 -lshell32 -luuid -lwsock32 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lws2_32 -lole32 -lintl



dllwrap --export-all-symbols --add-stdcall-alias -o im-ti-er.dll --dllname im-ti-er.dll imti-er.o -L../../../gtk/.libs -lgtk-win32-2.0 -L../../../gdk/.libs -lgdk-win32-2.0 -L../../../gdk-pixbuf/.libs -lgdk_pixbuf-2.0 -L/mingw/lib -limm32 -lshell32 -luuid -lwsock32 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lws2_32 -lole32 -lintl



dllwrap --export-all-symbols --add-stdcall-alias -o im-ti-et.dll --dllname im-ti-et.dll imti-et.o -L../../../gtk/.libs -lgtk-win32-2.0 -L../../../gdk/.libs -lgdk-win32-2.0 -L../../../gdk-pixbuf/.libs -lgdk_pixbuf-2.0 -L/mingw/lib -limm32 -lshell32 -luuid -lwsock32 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lws2_32 -lole32 -lintl



dllwrap --export-all-symbols --add-stdcall-alias -o im-viqr.dll --dllname im-viqr.dll imviqr.o -L../../../gtk/.libs -lgtk-win32-2.0 -L../../../gdk/.libs -lgdk-win32-2.0 -L../../../gdk-pixbuf/.libs -lgdk_pixbuf-2.0 -L/mingw/lib -limm32 -lshell32 -luuid -lwsock32 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lws2_32 -lole32 -lintl

Then, I moved the shared libraries to C:\MinGW\lib\gtk-2.0\2.4.0\immodules. Finally, I ran gtk-query-immodules-2.0 and save the output as /etc/gtk-2.0/gtk.immodules.


mkdir -p /mingw/lib/gtk-2.0/2.4.0/immodules
mv *.dll /mingw/lib/gtk-2.0/2.4.0/immodules
gtk-query-immodules-2.0.exe /mingw/lib/gtk-2.0/2.4.0/immodules/*.dll > /mingw/etc/gtk-2.0/gtk.immodules

Tuesday, July 14, 2009

MinGW: Getting Pkg-Config When Building Glib For the First Time

If you're building glib for Windows for the first time but don't have pkg-config, there are a few ways to get pkg-config. Because pkg-config depends on glib, there is an inter-dependency problem between pkg-config and glib. One way to address this problem is to get Cygwin-built pkg-config. I recommend getting a Cygwin build, pkg-config-0.23b-1.tar.bz2 and cygwin-1.5.25-15.tar.bz2. Then, extract pkg-config.exe and cygwin1.dll like this:



tar xjOf pkg-config-0.23b-1.tar.bz2 usr/bin/pkg-config.exe > /mingw/bin/pkg-config.exe
tar xjOf cygwin-1.5.25-15.tar.bz2 usr/bin/cygwin1.dll > /mingw/bin/cygwin1.dll


If pkg-config can't find a library during configure, set the environment variable PKG_CONFIG_PATH.



PKG_CONFIG_PATH="C:\MinGW\lib\pkgconfig"
export PKG_CONGIG_PATH


Check: pkg-config --help

    pkg-config --libs --cflags glib-2.0

Friday, July 3, 2009

Cygwin: To Convert Pango Static Libraries to Shared Libraries

Pango is a required component of GTK+ libraries. With Cygwin GCC compiler, I was compiling Pango during GTK+ compilation. But I ran into a problem when only static libraries of Pango were produced. So I had to produce shared libraries of Pango from static ones. Here I show how I did it using dllwrap:



  1. First, create empty directories:

    mkdir pango pangocairo pangoft2 pangowin32

  2. Extract object codes from the static libraries into separate directories:

    cd pango
    ar x /usr/lib/libpango-1.0.a
    cd ../pangocairo/
    ar x /usr/lib/libpangocairo-1.0.a
    cd ../pangoft2/
    ar x /usr/lib/libpangoft2-1.0.a
    cd ../pangowin32/
    ar x /usr/lib/libpangowin32-1.0.a

  3. Create a shared library cygpango-1.0-0.dll and import library libpango-1.0.dll.a from the static library /usr/lib/libpango-1.0.a. The dependencies are gotten from /usr/lib/libpango-1.0.la:

    cd ../pango/

    dllwrap --verbose --export-all-symbols --add-stdcall-alias -o /usr/bin/cygpango-1.0-0.dll --dllname cygpango-1.0-0.dll --output-lib /usr/lib/libpango-1.0.dll.a *.o -L/usr/lib -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -luser32 -lkernel32 -lintl -liconv

  4. Likewise, convert /usr/lib/libpangowin32-1.0.a to a shared library:

    cd ../pangowin32/

    dllwrap --verbose --export-all-symbols --add-stdcall-alias -o /usr/bin/cygpangowin32-1.0-0.dll --dllname cygpangowin32-1.0-0.dll --output-lib /usr/lib/libpangowin32-1.0.dll.a *.o -L/usr/lib -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -luser32 -lkernel32 -lintl -liconv -lgdi32

  5. Likewise, convert /usr/lib/libpangoft2-1.0.a to a shared library:

    cd ../pangoft2/

    dllwrap --verbose --export-all-symbols --add-stdcall-alias -o /usr/bin/cygpangoft2-1.0-0.dll --dllname cygpangoft2-1.0-0.dll --output-lib /usr/lib/libpangoft2-1.0.dll.a *.o -L/usr/lib -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -luser32 -lkernel32 -lintl -lfontconfig -lxml2 -liconv -lfreetype -lz

    If fontconfig was compiled with expat, replace -lxml2 with -lexpat.


  6. Likewise, convert /usr/lib/libpangocairo-1.0.a to a shared library:

    cd ../pangocairo/

    dllwrap --verbose --export-all-symbols --add-stdcall-alias -o /usr/bin/cygpangocairo-1.0-0.dll --dllname cygpangocairo-1.0-0.dll --output-lib /usr/lib/libpangocairo-1.0.dll.a *.o -L/usr/lib -lcairo -lmsimg32 -lpixman-1 -lpng12 -lpangowin32-1.0 -lgdi32 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -luser32 -lkernel32 -lintl -lfontconfig -lxml2 -liconv -lfreetype -lz

    If fontconfig was compiled with expat, replace -lxml2 with -lexpat.



  7. Finally, modify /usr/lib/libpango*.la accordingly. For example, I made the following change to my libpango-1.0.la file:

    dlname='../bin/cygpango-1.0-0.dll'
    library_names='libpango-1.0.dll.a'


This creates shared libraries cygpango-1.0-0.dll, cygpangowin32-1.0-0.dll, cygpangoft2-1.0-0.dll, cygpangocairo-1.0-0.dll and import libraries libpango-1.0.dll.a, libpangowin32-1.0.dll.a, libpangoft2-1.0.dll.a, libpangocairo-1.0.dll.a.

Sunday, June 28, 2009

Text Conversion with sed

sed is a handy UNIX tool that manipulates a stream of text. Here I'll list some useful examples of sed commands. This is just a note to myself. I'll add more as I learn more about sed



To replace every instance of ABC with DEF in a text file, run the following command:


sed 's/ABC/DEF/g' input.txt > output.txt


To convert DOS/WINDOWS style text to UNIX/LINUX style text, run the following command. In other words, this command removes carriage returns from the end of every line:


sed 's/\r$//g' input.txt > output.txt


To remove a tab from the beginning of every line, run:


sed 's/^\t//g' input.txt > output.txt

Saturday, June 27, 2009

Removing Malware from Windows XP

This is a simple trick to remove spyware or malware from Windows XP. I used it to fix my friend's computer. His PC was infected with bogus Anti-virus called System Security version 4.52. This malware reports virus infection and asks me to buy their software. It also disables other real anti-virus like AVG and blocks the user from accessing legitimate sites like Anti-virus vendors and the Microsoft site. Don't be tricked into giving them your valuable credit card number! This bogus malware is a scam. Just follow these simple steps to get rid of this kind of evil creatures.




  1. Restart your computer and hold down the F8 key. You'll see a menu of boot options. Choose the Safe Mode with Networking so you can go online and download Anti-virus like AVG or Avast!

    Windows XP advanced boot menu
  2. Once you're in the Safe Mode, launch the registry editor (regedit.exe).
  3. Go to “HKLM\Software\Microsoft\Windows\CurrentVersion\Run”
  4. Find anything suspicious and note the location of the perpetrator. In my case, it looks like:

    10479844  "C:\Documents and Settings\All Users\Application Data\10479844\10479844.exe"

  5. Remove it from the registry.
  6. Open the explorer and remove the folder containing the malware/spyware/scumware from the system.

Friday, June 26, 2009

Cygwin/MinGW: Convert a Static Library to Shared Library

As I have used MinGW and Cygwin to compile GNU/Linux software in Windows, sometimes I only get static libraries, but not a shared library. After some research, I found several ways to convert a static library to a shared library. Using GCC with the -shared parameter is one way. libtool is another tool for such a task. In this post, I will write about dllwrap because that's what I have used and known to work.



Using dllwrap


Suppose the name of the static library is libpango-1.0.a This library is just an archive of many object files. Running “ar t libpango-1.0.a” will display the contents of the archive.


ar t libpango-1.0.a

Now, we have to extract the contents of the archive into an empty folder. Create a new folder.


mkdir temp

Change to the newly created folder and extract the static library.


cd temp
ar x libpango-1.0.a

Use dllwrap to create a shared library from the object files in the following manner:


dllwrap --verbose --export-all-symbols --add-stdcall-alias \

-o /usr/bin/cygpango-1.0-0.dll --dllname cygpango-1.0-0.dll \

--output-lib /usr/lib/libpango-1.0.dll.a *.o -L/usr/lib \

-lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -luser32 -lkernel32 -lintl -liconv

This creates a shared library cygpango-1.0-0.dll and an import library libpango-1.0.dll.a. To learn more about dllwrap, read the output of “dllwrap --help


Using GCC to convert a static library to shared library


You can also use GCC to do a library conversion with GCC. Here's an example. It's certainly a lot of typing:



ar x /usr/lib/libpango-1.0.a
gcc -shared -o libpango-1.0-0.dll -Wl,--out-implib=libpango-1.0.dll.a \

-Wl,--export-all-symbols -Wl,--add-stdcall-alias -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc \

*.o -L/usr/lib \

-lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -luser32 -lkernel32 -lintl -liconv

This creates the same set of files as with dllwrap above, but with slightly different sizes. For more information, read the GCC manual and the output from ld --help



Using a2dll to Convert a Static Library


a2dll is a little tool from mingw-utils that can be used to convert a static library to a dynamic library. For example,


a2dll libmp3lame.a -o lame_enc.dll

About This Blog

KBlog logo This blog seeks to share useful information on hottest movies available on the Internet. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

icon
Powered By Blogger