Percentages are Reversable

6% of 50 = 50% of 6 = 3
 

Because x% of y is same as y% of x. This stems from commutative property of multiplication.
 

So, 6/100x50 = 6x50/100

Also X percent of Y is just multiplying the two together and dividing by 100:

  • 7% of 11 = 77/100 = 0.77
  • 4% of 20 = 0.80

 

Get Rid of Unwanted Dotted Lines in LibreOffice Calc

 Two methods:

  1. File --> Reload (dotted lines could reappear later)
  2. Tools --> Options --> LibreOffice Calc --> View --> Uncheck page breaks


Calculating percentages

 X% of Y is the same as Y% of X.  For example, calculating 32% of 50 is the same as 50% of 32, which is 16.

Fixing default zoom in LibreOffice Calc

  1. Close all LibreOffice documents
  2. Open a new document
  3. Adjust the slider on the bottom right to your desired zoom level
  4. Close the document (no need to save it first)
  5. Open a new document - it should be at your desires zoom level

NOTE! This does not work if you use the mouse scroll wheel!

Using the Excel SumProduct Function with multiple AND and OR conditions

Given NFL football data like the below, how many times does PHI go for it on 4th down? Here, "go for it" means attempt to gain enough yardage for another first down by passing or running the ball.

A B C
1 Team Down Play
2 ATL 1 RUSH
3 ATL 2 RUSH
4 ATL 3 PASS
5 ATL 4 PUNT
6 PHI 1 RUSH
7 PHI 2 RUSH
8 PHI 3 PASS
9 PHI 4 PASS
10 ATL 1 RUSH
11 ATL 2 RUSH
12 ATL 3 PASS
13 ATL 4 PUNT
14 PHI 1 RUSH
15 PHI 2 RUSH
16 PHI 3 PASS
17 PHI 4 RUSH

The goal is to count the rows when:

  • team = 'PHI'
  • AND down = 4
  • AND (play = "rush" OR play = "pass")


Here is the SUMPRODUCT forumla for this calculation, formatted for easier reading.

=SUMPRODUCT(
    --(
        (A2:A17="PHI")
      * (B2:B17=4)
      * ( (C2:C17="RUSH") + (C2:C17="PASS") )
    )
)


You can see that multiplication is used for the AND, while addition is used for the OR.

The double negative has the effect of coercing the boolean true/false that is returned into an integer, where true = 1 and false = 0.  The inner negative coerces to int, but leaves a negative value.  The outer negative flips the sign back to positive.  You can get the same effect just by multiplying by 1.
 

Calculating original sale price from total and tax rate

Problem: Given a total price and a tax rate, calculate the original sale price.

Example: Total Price = 27.03 and Tax Rate = 0.08125, or 8.125%

Sale price = Total Price / (1 + Tax Rate)
           = 27.03 / 1.08125
           = 25.00

Tax Amount = Total Price - Sale Price
           = 27.03 - 25.00
           = 2.03

How to scp and ssh from Ubuntu to a Raspberry Pi without a password

From your local machine, be able to log in or rcp or rsync files to the rpi without having to enter a password.  This enables automated scripts to push code to the rpi as a server, or to automate backups.
  1. Create a local .ssh directory with cd ~; mkdir .ssh
  2. Create a public/private key pair with ssh-keygen -t rsa (take all the defaults when prompted)
    • The private key is ~/.ssh/id_rsa
    • The public key is ~/.ssh/id_rsa.pub
  3. Copy the public key to the remote rpi with scp id_rsa.pub pi@192.168.1.100:./ (your ip address may be different)
  4. ssh to the rpi with ssh pi@192.168.1.100
  5. Create a .ssh directory with mkdir .ssh
  6. Move id_rsa.pub to the .ssh directory and rename it with mv id_rsa.pub .ssh/authorized_keys
  7. Test with ssh pi@192.168.1.100 - you should be logged in without entering a password.

Opening the gnome terminal maximized in Ubuntu 16.04

