Dengar's Blog Logo

Dengar's blog...
We will see what I post, probably will be some random tutorials

Wednesday, 9 November 2016

list of all eBay categories and eBay category ids

it's strange that a company like eBay doesn't make it easy for sellers to get the resources they need. have you tried getting a complete list of all eBay categories? maybe with the eBay category tree? - you will find that there's not a convenient download location, albeit there should be!

the "trick" so i've learned is to get it yourself.

here is a very short python script that will get your categories:

#! /usr/bin/env python
import tools as t
import xmltodict as xml
import requests
url = 'http://open.api.ebay.com/Shopping?callname=GetCategoryInfo&appid={}&siteid={}&CategoryID={}&version=729&IncludeSelector=ChildCategories'
app_id = 'XXXX' #get your own eBay app id
site_id = '3' # 3 is UK
to_get = [-1] # start at the top
done = []
categories = {}
if __name__ == "__main__":
    while len(to_get) > 0:
        cid = to_get.pop()
        re = requests.get(url.format(app_id, site_id, cid))
        root = xml.parse(re.text)
        cats = root['GetCategoryInfoResponse']['CategoryArray']['Category']
        for cat in cats:
            if cat['CategoryID'] not in categories:
                print(cat.get('CategoryName', 0))
                c = {'category_id': cat.get('CategoryID', 0),
                    'category_level': cat.get('CategoryLevel', 0),
                    'category_name': cat.get('CategoryName', 0),
                    'category_parent_id': cat.get('CategoryParentID', 0),
                    'leaf_category': cat.get('LeafCategory', 0),
                    'category_name_path': cat.get('CategoryNamePath', 0)}
                categories[cat['CategoryID']] = c
            done.append(cid)
            if cat['CategoryID'] not in done  and cat['LeafCategory'] == 'false' :
                to_get.append(cat['CategoryID'])
    with open('eBay_categories.tsv', 'w', encoding="utf-8") as of:
        of.write("category_id\tcategory_level\tcategory_name\tcategory_parent_id\tleaf_category\tCategoryNamePath\n")
        for k,v in categories.items():
            of.write(str(v['category_id']) + "\t" + str(v['category_level']) + "\t" + str(v['category_name']) + "\t" + str(v['category_parent_id']) + "\t" + str(v['leaf_category']) + "\t" + str(v['category_name_path']) + "\n")



the above will then create a tab delimited text file named 'eBay_categories.tsv'.
please note you will need both the "requests" and the "xmltodict" modules. they can be easily obtained using pypi. this code is python 3

Friday, 8 January 2016

why is mac osx is deliberately awkward? and why doesn't somebody go and hurt mac osx developers?

things that are really, really f*cking cr*p in osx:
  • non standard keyboard shortcuts
    having used windows, apple macintosh (many years ago) and linux systems for most of my life and used certain standard keyboard shortcut combinations (ctrl+x, ctrl+c, return, delete or backspace), it is infuriating to see that mac at some point must have thought that it's wise to deviate from everyone else and therefore make their computers more difficult to use.

  • there is no standard programme to open archives - not even zip
    the standard is to unzip an archive. other than in the command line, there doesn't seem to be a way of looking what's inside a zip file. you have to extract it, then delete it. pointless.
    not only that, but zip is really the only thing supported, so you end up installing a different archive manager for tar balls, rar, 7z or any other files.

  • the decision to not support ntfs or fat32 or other file systems out of the box, but just their own journaling file system and exfat

  • you cannot cut and paste in the file browser "finder". wtf??!!
this list will grow over time

Saturday, 4 April 2015

An easy way to enable VNC in Ubuntu 14.04

i've struggled today for a few hours to get XDMCP connections running on my new tv server. in the end i posted on a few forums and gave up. a bit frustrating!

but i still didn't want to leave my seat without having any ability to log into my server without gui, so i opted for a simple vnc server solution:


  1. you need to have the gnome-session-flashback package installed through apt-get
  2. you need to log into at least one session that is a gnome (fallback) one.
  3. go to applications > system tools > preferences > desktop sharing
and that solves the problem. you must have at least one desktop session running, logged into Gnome-flashback and this user must have the connection allowed.


Saturday, 10 May 2014

Removing unused Kernel files via command line

regular kernel updates are great, but having 3 years of kernel updates on one hard disk is not. chances are you are never going to use any of the 10 or 20 that you installed last year. if everything continues to work fine, why would you?

you can obviously use a package manager, such as synaptic, to uninstall unwanted programmes. quite often you might find a few other programmes that you didn't know you had still and want to get rid of. but it's generally easier to just use the command line to remove things quickly.

use this command:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge 

i use this command in ubuntu and i'm pretty sure it will work in derived versions, but results may vary!

Bulk encode MP3s with Lame and avconv

to be honest, when i am in the car or listening to music at home, i don't really hear the difference between "lossy" mp3s and lossless formats such as flac. flac is just really huge compared to MP3 and i wouldn't care if hard disk space was unlimited.
even if buying 2-3 nat storage devices, i think i'd still run our of space eventually.

so i do compress flac files after a while. but doing a whole album that is correctly labelled and tagged can be tricky. you don't want to use some software that renames the files or changes the tagging...

linux is very supportive for doing things like that via the command line:

what you need is avconv and lame. avconv is a very fast video and audio converter. it can use libmp3lame to encode to mp3. because avconv can also convert and optimise video files, you can use it the same way to strip mp3s from video files, such as music videos or stuff you downloaded from youtube. but this post is about mp3s.
lame ain't an mp3 encoder, but it simply is the best of them.

the command line argument to convert all flac files to mp3s in one folder is:
for file in *.flac; do n=$(basename "$file" .flac); avconv -i "$file" -codec:a libmp3lame -qscale:a 2 "$n".mp3; done
if you want to convert from a different format, simply exchange the ".flag" to a ".wav", ".mp4", ".swf" or whatever the source file might be.


Sunday, 2 February 2014

Exporting Sound with XDMCP

Some of you might be connecting to your remote linux box using XDMCP. While that would export the display,what would one do if one wanted to play a song on the remote box but hear it on the present system? well that can be easily done using the arts server on the remote machine setup the arts daemon by typing
artsd -n -u -p 5001
once the server is started change to the X display of the remote machine and type in
export ARTS_SERVER=ipofcurrentsystem:5001

and then

xmms &
Voila you will have a complete remote desktop including sound just like in windows xp.

Friday, 20 September 2013

Excel reverse string function (VBA)

a very simple VBA funciton to reverse a string (text cell) in Excel:

Function Reverse(str As String) As String
    Reverse = StrReverse(Trim(str))
End Function