Archive

Author Archive

Setting TimeZone Linux Ubuntu

February 24th, 2011
cd /usr/share/zoneinfo

#remove the current localtime sym link (if its wrong, if it were correct, you would not be looking for this blog)
sudo rm localtime

#Create the new symlink to the new timezone I am in the NYC timezone...so
sudo ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime

Greg Uncategorized

Linux Kill All Processes By Name

February 11th, 2011

Had a server with a bunch of hanging perl processes, and wanted to kill them all in one shot.

Solution:

kill -9 `pgrep perl`

Greg How-To, Linux, Perl ,

MYSQL Import -–Force Not working when importing a mysqldump

February 9th, 2011

This was a frustrating problem, because I had a a view and a routine in my dump that were using a function that had not been created by the dump as of yet. The –force command was not working for me…..

The Solution:

mysql -f -t -vvv -h localhost -u root -p < importfile.sql

Dump and Import one Liner (put all on one line)

mysqldump -h remote.host.com -u username  -pPassword --lock-tables=false 
--routines=true MyDatabase | mysql -f -t -vvv -h localhost -u username2 –pPassword2 
--force MyDatabase

Greg MySQL, SQL Server Stuff

STEELERS 24 J-E-T-S 19

January 24th, 2011

Merging Identical MYSQL Tables on New Database

January 24th, 2011

I needed to take identical tables on 3 databases, and merge it onto a new table on a new database. Clearly the reason for the task was consolidation. My biggest complaint about mysql is its lack of linked servers. You can do federated, but lets be honest….It’s a pain in the %$#^

So when it comes to consolidating, the best way (at least in my situation) was to manually merge the data. I thought of a few ways this could be done, but here is how I ended up doing it.

1) DUMP DATA to a File.

select broker_description,date,type,
       case when type = "O" then abs(Shares*100)
       else abs(Shares) end as Quantity,
       commission,'someportfolio' as portfolio
from accounting.trades r
join tickers t
on t.id = r.ticker
join exec_broker b
on b.id = r.exec_broker
where abs(commission > 0)
INTO OUTFILE "/tmp/dump.txt"

 

2) SCP the dump file from server1 to server2 (server where merge table will be)

scp /tmp/dump.txt root@10.1.10.20:/tmp/

 

3) IMPORT DATA (this assumes you scp’d the file to /tmp/ on the merge table server)

LOAD DATA  INFILE '/tmp/dump.txt'
INTO TABLE commission
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
(broker_description, date, type,Quantity,commission,portfolio);

 

NOT NECESSARY FROM HERE DOWN>>>>>THIS WAS AN EXTRA STEP

4) Dump server3 table data to file

In this case I actually needed to dump data from a mysql database that was on a Windows Server. Similar to step 1.

select broker_description,date,type,
       case when type = "O" then abs(Shares*100)
       else abs(Shares) end as Quantity,
       commission,'portfolio2' as portfolio
from accounting.trades r
join tickers t
on t.id = r.ticker
join exec_broker b
on b.id = r.exec_broker
where abs(commission > 0)
INTO OUTFILE "c:/temp/dump.txt"

 

5) I used WinSCP to upload the file from c:\temp to /tmp on target server

Greg MySQL

Install OpenSSH on Windows 7

January 14th, 2011

Net Net….this is a short version…but to the point. Its pretty simple.

Installing OpenSSH on windows 7

1) Download and install Cygwin
a. Be sure to choose openssh as one of the packages that gets installed.
2) Once setup is complete. Right Click Cygwin Icon on desktop and “Run as Administrator”
3) execute “ssh-host-config” from the command line and anwser basic questions
4) mkpasswd -cl > /etc/passwd
5) mkgroup –local > /etc/group
6) net start sshd

Greg How-To , ,

MYSQLDUMP and Import over SSH OneLiner

December 18th, 2010

So you want to Import a mysql database from Server A to Server B over ssh? Easy!

1) Setup SSH to login automatically from Server A to Server B

On server A

Create a private and public key.

     ssh-keygen -t rsa
     cat id_rsa.pub | ssh user@ServerB ‘cat >> ~/.ssh/authorized_keys’

Test that login works automatically

ssh user@ServerB

Still from Server A “MYSQLDUMP One Liner”
ssh user@ServerB ‘mysqldump –u mysqlUser -pMyPassword –lock-tables=false yourdatabase’ | mysql -h localhost -u greg –pYourOtherPassword yourImportDatabae

Greg Uncategorized

Dear Grandpa,

December 4th, 2010

I usually hate all of the political junk mail that circulates through my inbox. Many times, I find the data points being used inaccurate, and it bothers the heck out of me, that people read the stuff and take it as gospel, without knowing the truth. However, this one hit closer to home for me. As a recent small business owner, I pay much closer attention to my taxes than I did when I was straight W2. And trust me, when you are paying lump sums out of pocket on a quarterly basis, it feels alot different than it did when it was skimmed off my bi-weekly paycheck.

Anyway, I enjoyed reading this…I hope you will too. Even if the truth hurts you.

See below…

 

John G. Is 63 years old and owns a small business.  He’s a life-long Republican and sees that his dream of retiring next year has all but evaporated.  With the stock market crashing and new taxes coming his way, John now assumes that he will work to his dying day.

John has a granddaughter.  Ashley is a recent college grad.  She drives a flashy hybrid car, wears all the latest fashions, and loves to go out to nightclubs and restaurants.  Ashley campaigned hard for Barack Obama.  After the election she made sure her grandfather (and all other Republican family members) received a big I told-you-so earful on how the world is going to be a much better place now that Obama and her party is taking over.

