Month: July 2016

Journal Entry – 07232016

Journal Entry – 07232016

So Potato, seems like she is starting to become more comfortable in her new home. She is now exploring more of the home and even gone into the bed room where Cassie and I sleep. Although she has tried to jump on the window ledge only to cause the vertical blinds to make noises which in turn woke me up. When she saw me awake, she ran back to her hiding space on the couch. She is warming up to me where she has come up to me and wanted attention from me.

I am still listening professional cellists play. In addition, and still working on my E Major Scale. It’s getting a little easier every time I play and expectantly trying to remember the figure placement. I have started learning the Hunter’s Chorus, C. Schroeder, Op 31, No. 5.

I finally got my car back from the repair shop and it looks good now! I have not drove it a lot lately as I have been using Caltrain, but I will report on it next week. Also, The rental that I got while my car is in the shop, has gotten into an accident on Sunday. It looks like my neighbor side swiped it with here car and cause some paint exchanged. I was not exactly mad at my neighbor as in more disappointed in the fact that she has not come forth about it and owned up to it. A few days later I did cross paths with her and we just exchange “Hello”. Yes, I wanted to talk to her about it, and in the process I would have gotten upside, but I just dropped it and let it be. Her actions alone (ie, not telling me she hit my car, not leaving a note, nor not notifying the insurance company) already told me everything. I return the rental, file the paper work, and notify my insurance company.

Next weekend, Cassie and I are going to Monterey for the weekend! I am hopping that weather is good on the weekend. I was thinking maybe we can go whale watching. Also, I want to take her to the Old Fisherman’s Grotto. They have great Clam Chowder and Ghirardelli Chocolate Shop in Monterrey as well! More info to come!

Creating Self-Signed Certs on Apache 2.2

Creating Self-Signed Certs on Apache 2.2

This page will walk though the process of creating a secure Self_Signed Certificate for Apache2. In order to get started you will need to make sure that OpenSSL is installed. If it is not install, refer to the site: http://www.openssl.org on how to install the software.

===== Getting Started =====

Need to generate a key. So will enter the fallowing command:


openssl genrsa -des3 -out newca.key 4096

After awhile it will prompt you to enter the fallowing information:

Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:
Email Address []:


Create a certificate and sign it. This example certificate will last 365 days:
openssl req -new -key newca.key -out newca.csr
openssl x509 -req -days 365 -in newca.csr -signkey newca.key -out newca.crt

===== Getting around Apache prompt =====

If the cert is protected with a password, by default Apache will prompt for the password when it starts. This can be a problem since you will need to enter the password each time Apache is restarted. We can fix this by having Apache call a program that gives the password to Apache. Will create a script in /etc/apache2/ssl name password.sh. Then add the fallowing into the script:

^ /etc/apache2/ssl/password.sh ^
| #!/bin/bash |
| echo ‘password’; |

Change the password to something better. For example: idon7kn0w or ugh1d0ntl1kepassw0rd5

In you Apache config files edit where the SSLPassPhraseDialog is at and add exec:/etc/apache/ssl/password.sh

^ /etc/apache2/modules.d/40_mod_ssl.conf ^
| exec:/etc/apache/ssl/password.sh |
| |


SSLPassPhraseDialog exec:/etc/apache2/ssl/password.sh

Now the needs to be executable:

chmod a+x /etc/apache2/ssl/password.sh

If the SSLPassPhraseDialog does not work, Then you will need to generate and key and cert that will not prompt for a password. To do that enter the fallowing commands and copy the key into your apache ssl folder.


openssl rsa -in newca.key -out newca.key.insecure
mv newca.key newca.key.secure
mv newca.key.insecure newca.key

Source: http://www.tc.umn.edu/~brams006/selfsign.html

Journal Entry – 07092016

Journal Entry – 07092016

I have now replace dokuwiki with wordpress, and so far I am happier with wordpress than with dokuwiki. I feel that it makes it easier for me to focus on what matters more than spending time trying to fiddle with a bunch of stuff and not really accomplishing alot. Ansible is coming along slowly and I will update my progress on the Ansible post. I have already started thinking about moving my mail system from postfix/devcot -> postfix/dbmail.

On the cello front, I found a new youtube channel Sarah Joy Music Tutorials/Music Videos some of the tutorials she posts very helpful to me. For example, the stretching exercise she has posted on her site or Five practicing mistakes. On Suzuki Book #2 Minuet #3 I have been practicing that for two months now, and I feels like I am getting better with it. It definitely a challenging piece along with the pieces that my teacher, Mr. Ma, has me working on as well. But, I feel good about. Although, I am thinking of posting some of my playing on youtube and sharing with my friends!

