9/12/2013

Bash Shell Math

While the bash shell can only do integer arithmetic, it can do it in several ways:
Double Parenthesis, Dollar Square Brackets. the let statement, and command substitution of expr which was used to arithmetic in the original Bourne Shell, sh.

Double Parenthesis

x=$(( 5 * 3 )) ; echo $x
15

y=$(( $x / 4)) ; echo $y
y=$(( x / 4)) ; echo $y # dollar is optionaly
# Floor division rounds down always

Increments/Decrements
y=0
((y++)) ; echo $y
1
((y--)) ; echo $y
0
((++y)) ; echo $y
1
((--y)) ; echo $y
0
((y+=2)) ; echo $y
2
((y-=2)); echo $y
0

Different Base Numbers
x=$((2#0101)) ; 
echo $x
5
x=$((16#ff)) ; echo $x
255
Also:
echo $((0xff)) # hexadecimal
255
echo $((0Xff)) # hexadecimal
255
echo $((077)) # octal
63


Dollar Square Brackets

x = 0
x = $[ $x + 1 ]
echo $x
1

let Statement

The let statement is special in that expressions can dereference the value of a variable without using the dollar symbol. For example,
ec
let x=3
let y=4 + x
echo $y
7

expr Command Substitution

x=`expr 3 + 4`
echo $x
7



Ad Word Soup: Decoding the acronyms CPA, CPC, CPI, CPM, CTR

Ad Word Soup: Decoding the acronyms

Others may go into greater detail, but here's what the acronyms mean that are used in on-line advertising.

CPA - Cost Per Action

CPA is cost per action or payment for when user acts upon an ad

CPC - Cost Per Click

CPC is cost per click or payment for when a click on an ad occurs

CPI/CPM - Cost Per Impression(s)

CPI is cost per impression
CPM is cost per 1000 impressions

CTR - Click Through Rate

CTR is the number of clicks divided by the number of impressions times 100. 
It is normally expressed as a percentage. For example,
If 5 people click out of 100 impressions, then the CTR would be 5%. 

Click Fraud

Fraud is a problem, as well as people gaming the system 

What Advertising Model To Use


5/25/2013

Verizon Samsung Galaxy S4 Root, Recovery, ROMs, More...

Verizon Samsung Galaxy S4 Root, Recovery and ROMs

Root

The  Samsung Galaxy S4 has only been out on Verizon a few days, and it's already been rooted. The http://www.sxtpdevelopers.com site already has a good forum going.  Despite Verizon's attempt to harden the kernel to prevent the Motochopper exploit that is used from working, the exploit works by first loading an earlier version of the kernel, then running the exploit, then reloading the latest kernel.

Recovery

There's a new set of tools for flashing kernels and recoveries that works around the locked bootloader on the Galaxy S4 called Loki. While I've not downloaded the source code yet to use it, it's my understanding that the recovery installed by GooManager uses this set of tools.

So, after you've got root, go get GooManager and you can install the Team Win Recovery Project (TWRP) recovery.

The sex tape developer's site also has a CWM recovery under development as discussed in this forum. It looks like in order to try this one, you'll need to download and build the Loki tools.

ROMs

Perhaps the most important ROM of all is out at the sex tape developer's site, the stock unrooted original ROM. At this point, there are several other proof of concept ROMs under development there as well, but nothing that looks ready to really use yet.

Of course, if you want to go looking for ROMs, a good place to go is always the xda-developers.com site. Today, the Verizon Samsung Galaxy S4 forum is at the top of the list! So far, I've only one ROM here, a stock rooted odexed and deodexed.

Kernels

The kernel from Faux123 is out for all US and International versions of the Galaxy S4. I just downloaded from this thread.

Google Wallet

Similar to getting Google Wallet working on the Samsung Galaxy S3, the S4 requires a /system/build.prop hack, flashing a deodexed ROM, loading the Xposed framework, and applying an Xposed framework patch. 

This XDA thread was started for T-Mobile, but can be followed except that before beginning you will want to download a deodexed ROM for your carrier of the device, like the Verizon one mentioned in this thread from XDA Developers. Basically, this will make your phone look like a Sprint Galaxy S4 device, which has access to the app. Once the app is installed and working, you can revert your build.prop back to the original.

Repositories

I stumbled upon this repository which has many of the files that you need, not just for the S4, but many other Samsung devices as well.

5/01/2013

GRUB 2 Bootloader

While GRUB Legacy received it's last update in 2005 to 0.97, it will probably be around for several more years. Meanwhile, GRUB 2 has begun to replace GRUB in progressive distributions like Ubuntu and Fedora. The new GRUB, GRand Unified Bootloader, offers several advantages:
  • Dynamically loaded modules
  • Non-ASCII character support
  • Ability to boot from partitions inside of Logical Volume Management (LVM) or RAID
  • Ability to work with many architectures without a PC BIOS
As in previous posts, what I will describe pertains to Fedora. Notably, Fedora uses /boot/grub2/grub.cfg instead of /boot/grub/grub.cfg that I've seen mentioned for Ubuntu-based distributions.
Previously, GRUB stored it's components under /boot/grub and was primarily configured with either /boot/grub/menu.lst or /boot/grub/grub.conf.

Now, GRUB 2 uses several locations for it's files:
  • /boot/grub2
    • Contains many module files
    • grub.cfg which should not be edited manually
    • grubenv another configuration file which should not be edited
  • /etc/default/grub
    • contains the entries for creating a default boot entry
    • typically where customization will be done
  • /etc/grub.d directory
    • contains scripts that are run by grub2
    • scripts can be customized or added
    • Contains the following executable scripts: 
      • /etc/grub.d/00_header
      • /etc/grub.d/10_linux
      • /etc/grub.d/20_linux_xen
      • /etc/grub.d/30_os-prober
      • /etc/grub.d/40_custom
      • /etc/grub.d/41_custom
      • /etc/grub.d/90_persistent
  • /usr/lib/grub/directory
    • Stores a couple of library files
  • /sbin/grub2-mkconfig
    • Used to regenerate the /boot/grub2/grub.cfg
Here's what the /etc/default/grub looks like in Fedora 16:
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
# GRUB_TERMINAL="serial console"
# GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600"
GRUB_CMDLINE_LINUX="quiet rhgb"
GRUB_DISABLE_RECOVERY="true"


There are just a few of entries in this file that might need customization:
The GRUB_TIMEOUT is how many seconds before the default is booted. Some people might like more time than this, particularly if dual booting operating systems.

The GRUB_CMDLINE_LINUX contains the parameters that are passed to the Linux kernel. Occasionally, some systems might require additional parameters be passed, so this might also be customized.

Also, the GRUB_TERMINAL and GRUB_SERIAL_COMMAND might be uncommented to provide a serial console.

After updating don't forget to execute:
/sbin/grub2-mkconfig




4/05/2013

Installing Google Wallet on Verizon Galaxy S3

No fancy installer is necessary to get Google Wallet to work on the Galaxy S3 on Verizon, on a few minor edits to the /system/build.prop are required. Installing Google Wallet is possible on the Verizon Galaxy S III, if your phone appears as a Galaxy Nexus. Assuming you have rooted your phone, and installed a decent version of busybox, then you can execute in a root shell on the phone(at your own risk).:

cp /system/build.prop /mnt/extSdCard/build.prop.original
mount -o remount,rw /system

Use sed to edit the /system/build.prop
sed -i 's/ro\.product\.model.*/ro\.product\.model=Galaxy Nexus/' /system/build.prop
sed -i 's/ro\.product\.name.*/ro\.product\.name=yakju/' /system/build.prop
sed -i 's/ro\.product\.device.*/ro\.product\.device=maguro/' /system/build.prop
mount -o remount,ro /system
reboot

or use vi to make the following changes in /system/build.prop from:

ro.product.model=SCH-I535
ro.product.name=d2vzw
ro.product.device=d2vzw

to

ro.product.model=Galaxy Nexus
ro.product.name=yakju
ro.product.device=maguro

Save your changes (:wq)
mount -o remount,ro /system
reboot

With the modified build.prop can install Google Wallet from the market.
When the installation is finished and you have successfully configured Wallet, 
you can revert to the original /system/build.prop with:

mount -o remount,rw /system
cp /mnt/extSdCard/build.prop.original /system/build.prop
mount -o remount,ro /system
reboot

3/18/2013

Windows 8 and Linux on a Toshiba Satellite Laptap

 Windows 8 and Linux on a Toshiba Satellite Laptap

About a week ago, I got a new laptop: a Toshiba Satellite C855D-S5351. With the $50 rebate and $120 instant savings available on it at Office Depot, I thought it was going to be a great deal for $329. Perhaps, if I only wanted to run Windows 8 on it, I would be satisfied, but because I also want to run Linux on it, I've had to struggle to get a few things working.

First, in order to make Windows 8 livable, I would recommend installing Classic Shell. You can download it from  http://www.classicshell.net/. As shown in the screenshot, Classic Shell not only provides the Start Menu that is missing in Windows 8, but a greatly improved Windows Explorer. The menu can even look like the version of a Windows Start Menu that you like the best. I really like locating things where they always have been in Programs or the Control Panel, as well as the Windows key on your keyboard will now activate this menu. When you want to go to the Windows Metro look, you can either Alt-tab to the App, or move over the right side of the screen, and activate the Start icon.

Preparing to Install Linux on a Windows 8 System


Before you do anything to your hard disk, you should make a "Repair Disk Windows 8 64bit". Point to upper right, click the Search icon, select Settings, and then click in the box to type "drive". Choose the option to create a recovery drive. It can be a USB disk, CD or DVD.  Warning: If you don't create a Repair Disk, then Windows 8 may not boot and it may not be easy to fix.  You should also create a new Repair Disk after successfully completing any changes to your hard disk.

Although I didn't make the recovery disk until after I got in trouble installing Fedora 17, I was able to get Windows 8 to boot after installing Linux. I was able to get it to recover by using a Live GParted CD. After booting the CD, I right clicked the Windows Recovery partition, and I set it the flags on it to include "boot". You may not be so lucky!

Create Space to Install Linux Using Disk Management

In order to get Linux installed to begin with, I first had to create some space on the laptop. I searched in Settings for "Disk Management". Start the Disk Management tool with the descripton "Create and format hard disk partitions".

Select the largest partition and right click to choose to shrink it.

At minimum, you will want to shrink it by at least 10Gb, but with a 640Gb hard drive, I was able to shrink mine by about 400Gb.

Next, to be able to boot the DVD to perform an install, I used the following procedure to switch to BIOS, disable Secure Boot, enable CMS (compatiblity booting), and boot an install DVD.

At first I tried installing CentOS 6, and it succeeded nicely, but without ethernet support by default. I never got wireless working, although I think it may be possible using the compat-drivers discussed below.

When I quickly tired of the lack of available current packages from CentOS 6 (and other related repositories), I wanted to upgrade to Fedora. I tried the latest Fedora 18, but unfortunately, the brand new installer failed. So, next I tried the Fedora 17 DVD install and it succeeded. I was able to get ethernet, wireless, bluetooth, radeon, and other drivers working successfully.

Booting From Windows 8 to Linux

After booting, click the screen or log out of your account
Click the power icon in the lower right corner and choose Restart
Press F2 when Toshiba logo appears
Use arrow keys to navigate to Security menu
Go down until you arrive at Secure Boot
Press Enter to change the value, use arrows to change to Disabled, press Enter to go back
Up to the top, over to the Advanced menu
Down to System Configuration, and press Enter.
Down to Boot Mode
Press Enter to change to value to CMS Boot, and Enter to go back. (Press F10 and Enter)
Press Escape to go back to the top level menus.
Go up and over to the right to the Exit menu
Select Exit and save changes

When you want to come back, then follow this procedure:

Booting From Linux to Windows 8

Restart
Press F2 when Toshiba logo appears
Over to the Advanced menu
Down to System Configuration, and press Enter.
Down to Boot Mode, and press Enter
Use arrow keys to change to value to UEFI Boot, and press Enter
Press Escape to go back to the main menus
Go up and over to Security menu
Down arrow until you arrive at Secure Boot, and press Enter
Use the arrow keys to change the value to Enabled and press Enter  (Press F10 and Enter)
Go up and over to the right to the Exit menu
Select Exit and save changes
Boot into Windows 8

Ethernet networking

The Atheros ethernet device is shown on the PCI bus with lspci -nn as:
01:00.0 Ethernet controller [0200]: Atheros Communications Device [1969:1090] (rev 10)
There is no driver for this device yet in the kernel,  although one is proposed according to http://www.linuxfoundation.org/collaborate/workgroups/networking/alx.

From this document I found the source that is used to make the alx.ko kernel module needed for wired networking. The procedure there will only enable the ethernet driver, but not the other compat-drivers. Once built, this alx kernel module worked well in Fedora.

If you only want ethernet support then the procedure to build the module with the compat-drivers download is:


./scripts/driver-select alx

make

sudo make install

Making (Almost) All the compat-drivers 

Since the radeon driver is already working in Fedora, and the one from the compat-drivers doesn't work  so well, I didn't want that driver to be built and installed. So, I commented out building the radeon driver in the   drivers/gpu/drm/Makefile.

I did want to have the wireless driver built, but there was a problem in the source I downloaded with building another wireless driver (wil6210), so building all the drivers wasn't working. Since I didn't need this driver, I commented out building the wil6210 driver in ./drivers/net/wireless/ath/Makefile, as explained below.

Getting Wireless and Wired Ethernet Working 

The Toshiba Satellite C855D-S5351 laptop that I using has a Realtek Wireless network interface which uses the rtl8723ae kernel module as a driver. This driver is also not included in the main stream kernel,, but is a part of the compat-drivers package.

In order to build everything except the radeon driver and the wil6210 wireless driver that refused to build, I made the following changes:

First, to not build the radeon driver, the file ./drivers/gpu/drm/Makefile had to have the line changed  from:
obj-$(CONFIG_COMPAT_DRM_RADEON)+= radeon/
to by adding a # at the beginning of the line:
#obj-$(CONFIG_COMPAT_DRM_RADEON)+= radeon/


Second, in the ./drivers/net/wireless/ath/Makefile, the following line originally appeared as:
obj-$(CONFIG_WIL6210) += wil6210/
To stop building this driver a # was added to the beginning of the line like:
#obj-$(CONFIG_WIL6210) += wil6210/


Once these changes are made to the two Makefiles, then you are ready to build and install the drivers with:
make
sudo make install

Centos/Redhat

Although I had no success getting the compat-drivers to be built under Centos or Red Hat Enterprise Linux, I found a couple of potential solutions. There is a repository compatible with RHEL that exists at http://people.redhat.com/sgruszka/compat-wireless.repo.

Also, there is the "El Repo" repository for the ethernet driver, and instructions for configuring this repository at http://elrepo.org/tiki/tiki-index.php. Using another Internet connected machine, I did successfully use this repository to download the kmod-alx driver and get it to work with Centos 6.

Fedora 17

Installation of Fedora 17 did present one challenge. The installer would not continue past custom partitioning (I wanted to preserve my /home partition). It complained about not having a BIOS Boot partition for Grub 2. The installer would automatically create this partition in automatic partitioning mode, but provided no way to do it manually in the custom partitioning mode.

With UEFI, systems don't use a "MS-DOS Partition Table" on the hard drive, instead they use "Guid Partition Table" or GPT type. The partitioning tool fdisk does not work with GPT partitions, so something like parted or gparted needs to be used instead. Since parted can be very challenging and unforgiving, I decided against using it, even though I could access it from the installation shell.

The solution I used instead to create a special partition with the boot_grub flag set was a Live CD version of Gparted from http://gparted.sourceforge.net/download.php. Once the CD was booted, I  created a 10Mb partition, and right-clicked it to set the boot_grub flag on it. Once this partition existed, then Fedora 17 was able to use custom partitioning successfully during installation.

Windows 8 

After all seemed well with the completed Fedora installation, I attempted to boot back to Windows 8. Unfortunately, after following the above procedure to go back to UEFI and Secure boot, I encountered an error message about not having any bootable partition. GParted Live CD to the rescue again! Using GParted, I right-clicked the Windows Recovery partition, and set it's flag to boot, and applied the change. Surprising Windows 8 booted right back up without any apparent issues.

Conclusion

It is possible to use both Windows 8 and Linux on the Toshiba Satellite C855D-S5351 laptop. Although I disabled Secure and UEFI booting in order to make it possible. Next, I may explore the possibility of installing Linux using Secure UEFI booting, as several distributions claim that capability.

Soon, the Atheros alx kernel module for wired ethernet networking should be in the mainstream kernel. Reportedly, the Realtek Wireless rtl8723ae kernel module may be reworked and merged with other similar modules for Realtek Wireless devices, so it may also be available in the mainstream kernel in the near future. For now, there's compat-drivers, compat-wireless, and various repositories around to enable the use of both wired and wireless networking.




How to create a Custom GNOME 3 Launcher

How to create a Custom Gnome 3 Desktop Launcher

Creating a custom launcher icon to put on the Gnome 3 Desktop dock called "Dash" is fairly easy, if you know what to do.

Create a ".desktop" file with the command: 
gnome-desktop-item-edit ~/Desktop/ --create-new MYAPPNAME.desktop

Now, copy it to /usr/share/applications as the root user or using sudo:
sudo cp MYAPPNAME.desktop /usr/share/applications

Then, the application can be found in the overview mode of Gnome 3 (when you press the Windows key and start typing "MYAPPNAME". Right-click on the found icon and choose "Add to Favorites" or just drag it over into the dock ("Dash").

About Me - WrightRocket

My photo

I've worked with computers for over 30 years, programming, administering, using and building them from scratch.

I'm an instructor for technical computer courses, an editor and developer of training manuals, and an Android developer.