Having lost both roommates, Ashley recently ran short of cash and cannot pay the rent (again) on her 3-bedroom townhouse.  As she had done many times in the past, she e-mailed her grandfather asking for some financial help.

Here is his reply…

Sweetheart, I received your request for assistance.  Ashley, you know I love you dearly and I ‘m sympathetic to your financial plight.  Unfortunately, times have changed.  With the election of President Obama, your grandmother and I have had to set forth a bold new economic plan of our own…"The Ashley Economic Empowerment Plan."  Let me explain.

Your grandmother and I are life-long, wage-earning tax payers.  We have lived a comfortable life, as you know, but we have never had the fancier things like European vacations, luxury cars, etc.  We have worked hard and were looking forward to retiring soon.  But the plan has changed.  Your president is raising our personal and business taxes significantly.  He says it is so he can give our hard-earned money to other people.  Do you know what this means, Ashley?  It means less for us, and we must cut back on many business and personal expenses.
You know the wonderful receptionist who worked in my office for more than 23 years?  The one who always gave you candy when you came over to visit?  I had to let her go last week.  I can’t afford to pay her salary and all of the government-mandated taxes that go with having employees.  Your grandmother will now work 4 days a week to answer phones, take orders and handle the books.  We will be closed on Fridays and will lose even more income to the new Wal-Mart store that recently opened.
I’m also very sorry to report that your cousin Frank will no longer be working summers in the warehouse.  I called him at school this morning.  He already knows about it and he’s upset because he will have to give up skydiving and his yearly trip to Greenland to survey the polar bears.
That’s just the business side of things.  Some personal economic effects of Obama’s new taxation policies include none other than you.  You know very well that over the years your grandmother and I have given you thousands of dollars in cash, tuition assistance, food, housing, clothing, gifts, etc., etc. But, by your vote, you have chosen to help others — not at your expense — but at our expense.
If you need money now, sweetheart, I recommend you call 202-456-1111.  That is the direct phone number for the White House.  You can also contact the White House here:
http://www.whitehouse.gov/CONTACT/.
You yourself told me how foolish it is to vote Republican.  You said Mr. Obama is going to be the People’s President, and is going to help every American live a better life.  Based on everything you’ve told me, along with all the promises we heard during the campaign, I’m sure Mr. Obama will be happy to transfer some stimulus money into your bank account.  Have him call me for the account number, which I memorized years ago…
Perhaps you can now understand what I’ve been saying all my life:  Those who vote for a president should consider the impact on the nation as a whole, and not be just concerned with what they can get for themselves.  What Obama supporters don’t seem to realize is all of the money he is redistributing to illegal aliens and non-taxpaying Americans (the so-called "less fortunate") comes from tax-paying families. 
Remember how you told me, "Only the richest of the rich will be affected"?  Well, guess what, honey? Because we own a business, your grandmother and I are now considered to be the richest of the rich. On paper, it might look that way, but in the real world, we are far from it.
As you said while campaigning for Obama, some people will have to carry more of the burden so all of America can prosper.  You understand what that means, right?  It means that raising taxes on productive people results in their having less money; less money for everything, including granddaughters.
I’m sorry, Ashley, but the well has run dry…  The free lunches are over…  I have no money to give you now.  So, congratulations on your choice for "change”.  For future reference, I encourage you to try and add up the total value of the gifts and cash you have received from us, just since you went off to college, and compare it to what you expect to get from Mr. Obama over the next 4 (or 8) years. I have not kept track of it, Ashley.  It has all truly been the gift of our hearts.
Remember, we love you dearly… but from now on you’ll need to call the number mentioned above.  Your "Savior" has the money we would have given to you.  Just try to get it from him.
Good luck, sweetheart.
Love,
Grandpa

Greg Uncategorized

Cutting through “Red Tape” with Free software and API from TODOIST

October 17th, 2010

One client I was working with in the past wanted a weekly update and priority list of work that was completed in the last week, and what was on my plate for the coming week. Being someone that just can’t deal with red tape, I thought immediately, How am I going to automate this?

I began my search for a simple, easy to use Task Manager. The criteria were as follows.

1) Easy to add/remove/manage tasks.

2) UI when mobile. I have a blackberry, so just an Iphone App won’t do. although todist has one. Along with a chrome plugin…which needs some work, but is pretty good.

3) Easy to manage multiple Projects

4) Free

5) Has an API

First stop Lifehacker, and came across this post http://goo.gl/QJYr

 

After messing with todoist, I was impressed. The UI was so clean and simple. I love that.

Here is how my code works….

1. [Client A] is setup as a project.

2. I add tasks and check them off.

3. Then Sunday morning,

     a. my script looks up everything that was completed since last monday and puts it in the last week category.

     b. takes all uncompleted tasks and set them as next week priorities.

     c. I get an email that looks like:

WEEK PRIORITIES
* Post on Twitter
* Email Clients
* Order a new computer

LAST WEEK
* Did some good work
* Installed SoftwareUI
* Configured Router
* Created Stock Alert System

Very simple but cutting through red tape with technology.

Greg Uncategorized

svnsync: Can’t open ‘C:\DOCUME~1 Error

May 28th, 2009

I had this very annoying error the other day when trying to sync my repositories. The answer was so simple, but took me forever to figure out, as some files would sync and some would fail.

The answer….

Turn off your Virus Protection! That’s it! :)

Hope it helps you out.

Greg Uncategorized