Posted: May 17th, 2012 | Author: matt | Filed under: Linux, programming, script-fu | 1 Comment »
I recently needed to trim the last N characters from a string in shell. I wrote this little function to handle the task.
This requires a newer distro that has updated coreutils that includes the ‘fold’ command (Feb 2010).
#!/bin/bash
function trimChars() {
if [ $2 ]; then
TRIM_LAST=$2
elif ! [ $2 ]; then
TRIM_LAST=4
fi
if [ $1 ]; then
STRING="$1"
elif ! [ $1 ]; then
STRING="FooBar.xls"
fi
NEW_STRING=""
STRING_ARRAY=(`echo ${STRING} | fold -w1`)
NEW_STRLEN=$[ ${#STRING_ARRAY[*]} - ${TRIM_LAST} ]
for((i=0;i<${NEW_STRLEN};i++)); do
NEW_STRING="${NEW_STRING}${STRING_ARRAY[$i]}"
done
printf "String in:\t %s\nString out:\t%s\n" ${STRING} ${NEW_STRING}
}
Posted: May 4th, 2012 | Author: matt | Filed under: programming, python | Tags: python | 1 Comment »
stumbled across the FizzBuzz quest thanks to fellow dad Jeff Atwood.
I spent about 8 minutes on this mainly because I always forget / vs %, and iteration through if blocks. Here is my fizzbuzz in Python.
for i in range(0,100):
j = i % 3
k = i % 5
if j == 0 and k == 0:
print 'FizzBuzz'
elif k == 0:
print 'Fizz'
elif j == 0:
print 'Buzz'
else:
print i
Posted: February 14th, 2012 | Author: matt | Filed under: Uncategorized | Comments Off
my SSL cert expired with godaddy and my “wonderful” VPS hosting provider knocked my vm offline, again. the joys of cheap hosting.
Posted: December 26th, 2011 | Author: matt | Filed under: Uncategorized | Tags: registrar godaddy namecheap | Comments Off
What is “it”? switching from GoDaddy.com to Namecheap for domain registration. I refuse to support a business that WANTS to oppress the internet and its users, consumers, and creators.
fuck you, Godaddy, and your elephant hunting (ex-)CEO.
Posted: November 18th, 2011 | Author: matt | Filed under: inspiration, Links | Tags: life, Links, stress, work | Comments Off
http://tinybuddha.com/blog/6-tips-work-life-balance-for-people-with-big-dreams-2/
Posted: November 3rd, 2011 | Author: matt | Filed under: OSX | Tags: OSX Java | Comments Off
I had to google this myself but am posting here in case the few people reading this blog might use it.
One interesting thing I didn’t realize is that Apple includes a bunch of the older JDKs for backwards compatibility I guess.
me@mylaptop$ ls /System/Library/Frameworks/JavaVM.framework/Versions/
1.3/ 1.4/ 1.5/ 1.6/ A/ CurrentJDK/
1.3.1/ 1.4.2/ 1.5.0/ 1.6.0/ Current/
And here is how you set your $JAVA_HOME environment variable in BASH.
me@mylaptop$ export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/
And here is how you do that in t/csh shell
[me@mylaptop:~] msnow% setenv JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
[me@mylaptop:~] msnow% echo $JAVA_HOME
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
Posted: October 11th, 2011 | Author: matt | Filed under: sysadmin | Tags: DevOps | Comments Off
going to try and start attending the SF Bay Area Large Scale Production Engineering meetup. we’ll see how things go.
Posted: October 9th, 2011 | Author: matt | Filed under: inspiration | Tags: Apple, quotes, steve jobs | Comments Off
Like the rest of the world I am deeply saddened by the loss of life that was Steve Jobs. While not a shock considering his health issues, it is very sad for many reasons that hit close to home for me. He has children and wife that are still alive, without a father.
I never met him or even saw him in person. I only read about him and watched interviews, keynotes, and speeches he gave. He was a very captivating speaker and seemed to know how to motivate people.
You will be missed by more than just us fanboys.
Here are a few links to neat tributes, quotes, and thoughts on Steve’s life, work and philosophy.
The Wall Street Journal – Steve Jobs Quotes
Guy Kawasaki – What I learned from Steve Jobs
Steve Jobs – Bashes Teachers Unions
Milo Yiannopoulos – Steve Jobs, the greatest conservative icon of our time
Steve Wozniak on remembering Steve.
How Apple got everything right by doing everything wrong. (old wired article from 2008)
Dalla Rosa – Steve Jobs.
The Atlantic – Steve Jobs 1955-2011
The list of web pages created in the last several days is endless. This is just another one that doesn’t mean much to anyone, but is a way for me to place my thoughts.
my favorite Steve Jobs quote comes from his 2005 Stanford commencement speech.
“…Death is very likely the single best invention of Life. It is Life’s change agent. It clears out the old to make way for the new. Right now the new is you, but someday not too long from now, you will gradually become the old and be cleared away. Sorry to be so dramatic, but it is quite true.
“Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma — which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.”
These words may be morbid to some, but are so true. So many people (myself included) are afraid to follow their dreams for some reason or another. if we can learn anything from this man let it be to not be fearful, and to live life.
And a final quote from one of our founding presidents, Abraham Lincoln.
“…And in the end, it’s not the years in your life that count. It’s the life in your years.”
Posted: September 27th, 2011 | Author: matt | Filed under: Uncategorized | Comments Off
After a long outage that started out initially by my hosting provider, we are back online.
We are patched up to the latest Ubuntu 10.x, and now running on the latest Nginx instead of the RAM hog, Apache.
CrashPlan and my crappy VPS are what triggered me to switch to nginx. Crashplan is written in Java. Java is a big fat RAM hog and my VPS only gives me 1GB. ouch 2001 called and wants its small amounts of RAM back.
Posted: June 3rd, 2011 | Author: matt | Filed under: Linux, sysadmin | Tags: Dell, Linux, RAID | 1 Comment »
it took me a few google searches to find it but I eventually found what I was looking over at ServerFault.Com.
Unfortunately the Dell OMSA Linux package only includes the .so libraries needed to query the LSI MegaSAS controller (aka, Dell H700) but no MegaCli binary. boooo.
Lucky for me, and everyone else LSI provides a download for it here.
If you’re a fellow sysAdmin and have not checked out ServerFault.com or the network of other Q&A sites like StackOverFlow.Com, head on over to http://stackexchange.com/sites.