Chris Jean

Linux, WordPress, programming, anime, and other stuff
  • Home
  • Linux
  • Development
  • Random Ramblings

Restart Ubuntu’s Unity Without Logging Out

February 13th, 2013

Sometimes when you change a configuration in Unity that is based on configuration files, you need to force Unity to reload. In most guides that I’ve found, the recommendation is to simply log out and log in again. While this works, losing everything that you have open just to force a reloading of configuration files is a bit much. Fortunately, there is a very easy way to force Unity to reload.

These details are specific to Unity running in Ubuntu 12.10, but should work as long as your system is running Unity.

  1. Load a run dialog by pressing Alt+F2
  2. Type unity --replace
  3. Press the Enter key

The screen will flicker and things will start to look normal again in a few seconds. This is due to the entire desktop reloading. The end result is that the configuration files will have reloaded. The only side effects are that your windows may be reordered in the alt-tab listing and some windows may switch their desktop (typically, I have at least one window from my second desktop switch over to my first desktop).

Categories Linux, Tips 'n Tricks
Comments (0)

My Six Month Personal Fitness Results

July 13th, 2012

I’ve been overweight most of my life. I experienced many years of depression that started in elementary school. From that moment until early 2012, I have consistently gained weight.

In January, I decided that I had to get serious about weight loss, so I did.

While driving to work one morning, I decided that if I didn’t do something to change my life at that exact moment, that I never would. I made a contract with myself that I would immediately go and sign up at a gym and get a personal trainer, that I would do everything that trainer told me to do, and that I wouldn’t look back or second guess myself. I had thirty years of being irresponsible, now it was time for some personal responsibility.

So, that’s what I did. I messaged the office to say that I would be late. I drove to Results Fitness, a gym near my office and home. I met Jeff Miller, a trainer at Results. I signed up for the gym and to meet Jeff every Tuesday and Thursday. I committed to eat a specific meal plan every meal of every day. I do what my trainer tells me. I haven’t looked back. I haven’t second guessed my decision. I haven’t regretted anything.

Read More→

Categories Random Ramblings
Comments (25)

Some Great AMVs from 2011

January 10th, 2012

In celebration of my newly-operational Minitube, I thought I would share some great AMVs from 2011 that I found thanks to Minitube.

Unfortunately, one of my favorite AMVs in a long time is no longer on Youtube. You can find it here on AnimeMusicVideos.org. It’s responsible for getting me into Puella Magi Madoka Magica. You should definitely check it out.

This next one probably can only be viewed on Youtube proper. It uses video from ef – A Tale of Memories, a show that I’ve been meaning to watch. This video has definitely pushed it higher on my list.

Read More→

Categories Uncategorized
Comments (0)

Fix: Minitube Doesn’t Play Videos in Ubuntu

January 10th, 2012

I’ve been a huge fan of Minitube. I use it nearly every work day to run interesting videos to give me a nice sound backdrop to work by. Mostly, I find myself playing AMVs, but I also enjoy just typing in random stuff to see what it starts playing.

However, a few weeks ago, it just suddenly stopped working. I was sad, but there was a lot of stuff going on, so I just left it broken. Today, I found the fix.

On Minitube’s install page, Flavio mentions removing the phonon-backend-xine package as a possible solution. I tried it, and it worked. Given that I don’t know what other software may rely on this, I tried reinstalling the package, and Minitube still worked. After rebooting, I found that it no longer worked again, so it seems that the package does need to stay removed. I’ve updated the following to only show removing the package.

Here’s how you can do what I did.

[gaarai@tenshi ~/src]$ sudo apt-get purge phonon-backend-xine

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  phonon-backend-xine*
0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
After this operation, 651kB disk space will be freed.
Do you want to continue [Y/n]? 
(Reading database ... 285104 files and directories currently installed.)
Removing phonon-backend-xine ...
[gaarai@tenshi ~/src]$ 

Hopefully, you’ll be fast on your way to enjoying a fully-functional Minitube once again. If this doesn’t fix your issue, Minitube now has a forum that could help you out.

Good luck and happy Minitubing.

Categories Tips 'n Tricks
Comments (0)

MikuMikuDance + Moymoy Palaboy = Awesome Video

September 14th, 2011

I haven’t posted a cool video in a while, and I really need to start again as I keep losing track of awesome videos.

Someone took the Moymoy Palaboy (a Filipino duo that do awesome lipsync videos) guys singing the Backstreet Boys song Everybody and used MikuMikuDance to recreate the guys doing the lipsync as cute anime-style girls. So many awesome things in a mere minute and a half.