I met with my Jessica this week for our session. Most of the time during our session we talk about my journal and what does it mean to me, what is the goal of it, and what do I expect to get out of it. The goal is to understand why do I overreact to curtain issues, to help me understand about it and how to deal with it, and what I want to get out of it to be a better person. We have mention that we may need to change the focus from Relationship coach to psychotherapy. I felt that at first I did not need it, that I am ok without it. But, now thinking about, I guess maybe I should venture into it deeper to see if I can have a healthier relationship with my self. In addition, try to deal or come to terms with the unstructured parts of my life or events in my life. I guess time will only tell to see how this will work out for me.

So, Cassie and I decided to expand our family and now where adopting a cat. Her name is potato.

Female Siamese Brown 2 years old
Female, Siamese, Brown, 2 years old

I am still a little apprehensive about potato, but excited to adapt! I have talk to my friends about adopting a cat they give me a few advice here and there. More news to come!

I got play Magic night with Ian, Adrian, and Jim! It was a great time playing with them, although I have to admit, I was getting murdered in the game as I could not keep a creature in play for more than two turns. But, in the end, it really did not matter if I win or lose, spending time with my friends or my girlfriend Cassie means a lot more! I also, schedule a romantic evening with Cassie on the 15th of this month at the McCormick and Schmicks restaurant in San Jose. I’m excited about it and it’s been a long time since we have one.

Working with sqlite in Python

Working with sqlite in Python

#!/bin/python

import datetime
import timedelta
import os.path
import sqlite3
import sys

#Global Variables
DBPath='test.db'

#from datetime import datetime, timedelta
#then = datetime.now() - timedelta(hours = 2)
#now = datetime.now()
#(now - then) > timedelta(days = 1)
#False
#>>> (now - then) > timedelta(hours = 1)
#True

StuffToLoad = [
	(0 , 'example.domain.com'  , 'Maintenance' ,'2014-08-10 15:07:15.067766'),
	(1 , 'example2.doman.com'  , 'Maintenance' ,'2014-08-10 15:07:15.067766'),
	(2 , 'exmaple3.domain.com' , 'Maintenance' ,'2014-08-10 15:07:15.067766'),
]

def CreateDB():
	print "Creating Database....."
	conn = sqlite3.connect(DBPath)
	conn.execute('''CREATE TABLE MInMant (ID INT PRIMARY KEY NOT NULL, Machine TEXT NOT NULL, HostState INT NOT NULL, date CHAR(50))''')
	conn.commit()
	conn.close()

def InsertDB(x):
	conn = sqlite3.connect(DBPath)
	c = conn.cursor()
	t = ('Maintenance',)
	c.execute('SELECT * FROM MInMant WHERE HostState=?', t)
	c.executemany('INSERT INTO MInMant VALUES (?,?,?,?)', StuffToLoad)
	conn.commit()
	conn.close()

def PrintDBContents():
	print "DEBUG PrintDB Contents"
	conn = sqlite3.connect(DBPath)
	c = conn.cursor()
	for row in c.execute('SELECT * FROM MInMant'):
	        print(row)

#We start out program
#if os.path.isfile(DBPath) == 'True':
CreateDB()

#Load data into our DB
InsertDB(StuffToLoad)

#Print data from our DB
PrintDBContents()
Linux tib bits…

Linux tib bits…

[toc]

Linux Networking Devices

Udev naming

There a few network gotchas when adding a new network card or copying VMs. The issue starts when an existing the name of the network adapter changes (e.g., from eth0 to eth1) network adapter’s MAC address changes because a configuration script in linux associates the name of the network adapter with its MAC address. It can be disabled:

Disable udev persistent net generation

echo -n > /etc/udev/rules.d/70-persistent-net.rules
echo -n > /lib/udev/rules.d/75-persistent-net-generator.rules

# disable udev persistent net generation

echo -n > /etc/udev/rules.d/70-persistent-net.rules
echo -n > /etc/udev/rules.d/75-persistent-net-generator.rules

Systemd naming

With systemd, network devices are named differently(ie. enp0s0 or wlp2s0). Although this provides a more consistence naming convention with network adapters in linux, in some cases, The old style naming is sometimes needed for environments or scripts. To fix that, In grub:

Change:

title Gentoo Linux 4.4.1
root (hd0,0)
kernel /kernel-genkernel-x86_64-4.4.9-gentoo root=ZFS dozfs init=/usr/lib/systemd/systemd
initrd /initramfs-genkernel-x86_64-4.4.9-gentoo

To:

title Gentoo Linux 4.4.1
root (hd0,0)
kernel /kernel-genkernel-x86_64-4.4.9-gentoo root=ZFS dozfs init=/usr/lib/systemd/systemd net.ifnames=0
initrd /initramfs-genkernel-x86_64-4.4.9-gentoo

Magic SysReq

I have gotten into situations where the subsystems or subproccesses on a running system maybe not be performing as expected. If you ever need to reboot the host and its not connected to an pdu magic SysReq is the next best options.

You can activate it by:


echo 1 > /proc/sys/kernel/sysrq

If you need to reboot the host:

echo b > /proc/sysrq-trigger

Note: This will cause the kernel to send an instruction to the cpu to reset and it will not show down any processes cleanly and the same goes to the filesystem. USE WITH CAUTION!

To make it permanently turn on:

echo “kernel.sysrq = 1” » /etc/sysctl.conf

More infromation can be found: If you would like to learn more about magic SysRq you can read the sysrq.txt file in the kernel documentation. http://www.mjmwired.net/kernel/Documentation/sysrq.txt

Simple useful Python Function

Simple useful Python Function

These are functions that I have been useful and flexible to me.

import sys
import subprocess
import string
import socket
import re
import syslog
import smtplib
import os
import sys, getopt
from optparse import OptionParser

# Function that does basic standard output
def message(message):
    sys.stdout.write(message)
    sys.stdout.flush()

#Get command line options then return the variables to be used in other parts of the script.
def CliOptions():
    """
    Setup command-line parsing options
    """
    parser = OptionParser()
    parser.add_option('-o', '--output', default = '',    dest = 'output', help = 'Where to output the file to.')
    parser.add_option('-i', '--input',  default = '',    dest = 'input',  help = 'The Input file.')
    parser.add_option('--TrueOrFalse',	default = False, dest = 'TOF', help = 'True or false value.')
    return parser.parse_args()

#Take the contents of data and write it in a file.
def WriteFile(outputFile, outputInformation): 
    fileHandle = open(outputFile + ".out", "w")
    fileHandle.write(outputInformation)
    fileHandle.close()
 
#Read a file and remove newline and return charaters. Then return the data back.
def readFileFunction(inputFile):
    InputFromFile = []
    with open(inputFile, "r") as ins:
        for inputFileLineItem in ins:
            InputFromFile.append(line.rstrip('\r\n'))
    ins.close()
    return InputFromFile

#Have it output to syslog
def MsgLogging(msg):
	syslog.syslog(syslog.LOG_INFO, msg)

#This function calls shell commands. Clean the output but removing the any newline and return charaters using lambda.
def ExternalCommands(command):
    p1 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    results = p1.stdout.readlines()

    resultsFromPopen = map(lambda s: s.rstrip('\r\n'), results)
    return resultsFromPopen

How to use the above functions:


#The messaging function:
message ("Hello World\n")

#For the CliOptions function, The function gets called, it getting the commandline arguments. The function will return data into an array.
(options,args) = CliOptions()

#For the msgLogging
MsgLogging("Hello World")

#For ExternalCommands
results = ExternalCommands("ls /")

#For readFileFunction
results = readFileFunction(pathToFile)

#For WriteFile
WriteFile("/tmp/test.txt", "Hello World")
Journal Entry – 07022016

Journal Entry – 07022016

This week quite busy and it even bleed into the weekend. A couple of weeks ago, I installed a Velcro script with a rubber band underneath and strips of paper to help me with my bow hold and finger positioning on my cello. I have gotten used to having those things. I think for the Velcro I will keep it on the bow, but the strips of paper, I am thinking of removing it in the next few weeks to make me depend on my ears as I have been noticing that I have being depend on touch. I have happy that my playing has improved and reading sheet music with out the numbers has been becoming easier for me. Although, since next week is the start of my vacation and really practice playing my cello!

Cassie and I have been busy though this week, but we are able to spend time at night together and even talk about work, me finding a new job, or events that are happening in our lives. This weekend, I was hopping that she would come with me to play Magic The Gathering with Jim and Adrian, but she was not able to as she had to work. Although it was great see Kert and Kristy again! Cassie and I went to a BBQ with my friends in San Jose. It seems like my friends and Cassie got along well and we had a lot of fun! We all talked, ate, and laugh together!

Roopa’s BBQ Party

My project for this site is really coming together now, expectantly with wordpress. Ansible automation for the base configuration is coming along, and services are moving to a much better place. The articles on wordpress are coming together as well, and I will replace dokuwiki with wordpress. I feel a lot better using wordpress than dokuwiki as it never really satisfied my needs as wordpress does. I guess to some extent I am abie to personize it and make it more of my own that what I did with dokuwiki.

%d bloggers like this: