LinuxSysAdmin

Things I don't want to look for twice..

Monthly Archives: February 2014

Streaming PulseAudio on a Samsung SmartTV

So, recently I turned back to Linux and I was sick of Windows and NSA and all that crap. And my all time favourite for a desktop still remains Linux Mint. So I got myself a 64-bit Linux Mint 16 (Petra), installed ..and so far so good. Surely, I had some issues with ATI proprietary drivers, especially in Google Chrome which actually have solve by accessing chrome://flags and changing some stuff around. But today, as I own a Samsung Smart TV, I needed my desktop to stream my Rhythmbox to it. (I don’t use Banshee, the default player, ..well, just not a fan)

Anyways, so if you need to stream your output to a Samsung SmartTV, this is what you’ll have to do: (in the mean time, give the middle finger for Samsung, as they’re not planning on doing Samsung Link for Linux)

1. install the necessary packages:

sudo apt-get install rygel rygel-gst-launch wavpack paprefs pavucontrol

2. edit your own users’s rygel.conf:

vim ~/.config/rygel.conf

3. add something like this:

[general]
upnp-enabled=true
enable-transcoding=true
media-engine=librygel-media-engine-gst.so
interface=wlan0
port=0
log-level=*:4
allow-upload=true
allow-deletion=true
[GstMediaEngine]
transcoders=mp3;lpcm;mp2ts;wmv;aac;avc;flac
[Renderer]
image-timeout=15
[Tracker]
enabled=false
share-pictures=true
share-videos=true
share-music=true
strict-sharing=false
title=@REALNAME@'s media
[MediaExport]
enabled=false
title=@REALNAME@'s media
extract-metadata=true
monitor-changes=true
virtual-folders=true
[Playbin]
enabled=false
title=Audio/Video playback on @HOSTNAME@
[ZDFMediathek]
enabled=false
rss=508
update-interval=1800
video-format=wmv
[GstLaunch]
enabled=true
launch-items=myaudioflac
myaudioflac-title=FLAC audio on @HOSTNAME@
myaudioflac-mime=audio/flac
myaudioflac-launch=pulsesrc device=upnp.monitor ! flacenc
[Test]
enabled=false
[ExampleServerPluginVala]
enabled=false
[ExampleServerPluginC]
enabled=false
[ExampleRendererPluginVala]
enabled=false
[ExampleRendererPluginC]
enabled=false
[MPRIS]
enabled=false
[External]
enabled=false

This will transcode everything to FLAC and advertise this as “FLAC audio on @HOSTNAME@”. I did this because around half of my music collection is actually FLAC. To transcode to mp3, replace the following block:

[GstLaunch]
enabled=true
launch-items=myaudiompeg
myaudiompeg-title=MPEG audio on @HOSTNAME@
myaudiompeg-mime=audio/mpeg
myaudiompeg-launch=pulsesrc device=upnp.monitor ! lamemp3enc target=quality quality=6

4. Run paprefs and check everything under Network Server:

2

 

5. (restart your computer – I sincerely think it’s optional step, but I’ve read is some place)

6. Start your music player, hit Play, then run pavucontrol and select the output to be “DLNA/UPnP Streaming”

1

 

7. Start¬†rygel, preferably in the background, after you’ve seen you don’t have any errors.

8. Turn on your TV and hit the “Src” button on the remote and you should see something like “Network Gst Launch”. Select that, than “Music”, then click on “FLAC audio on hostname”

That’s it! It should automagically start playing..

NOTE: all commands should be run as your own user, not root.

Got inspired from:

http://community.linuxmint.com/tutorial/view/1506

https://wiki.gnome.org/Projects/Rygel/Pulseaudio

 

Pig Latin (python)

pyg = 'ay'
original = raw_input('Enter a word: ')
word = original.lower()
first = word[0]

if len(original) > 0 and original.isalpha():

if first[0] == 'a' or first[0] == 'e' or first[0] == "i" or first[0] == "o" or first[0] == "u":
new_word = word + pyg
print new_word
else:
new_word = word[1:] + first + pyg
print new_word

else:
print 'empty or has numbers/special characters'

Sink my battleship (python)

from random import randint
board = []
for x in range(5):
 board.append(["O"] * 5)
def print_board(board):
 for row in board:
 print " ".join(row)
print "Let's play Battleship!"
print_board(board)
def random_row(board):
 return randint(0, len(board) - 1)
def random_col(board):
 return randint(0, len(board[0]) - 1)
ship_row = random_row(board)
ship_col = random_col(board)
# print ship_row
# print ship_col
for turn in range(4):
 # print "You are on turn " + str(turn + 1) + "."
 # print "Turn #%i: " % (turn + 1)
 # Everything from here on should go in your for loop!
 # Be sure to indent four spaces!
 guess_row = int(raw_input("Guess Row:"))
 guess_col = int(raw_input("Guess Col:"))

 if guess_row == ship_row and guess_col == ship_col:
 print "Congratulations! You sunk my battleship!"
 break
 else:
 if (guess_row < 0 or guess_row > 4) or (guess_col < 0 or guess_col > 4):
 print "Oops, that's not even in the ocean."
 elif(board[guess_row][guess_col] == "X"):
 print "You guessed that one already."
 else:
 print "You missed my battleship!"
 board[guess_row][guess_col] = "X"
 if turn == 3:
 print "Game Over"
 # Print (turn + 1) here!
 print str(turn + 1)
 print_board(board)

Host1Plus fake advertising (solved)

This morning I’ve ordered a level 1 VPS from Host1Plus. I’ve wanted to do that for a long time, but I wasn’t very impressed by CPU offer. Yesterday when I checked their offer, I’ve seen they’re offering 1 core for the entry-level plan, so I ordered a level 1 for 2 years. Paid with my VISA card this morning and I had my VPS by the time I woke up after my afternoon sleep – yeap, I sleep in the afternoon, so what?!

So, here is the offer:

2

That’s cool, 1 core just for me. So I created my account, paid for 2 years and wait quietly for them to set up my new VPS. After few hours, as their email didn’t come, I checked my client area page and saw that:

ps1

(yeap, I’ve deleted the IP Addresses field)

Anyway, I saw the 50% CPU and decided to dig deeper into it, and found out that:

3

So it seems that the web interface in client area was right. Instead of having full 3.4GHz core, I only have 1696MHz, which, you already guessed, is around 50%. Nice, so not one core, just a half of it. So I thought there’s an error in the template they’re deploying, so I entered a live chat with a support guy. Here are some parts of it. First, we talk about what the website says:

16:48 Host1Plus: Well you have 1 CPU core with 50% of it’s speed
16:48 Me: yeap
16:49 Me: shouldn’t I have 1 core with 100% speed?
16:49 Me: http://www.host1plus.com/vps-hosting/
16:50 Me: it clearly states 1 core, not half core
16:52 Host1Plus: Your server can use 50% of 1 CPU core, that is defined in service configuration
16:52 Me: Yes, but what I just bought is 1 full core, not half of it
16:53 Me: and VPS hosting level 1 means 1 full core, 256MB ram and 15GB of disk space
16:53 Me: if you need, I can send you a print screen of your website
16:54 Host1Plus: I am afraid it does not state in the plans that level 1 has 1 full core, it shows that it includes 1 core
16:54 Me: exactly, 1 core, not 0.5 core
16:56 Host1Plus: It seems there is misunderstanding in our communication, have you checked how much CPU speed it shows inside your server ?
16:56 Me: before buying a host1plus VPS I had a free one, which clearly stated I don’t have a full CPU core
16:56 Me: model name : Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
stepping : 9
cpu MHz : 1696.060
16:57 Me: exactly half of 1 core
16:57 Host1Plus: Half of it’s speed, not the core itself
16:58 Me: you can’t split a CPU core in 2
16:58 Host1Plus: That’s why it shows 50%
16:58 Me: so, I see 2 options: 1. you’re misguiding clients or 2. service configuration not updated with the specs from the site
16:59 Host1Plus: If it would be 100% then you could all 3.40GHz
16:59 Me: exactly!
16:59 Me: which currently, I don’t

So yes, they are showing 1 core, but you only get half. Wait, it’s getting better:

17:01 Host1Plus: As I can see level 1 comes with 50% priority, level 2 – 100%, level 3 – 150%, level 4 – 200% and level 5 with 350%
17:01 Host1Plus: Everything is all right with the plans
17:03 Me: well, thing is, from your website, you can understand: level1: 100%, level2: 100%, level3: 200%, level4: 200%, level5: 400%
17:03 Me: 100% meaning 1 full core

Everything alright with the plans, I’m sure, but not alright with the website. So, although on level3 and level4 it says you get 2 cores, you get 1.5 cores for level 3, 2 cores for level4 and 3.5 cores instead of 4 for level 5. Fucking marketing department!

This is funny:

17:16 Host1Plus: Unfortunately, I don’t see the reason why your server should have more CPU speed than it’s defined in the configuration, you have ordered level 1 even without asking about it’s specifications before ordering

Why not calling you anyways? And just have contact info on your website? That should avoid this kind of issues. But, as long as you’re writing something on your website, ..I would expect to pay for what I see, not for what you mean. Now, the refund option:

7:18 Me: ok, upgrading is not an option, but as it’s not even 1 day since I bought your product and not pleased because it’s not what it’s advertised, I can surely ask for a refund, right?
17:20 Host1Plus: You may get refund only if your request matches with Host1Plus refund policy http://www.host1plus.com/refund-policy/

Here is their refund policy:

Terms that must be met in order to receive a refund:
– Refunds are only applicable for monthly hosting service fees;
– Refunds are only applicable if we have failed to provide 99% uptime of the service;
– Refund is provided only once for a single account of the customer;
– Refunds are only applicable for services paid using Credit Cards. If payments were done using 3rd party checkout services (PayPal, etc.) refunds are only provided to clients HOST1PLUS accounts credit balance.

So guess what? Not getting a refund, because it was not a monthly payment. Silly me! Final issue: payment recurrency. I tried to get them to disable it. But:

17:24 Me: how can I make sure it’s not recurring payment? and my card is not credited automatically in 2 years?
17:25 Me: should I contact braintree? is there some settings you’ll make to my account?
17:25 Me: I wish that in 2 years my card won’t be billed automatically by you
17:25 Me: how can I do that?
17:27 Host1Plus: If you will cancel the service before the due date, the outstanding invoice will be canceled and you won’t be charged
17:30 Me: and there’s no way you can disable recurring payment on this account?
17:31 Me: because I might forget the expiration date..
17:33 Host1Plus: I am afraid I don’t have permission to disable recurring payment, however, I can advice with the management whether such option could be disabled for you

So I’m left with half core for the next 2 years. Probably enough for what I’m needing this for, but still, someone should modify the website or increase the CPU percentage. In the mean time, don’t trust what’s on host1free.com, get a live chat before trying to buy something from them first.

 

UPDATE!!!

Yesterday, a Senior Administrator¬†from Host1Plus contact me and asked me if there’s a way we can solve this, as they’re willing to increase my processing power to 1 full CPU, as stated on the webpage when I ordered the package. So, considering template custom changes were not a solution, I got upgraded to the Level 2 VPS for free for the rest of my billing period, which yes, gives me a full CPU, but also double memory (512MB instead of 256MB) and bigger swap. Also, noticed they changed their offer to clearly state 0.5CPU instead of 1. And I guess I’ll continue with level 2 after this, looks better for my tests.

So, after seeing they’re actually concerned about their customers, at least the ones that own a blog, I can recommed them to be quick and fast in processing orders and support tickets. Prices are more than ok, too!