Using the Ctrl-Alt-T keyboard shortcut:
  1. Search for "Keyboard" in the Unity launcher
  2. Click the shortcuts tab
  3. Click "Custom Shortcuts"
  4. Click the "+" at the bottom of the window
  5. Enter a name, e.g., "Terminal"
  6. Enter the command: gnome-terminal --maximize
  7. Click "Apply"
  8. Set the keyboard shortcut by highlighting the row and typing the Ctrl-Alt-T key combination

Using the Unity Launcher
  1. Edit the file ~/.local/share/applications/gnome-terminal.desktop
  2. Paste these lines into the file:
    [Desktop Entry]
    Type=Application
    Name=Terminal
    Icon=utilities-terminal
    Exec=gnome-terminal --maximize

  3. Save the file
  4. Log out and back in again
The gnome terminal should launch maximized from either the Unity launcher or the Ctrl-Alt-T keyboard shortcut.  This does not solve the problem opening the terminal from Nautilus maximized.

Restore the Default Wallpaper on an Android Device

Works on Android 4.4.2

  1. SettingsDisplayWallpaperHome Screen
  2. Choose a Live Wallpaper
  3. Check the home screen to confirm the Live Wallpaper is working

Then:
  1. SettingsApplication Manager
  2. Force stop the live wallpaper
  3. Return to the home screen: your device is set to the default wallpaper

Calculating percentages

26 is 3/4 (75%) of what number?
Two ways to calculate:

  1. =26/(3/4)
  2. =4*26/3

Programming the KLIK1U to work with a Genie garage door opener


Step Result
Slide open the battery compartment Battery compartment is open and “program” button is exposed
Press and hold the “program” button until the led on the remote lights up LED on remote is lit
Press the Code/Learn button on the garage door opener LED on garage door opener begins flashing
Press the “I” button 6 times, ensuring the LED on the remote stops flashing after each press LED on garage door opener will be on steady after the 6th press
Press and hold the program button on the remote LED on garage door opener turns off
Press the “I” button on the remote to test Garage door opens and closes with the remote

https://www.chamberlain.com/CatalogResourcesV3/en-us/shared/files/tucmanuals/114A3485.pdf

Getting rid of a deleted email in iPhone

An email that was deleted from Microsoft Exchange server would not disappear from iPhone.

Steps to remove:
  1. Settings→Accounts & Passwords→Exchange (Mail, Contacts, Reminders, Notes)
  2. Turn off Mail for a few seconds, then back on.
  3. The account will re-sync everything and the email should disappear.


Downgrade Libreoffice to the current Ubuntu version

Upgraded to the latest LibreOffice and had performance problems.
Here are the terminal commands to revert to the current Ubuntu version:
  1. sudo apt-get remove --purge libreoffice*
  2. software-properties-gtk to open Software Sources
    • Click "Other Sources" tab and remove the libreoffice PPA
  3. sudo apt-get update
  4. sudo apt-get clean && sudo apt-get autoremove
  5. sudo apt-get install libreoffice


Calculating Percent Change

  • Method 1: (new - old) / old
  • Method 2: (new / old) - 1

Old value 100
New value 50
Method 1 =(B2-B1)/B1 -50.00%
Method 2 B2/B1-1 -50.00%

Calculating Inflation in Excel

Future value of 100 dollars at 3% inflation in 10 years = $74.41:

=100/(1+.03)^10

Formula to copy in cells to calculate inflated value:
Col A        Col B
Year     Inflated Value
0        =100*(1+.03)^A1
=A1+1    =100*(1+.03)^A2
=A2+1    =100*(1+.03)^A3
=A3+1    =100*(1+.03)^A4
=A4+1    =100*(1+.03)^A5
=A5+1    =100*(1+.03)^A6
=A6+1    =100*(1+.03)^A7
=A7+1    =100*(1+.03)^A8
=A8+1    =100*(1+.03)^A9
=A9+1    =100*(1+.03)^A10
=A10+1   =100*(1+.03)^A11

Microsoft VBA Get Existing Outlook Instance

Sub Get_Existing_Outlook_Instance()
  Dim objOutlook As Outlook.Application
  ' Gets the existing instance (if Outlook is already open) regardless of early or late binding
  On Error Resume Next
  Set objOutlook = GetObject(, "Outlook.Application")
  If objOutlook Is Nothing Then
      Debug.Print "Outlook is not open, getting a new instance"
      Set objOutlook = New Outlook.Application
  End If
  Set objOutlook = Nothing
End Sub

Microsift VBA Early vs. Late Binding Example


Private Sub Early_vs_Late_Binding_Example()
#Const LATEBINDING = False

#If LATEBINDING Then
    Dim objOutlook As Object
    Set objOutlook = CreateObject("Outlook.Application")
#Else
    ' NOTE! Early binding requires a typelib reference.  In the VBE click Tools -> References
    ' and make sure that "Microsoft Outlook xx.x Object Library" is selected
    Dim objOutlook As Outlook.Application
    Set objOutlook = New Outlook.Application
#End If
    
    Set objOutlook = Nothing
End Sub


Move Ubuntu Unity Launcher to the Bottom of the Screen

gsettings set com.canonical.Unity.Launcher launcher-position Bottom

To reset to the left side:
gsettings set com.canonical.Unity.Launcher launcher-position Left

Changing the window placement in Ubuntu

To see the current setting:
dconf read /org/compiz/profiles/unity/plugins/place/mode

To update the setting:
dconf write /org/compiz/profiles/unity/plugins/place/mode 1

(Try different values to understand the behavior.)

Restoring the default login screen background in Ubuntu Xenial

Changing the desktop wallpaper also changed the login screen. Follow these steps to override that behavior and reset the login screen back to the default.
cd /usr/share/glib-2.0/schemas/
sudo vi com.canonical.unity-greeter.gschema.xml
Look for this key node:
<key name="draw-user-backgrounds" type="b">
<default>true</default>
<summary>Whether to draw user backgrounds</summary>
</key>
Change the value true to false.

You can also remove the white dots by changing this key node:
<key name="draw-grid" type="b">
<default>true</default>
<summary>Whether to draw an overlay grid</summary>
</key>
Now recompile the schema with this command:
sudo glib-compile-schemas /usr/share/glib-2.0/schemas/
Log out and back in to see the change.

Biweekly vs. semi-weekly

  • Biweekly means once every two weeks.
  • Semi-weekly means twice per week.

Ubuntu Unity Configurations

To position the launcher at the bottom of the screen:
gsettings set com.canonical.Unity.Launcher launcher-position Bottom

To return to the default position on the left:
gsettings set com.canonical.Unity.Launcher launcher-position Left

To open new windows centered on the screen without installing compiz-conf:
dconf write /org/compiz/profiles/unity/plugins/place/mode 1

Getting a list of stock symbols with Python

Lists of stock symbols can be found at either of these links:


You can download a list of symbols from the nasdaq.com site for the Nasdaq, NYSE, and AMEX exchanges.

The FTP directory at ftp.nasdaqtrader.com gets updated every night at 3:00AM (symbols can change). Here is a quick Python script to download the nasdaqlisted.txt and otherlisted.txt files from the ftp site:


#!/usr/bin/python

# typical use: python get_symbols.py > symbols.txt

import urllib

def get_data( url ):
    data = urllib.urlopen( url )
    lines = []
    for line in data:
        lines.append( line.rstrip().split('|') )
    return lines


url = 'ftp://ftp.nasdaqtrader.com/SymbolDirectory/'
files = ['nasdaqlisted.txt', 'otherlisted.txt']

for f in files:
    print get_data( url + f )


List Comprehensions in Python

# create a new list
>>> a = [1,2,3,4,5]
>>> a [1, 2, 3, 4, 5]

# sample list comprehension expression; equivalent to b = a
>>> b = [a[i] for i in range(len(a))]
>>> b [1, 2, 3, 4, 5]

# only even indices
>>> b = [a[i] for i in range(len(a)) if i % 2 == 0]
>>> b [1, 3, 5]

# only even indices and conditionally modifies the value of a[i] 
>>> b = [a[i]*2 if i > 1 else a[i] for i in range(len(a)) if i % 2 == 0]
>>> b [1, 6, 10]