from django.contrib.auth.models import User from faker import Faker fake = Faker() for i in range(0,200): name = fake.name() first_name = name.split(' ')[0] last_name = ' '.join(name.split(' ')[-1:]) username = first_name[0].lower() + last_name.lower().replace(' ', '') user = User.objects.create_user(username, password=username) user.first_name = first_name user.last_name = last_name user.is_superuser = False user.is_staff = False user.email = username + "@" + last_name.lower() + ".com" user.save()
Author Archives: ChristianKreuzberger
Using pdfmake with npm on an AngularJS Application (without bower)
While people on the Internet are still fighting about npm vs bower, there are some packages that are only available for npm and some that are only available for bower. Unfortunately you will run into problems, sooner or later, just like I did today.
The package pdfmake enables JavaScript applications to convert text to PDF, both within a website as well as a NodeJS server application. However, they explicitly state that the bower version should be used for web applications, and the npm version for server applications.
But if you want to use npm and want to avoid bower (for whatever reason), then you will run into a problem.
Thankfully, somebody created a wrapper package for npm: https://github.com/AaronBuxbaum/pdfmake-client
You can install it via
npm install pdfmake-client --save
Android SDK and AVD Manager in your (Linux) Start Menu
The Android SDK and also AVD Manager can be started from the commandline, if you have the Android SDK Tools installed.
For instance, on my system I have android-sdk-tools in ~/android-sdk-tools, therefore I only need to go into that directory (cd ~/android-sdk-tools) and use the following command:
./Tools/android avd # start android avd manager
# or
./Tools/android sdk # start android sdk manager
This can be used for creating start menu entries, e.g., for XFCE. Mine look as follows:
~/.local/share/applications/menulibre-android-avd-manager.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=Android AVD Manager
Icon=phone-apple-iphone-symbolic
Exec=./android avd
Path=/home/ckreuzberger/android-sdk-linux/tools/
NoDisplay=false
Categories=Development;Utility;X-XFCE;X-Xfce-Toplevel;
StartupNotify=false
Terminal=false
~/.local/share/applications/menulibre-android-sdk-manager.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=Android SDK Manager
Icon=phone-apple-iphone-symbolic
Exec=./android sdk
Path=/home/ckreuzberger/android-sdk-linux/tools/
NoDisplay=false
Categories=Development;Utility;X-XFCE;X-Xfce-Toplevel;
StartupNotify=false
Terminal=false
Using Inkscape to Convert SVG to PNG
While in my previous post I explained how to mass convert images using the convert command line tool, I've found another solution using inkscape.
inkscape yourfile.svg --export-png=yourfile.png -w256 -h256
Shell Script for converting multiple images at once
One of the tasks I come across often is converting images from one format into another. For instance, I need to convert SVG to PNG.
This can be achieved easily by using the "convert" commandline tool (ImageMagick) and a standard for loop in linux (note that I wrote the *.svg statement in the for command on purpose and that I use "$f" on purpose):
for f in *.svg ; do convert "$f" "$f.png" done
However, this produces ugly file names like "file1.svg.png", which could be desireable in some scenarios, but not in my case when I deploy it for a website. You can bypass this by using ${f%svg}png:
for f in *.svg ; do convert "$f" "${f%svg}png" done
Essentially this tool can handle a lot of use cases, for instance you can specify the picture density and which color should be used as transparent:
for f in *.svg ; do convert "$f" -density 300 -transparent white "${f%svg}png" done
If you only want your pictures to have a certain size, you can resize them, e.g. using -resize 64x64:
for f in *.svg ; do convert "$f" -resize 64x64 -density 300 -transparent white "${f%svg}png" done
However, you need to be careful when doing this. For instance, when the source image is smaller than the destination image, you might run into problems, and need to use the command like this:
for f in *.svg ; do convert -resize 64x64 -density 300 "$f" -resize 64x64 -density 300 -transparent white "${f%svg}png" done
MySQL and German Umlauts in a Unique Constraint
I recently came across some very odd behaviour in MySQL with German Umlauts (ö ä ü ß) and Unique Constraints. The problem is even documented as Bug #57860 on mysql.com. In short, MySQL (or rather utf8_unicode_ci) would suggest that foobär
is the same as foobar
. So the statement
INSERT INTO test (test) VALUES ('foobar'),('foobär');
where test is a column with a unique index/constraint would fail.
This behaviour might be desired in some languages, but particularly for the german language this behaviour is not optimal. I'm sure if you find this blog post, you came across the same problem so I do not need to come up with another example.
The solution is simple, though you should think twice before you use it:
Instead of utf8_unicode_ci, you could use utf8_general_ci or even the newer and more appropriate utf8_german2_ci (available starting with MySQL 5.6).
Ubuntu + USB Headset
While USB Headsets are already supported by Ubuntu (15.10 in my example), there are some stumbling block. One of them was that the USB Headset is not recognized after (re)booting, only after plugging it out and back in.
To overcome this issue, the USB device needs to be entered in /etc/modprobe.d/snd-usb-audio (you might have to create this file first).
Step 1: Boot without the headset plugged in
Step 2: Run lsusb tool in commandline, copy the output to a text editor
Step 3: Plug in your USB headset
Step 4: Use lsusb tool in commandline to find out what USB devices you have, in my example:
Bus 002 Device 003: ID 0451:8046 Texas Instruments, Inc.
Bus 002 Device 002: ID 0451:8046 Texas Instruments, Inc.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 413c:301a Dell Computer Corp.
Bus 001 Device 005: ID 2034:0102
Bus 001 Device 004: ID 413c:2113 Dell Computer Corp.
Bus 001 Device 003: ID 0451:8044 Texas Instruments, Inc.
Bus 001 Device 002: ID 0451:8044 Texas Instruments, Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Step 5: Cross match the lsusb output from step 2 to find out which device your headset is, in my example it was
Bus 001 Device 005: ID 2034:0102
Step 6: Create the following entry in /etc/modprobe.d/snd-usb-audio (you might have to create this file first):
options snd-usb-audio index=2 vid=0x2034 pid=0x0102
Make sure to replace 0x2034 with the first ID of the lsusb output of your usb device, and 0x0102 with the second one.
Step 7: Reboot, enjoy!
New Publication: A Comparative Study of DASH Representation Sets Using Real User Characteristics
A Comparative Study of DASH Representation Sets Using Real User Characteristics
C. Kreuzberger, B. Rainer, H. Hellwagner, L. Toni and P. Frossard
Published at NOSSDAV 2016 (co-located with MMSyS 2016), Klagenfurt, Austria, May 2016.
Link to Paper: PDF
BibTeX Cite: To Appear
Presentation: PDF
Paper Website: http://concert.itec.aau.at/NOSSDAV_2016/
Git Repo: https://github.com/ChristianKreuzberger/amust-ndnSIM
Download YouTube MPD Files
Ever wondered which representations YouTube is using for your video? Is it worth uploading your YouTube video with 20 Mbit/s at 1080p and 30 fps?
Find out by analyzing your YouTube videos MPD (Media Presentation Description) file, as explained in my new open source repository here: https://github.com/ChristianKreuzberger/extract-youtube-mpd
This is the result of one of my videos:
python extract.py https://www.youtube.com/watch?v=GTGUa4J8XKw aspen.mpd
Downloading HTML of https://www.youtube.com/watch?v=GTGUa4J8XKw
Extracted MPDURL from HTML:
https://manifest.googlevideo.com/api/manifest/dash/sparams/.....
AdaptationSet,RepresentationID,Bitrate,Codec,ExtraInformation
audio/mp4,140,127570,mp4a.40.2
video/mp4,133,247800,avc1.4d4015,426/240/24
video/mp4,134,601944,avc1.4d401e,640/360/24
video/mp4,135,1103336,avc1.4d401e,854/480/24
video/mp4,160,109967,avc1.42c00c,256/144/12
video/mp4,136,2206969,avc1.4d401f,1280/720/24
video/mp4,137,4144774,avc1.640028,1920/1080/24
This means my video is available at 4.1 Mbit/s at 1080p and 24 fps, 2.2 Mbit/s and 720p, 1 Mbit/s and 480p, etc... We have a paper submitted to NOSSDAV that shows a full analysis of YouTubes representations, so stay tuned for more information.
Run ndnSIM 2.1 with scenario template without root access
Due to the new release of ndnSIM (version 2.1) my last post about running ndnSIM without root has become obsolete. It is also no longer necessary to compile ndn-cxx as a separate library now. However, if you still want to use the (recommended) ndnSIM scenario template without having root access, here are the steps to follow (for version 2.1):
Step 1: follow the installation (requirements, etc...) instructions on the ndnSIM website until you have to type ./waf the first time.
For instance (after having installed all pre-requesits):
mkdir ndnSIM
cd ndnSIM
git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Step 1.a: If you require BRITE, do this in addition:
hg clone http://code.nsnam.org/BRITE
cd BRITE
make
export BRITE_HOME=$(pwd)
cd ..
Step 2: Create a directory where ns-3 and ndnSIM will be "installed" into, e.g.:
mkdir ndnSIM-build
Step 3: Go to the ns-3 subfolder and compile ns-3 and ndnSIM:
cd ns-3
./waf configure --prefix ../ndnSIM-build -d optimized
./waf
Note: --prefix ../ndnSIM-build tells the build-script to not install the libraries to the default location, but to ../ndnSIM-build.
Step 3.a: If you followed Step 1.a for BRITE, you will have to add --with-brite=$BRITE_HOME to the ./waf command:
./waf configure --prefix ../ndnSIM-build -d optimized --with-brite=$BRITE_HOME
Step 4: Grab a coffee, tea, beer, etc.! This step takes some time...
Step 5: Once this has finished, type
./waf install
Note: You did not have to use sudo! ns3 and ndnSIM are now being "installed" to ../ndnSIM-build
Step 6: Set up LD_LIBRARY_PATH and PKG_CONFIG_PATH for being able to use the scenario template
cd ..
export LD_LIBRARY_PATH=$(pwd)/ndnSIM-build/lib/
export PKG_CONFIG_PATH=$LD_LIBRARY_PATH/pkgconfig
Step 6.a: You might need to add those exports to your ~/.bashrc file.
Step 7: Download and configure scenario template
git clone https://github.com/named-data-ndnSIM/scenario-template.git scenario
cd scenario
./waf configure
Step 8: Create your examples in the scenario template and run them!