It’s definitely my new favorite video.

Categories Videos
Comments (0)

Creating a PHP ICO Creator for Favicons

July 21st, 2011
I’m happy to report that PHP ICO is now live on GitHub.

For the past couple of weeks, I have worked on creating a PHP library to create ICO files. This has been difficult as all the documentation for the ICO format is either sparse or not completely documented.

I’m doing this since I have yet to find a way of creating a valid favicon file using just PHP and PHP’s GD library. Sure, I can create a PNG file and change the extension to “.ico”, but that doesn’t work in all browsers, on all operating systems (such as Windows XP), and is more of a hack than a valid method for creating favicon files.

So, it is time to make one. I have a placeholder github repository named php-ico.

The primary goal is to make a robust, reliable library that creates valid ICO files that can be properly rendered on Windows XP+ and all the major browsers. Thus, my initial goal is not to support every format that exists nor is it to support parsing the ICO files. If the project gets enough attention, I’ll look at expanding the scope.

Here are the resources that I’ve found helpful as I’ve worked on this project:

  • ICO (file format) – Wikipedia article about the ICO file format. This has a very comprehensive description of the ICO header. It is sparse on details about the format of the image data.
  • BMP file format – Wikipedia article about the BMP file format. This helped me understand the headers and pixel data format for the BMP image data.
  • Portable Network Graphics – Wikipedia article about the PNG file format. This gave me what I needed to know to identify PNG image data.
  • Windows Bitmap File Format – Very good article that delves into more details about the BMP file format. The extra details about the different types of headers, compression methods, compression encoding, and examples were very helpful.
  • Icons – A Microsoft Developer Network article from 1995 that provides the original ICO file format spec. While this is the most authoritative, I really didn’t find this to be as much help as other sources.
  • Replacing ICON resources in EXE and DLL files – Article from The Code Project that has a breakdown of the format similar to what is found in the MSDN article. Example C code is provided.
  • Support Vista-style ICO files – Mozilla Bugzilla filed bug. The discussion has some great information about methods used to reliably parse varying ICO formats and structures. It also has some good test ICO files to try.
  • Convert HBITMAP to .ICO file – This Chironex Software blog post provided the last piece I needed: how to structure the opacity mask data. Where he found this information (since I didn’t find it in any of the above articles) I haven’t a clue.

If this post gets some traction and interest, I’ll consider putting together a post detailing all the different pieces I’ve found here. I’m not a spec writer, but I’d try my best. Let me know if you’d like to have me work on this.

Categories Development
Comments (12)

Upgrade PHP 5.1/5.2 to 5.3 on CentOS

June 24th, 2011

I’m finding that more and more software developers are being quite inconsiderate and are making code that requires PHP 5.3. Since many server-based and long-term support distros are still on PHP 5.2, this can make things difficult quickly.

I’ll share how I upgraded one of my servers, but I do need to let you know about some specifics about my setup as your setup may be different and require different steps to upgrade.

When I started, my system ran CentOS 5.5 and PHP 5.2.16. Now it is running CentOS 5.6 and PHP 5.3.3.

You won’t be able to follow these steps without root access, so that is definitely a requirement. I’m also running Apache. You may be using a different web server, but if you don’t know what I’m talking about, you are running Apache. I assume that if you run a different server, you will know what to change in my steps.

Read More→

Categories Linux, Tips 'n Tricks
Comments (85)

PHP 5.3 and “It is not safe to rely on the system’s timezone settings”

June 24th, 2011

I just updated one of my CentOS systems to PHP 5.3 (a chore best reserved for another blog post), and started to see the following warning popping up:

PHP Notice: in file index.php on line 15: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Chicago’ for ‘CDT/-5.0/DST’ instead

Annoying to say the least. The fix is much easier than the message makes it seem.

PHP 5.3 now requires that you either have a timezone set in your php.ini file or that you pass the desired timezone via the date_default_timezone_set() function before calling the date() function.

I opened my server’s /etc/php.ini file and searched for timezone. My ini file had a section like the following:

[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
; date.timezone =

I uncommented the date.timezone line and added the timezone I wanted.

[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = 'America/Chicago'

There are two very important things to do in order for this to work properly for you:

  1. Use a timezone that is appropriate for your needs. Use PHP’s List of Supported Timezones to find the timezone that works for you.
  2. Since your server is likely to cache the PHP configuration, you will want to restart your web server process in order for the change to be recognized. The command to execute varies by system, but for most systems, the following will work:
    [user@server /etc]$ sudo service httpd restart
    
    [sudo] password for user: 
    Stopping httpd:                                            [  OK  ]
    Starting httpd:                                            [  OK  ]
    [user@server /etc]$ 

    Of course, if you are already root, you won’t need to use sudo:

    [root@server /etc]# service httpd restart
    
    Stopping httpd:                                            [  OK  ]
    Starting httpd:                                            [  OK  ]
    [root@server /etc]# 
Categories Linux, Tips 'n Tricks
Comments (5)

View CSV Data from the Command Line

June 17th, 2011

I recently wrote a script to dump data into CSV files. The CSV files work well for using in other scripts, but they are a bit difficult to read in order to verify that the data looks good. Sure, I could transfer the files to my local system and open them up in OpenOffice Spreadsheet or a similar program, but I want to do quick checks of the generated data and constantly copying the data and opening it up again in a program would just slow me down. Fortunately, there is a better way.

Using a combination of the cat, column, and less commands that are available from most *nix shells, the CSV data can be rendered into a nice table and quickly navigated. Here is an example:

[chris@host data]$ cat file.csv | sed -e 's/,,/, ,/g' | column -s, -t | less -#5 -N -S

      1 number_of_tests  execution_time min  execution_time max  execution_time avg  execution_time std_dev  peak_memory_usage min  peak_memory_usage max  peak_memory_usage avg  peak_memory_usage std_dev  real_memory_usage min
      2 449              0.2421700954        0.2522599697        0.24422667392717    0.0013405194115834      22062656               22067696               22062951.732739        552.24028841091            22282240
      3 416              0.2449610233        0.2619900703        0.24721734340337    0.0015257664849685      21295528               21300888               21295541.019231        262.48728836508            21495808
      4 446              0.2286360264        0.2422661781        0.23043336515404    0.001174508347353       20895976               20900800               20895987.03139         228.20177111936            20971520
      5 428              0.1955471039        0.2902140617        0.1981168762521     0.0046106433816399      18045464               18048784               18045487.271028        276.98063531264            18087936
      6 436              0.2208828926        0.2558329105        0.22297720351353    0.0021463518368546      18717960               18723192               18718020.238532        557.06025400191            18874368

The output is easy to navigate with the cursor keys and is perfect for quickly verifying the generated data.

To use for your files, simply replace file.csv in the above example with your file’s name. The -#5 determines how many columns to scroll when using the left and right arrow keys. You can increase or decrease this as needed to make navigating easier.

For those interested, I’ve tested this on Debian-based (Ubuntu, Mint, etc) and Redhat-based (CentOS) systems, and it works on all of them.

I updated the command to fix a problem with handling empty entries, such as “…,data,,data,…”. The sed command takes care of changing those empty values to a space.

Categories Linux, Tips 'n Tricks
Comments (0)

Fix “Insecure $ENV{PATH} while running setuid”

June 6th, 2011

Yet another tale from trying to run a Perl script with the setuid bit turned on. See my earlier post on fixing “Can’t do setuid (cannot exec sperl)” for details about why running perl scripts with setuid bits is a special case.

I tried to run my script and I got the following message:

[user@server ~]$ run-script

Insecure $ENV{PATH} while running setuid at ~/run-script line 4.

The basic idea that this message is trying to get across is that an environment variable that is being used may contain data that could open up an attack vector. The way to fix this is by setting the variable to a set of defaults that don’t come from the user and thus are less susceptible to being manipulated by someone in order to break the security of the system.

In this case, my script executed a program on the shell. Since shell interpretation comes into play, the $PATH variable is looked at to decide where the program could be located. This is an attack vector as someone could just change that variable to cause their own code to be called, thus escalating their code’s privileges without your knowledge.

In order to avoid this, I set the $PATH variable to a restricted set for use in the script by adding the following in the script before my shell call:

$ENV{"PATH"} = "/usr/bin";

This may need to be modified to meet your specific needs. In addition to making this change, I went ahead and changed the call to the shell program to be an absolute reference to the program in order to further mitigate any potential issue, such as aliases.

Categories Linux, Tips 'n Tricks
Comments (1)
Next Page »

I believe that the free flow of information and ideas is key to the past and future development of mankind. Unless the content declares otherwise, the post content on this site is declared public domain (CC0 1.0 Universal) and can be used in any manner with or without attribution or permission. Of course, if you wish to give attribution back to me, that would be very nice. :)

This site is running WordPress with the iThemes Builder theme by iThemes.