Posted 1 year ago

Upload files to Cloud Files Rackspace

#!/bin/sh

##########################################

## Upload File to CloudFiles RackSpace   ##

## Ver 0.1                               ##

## inong@code18.us                       ##

## 10 February 2012                     ##

##########################################

##

## 20120210 : - Initial scripts

##

##

## Configuration

# Date format

TODAY=`date ‘+%Y-%m-%d’`

YESTERDAY=`date —date=”yesterday” +%Y%m%d`

YEAR=`date ‘+%Y’`

# Direktori dimana script ini disimpan

BASEDIR=”/home/app/scripts/upload”

TEMPDIR=”$BASEDIR/temp”

# File-file log dan konfigurasi

COLLECTOR_LOG=”/home/app/logs/collector”

LOCK_FILE=”$BASEDIR/logs/lock_upload”

# User and API-Key Rackspace

URLAPI=”https://auth.api.rackspacecloud.com/v1.0”

USER=”[USERNAME]”

APIKEY=”[API_KEY]”

DIR_LOG=”[DIR_LOG]”

## Scripts

cd $BASEDIR

#—Cek lock file, kalau tidak ada buat dan jalankan script, kalau tidak ada mati—#

PROC=$(cat $LOCK_FILE)

if [ “$PROC” != “” ]; then

   exit 1

fi

echo “running” > $LOCK_FILE

#—Proses Upload File Collector to CloudFiles Rackspace—#

FILE_BOT=”collector”

tar zcvf $TEMPDIR/$FILE_BOT-$YESTERDAY.log.tar.gz $COLLECTOR_LOG-$YESTERDAY.log

function execution() {

    grab_auth_token

    upload_file

}

function grab_auth_token() {

    curl -D - -H “X-Auth-User: $USER” -H “X-Auth-Key: $APIKEY” $URLAPI 2>&1

    STORAGETOKEN=`curl -D - -H “X-Auth-User: $USER” -H “X-Auth-Key: $APIKEY” $URLAPI 2>&1 | grep Storage-Token |  awk ‘{print $2}’ | tr -d ‘\r’`

    STORAGEURL=`curl -D - -H “X-Auth-User: $USER” -H “X-Auth-Key: $APIKEY” $URLAPI 2>&1 | grep Storage-Url | awk ‘{print $2}’ | tr -d ‘\r’`

}

function upload_file() {

    cd $TEMPDIR

    ETAG=$(md5sum $FILE_BOT-$YESTERDAY.log.tar.gz | awk ‘{print $1}’)

    CONT_TYPE=$(file -bi $FILE_BOT-$YESTERDAY.log.tar.gz)

    curl -X PUT -T $FILE_BOT-$YESTERDAY.log.tar.gz -D - -H “ETag: $ETAG” -H “Content-Type: $CONT_TYPE” -H “X-Auth-Token: $STORAGETOKEN” $STORAGEURL/$DIR_LOG/$FILE_BOT-$YESTERDAY.log.tar.gz

}

execution

#—End Proses Upload File Collector to CloudFiles Rackspace—#

##—Proses selesai, hapus status lock—##

cat /dev/null > $LOCK_FILE

Posted 1 year ago

Icon Ambulance

One Sunday morning, January 6th, 2008 I was attending religious services when my cell phone vibrated. As discreetly as possible, I checked the phone and noticed that my phone said “Caller ID unknown”. I choose to ignore.

After services, as I was walking to my car with my family, I checked my cell phone messages. The message left was from Steve Jobs. “Vic, can you call me at home? I have something urgent to discuss” it said. 

Before I even reached my car, I called Steve Jobs back. I was responsible for all mobile applications at Google, and in that role, had regular dealings with Steve. It was one of the perks of the job. 

“Hey Steve - this is Vic”, I said. “I’m sorry I didn’t answer your call earlier. I was in religious services, and the caller ID said unknown, so I didn’t pick up”. 

Steve laughed. He said, “Vic, unless the Caller ID said ‘GOD’, you should never pick up during services”. 

I laughed nervously. After all, while it was customary for Steve to call during the week upset about something, it was unusual for him to call me on Sunday and ask me to call his home. I wondered what was so important?

“So Vic, we have an urgent issue, one that I need addressed right away. I’ve already assigned someone from my team to help you, and I hope you can fix this tomorrow” said Steve. 

“I’ve been looking at the Google logo on the iPhone and I’m not happy with the icon. The second O in Google doesn’t have the right yellow gradient. It’s just wrong and I’m going to have Greg fix it tomorrow. Is that okay with you?”

Of course this was okay with me. A few minutes later on that Sunday I received an email from Steve with the subject “Icon Ambulance”. The email directed me to work with Greg Christie to fix the icon. 

Since I was 11 years old and fell in love with an Apple II, I have dozens of stories to tell about Apple products. They have been a part of my life for decades. Even when I worked for 15 years for Bill Gates at Microsoft, I had a huge admiration for Steve and what Apple had produced. 

But in the end, when I think about leadership, passion and attention to detail, I think back to the call I received from Steve Jobs on a Sunday morning in January. It was a lesson I’ll never forget. CEOs should care about details. Even shades of yellow. On a Sunday.

To one of the greatest leaders I’ve ever met, my prayers and hopes are with you Steve.

-Vic

Taken from Vic Gundotra google+ (SVP of Social Business for Google)

Posted 1 year ago

Iseng belajar photo lagi dan oldig tema lomo vintage.

Posted 1 year ago

traffic yang brutal… LOL

Posted 1 year ago

How to check your tables size in MySQL

SELECT table_schema, table_name, table_rows, data_length/1024/1024 AS data_MB, index_length/1024/1024 AS index_MB FROM information_schema.tables WHERE engine LIKE ‘InnoDB’ order by data_length desc;

Posted 2 years ago

Simple Multithread with Bash Script

#!/bin/sh

PROC_ID=1

THREADS=5

X=1

while :

do

    function APPS () {

       A=$1

       echo “Thread $PROC_ID - Generate Number = $A” && sleep 0.5

    }

    if [ ! “$PROC_ID” -eq “$THREADS” ] ; then

       APPS $X &

       let PROC_ID=PROC_ID+1

    else

       wait

       PROC_ID=1

    fi

    X=$(( X+1 ))

done

wait

Posted 2 years ago

Recipe For Handling Rapid Growth
while (true)
{
identify_and_fix_bottlenecks();
drink();
sleep();
notice_new_bottleneck();
}

This loop runs many times a day.

Posted 2 years ago

Yuk, jajal kekuatan Processor PC/Laptop loe…. Di mac gw sempet bikin lag, hehehee :D

Oh ya… aplikasi “bc” di windows ada koq.

$ bc -l -q

scale = 10000;

4*(12*a(1/49) + 32*a(1/57) - 5*a(1/239) + 12*a(1/110443))

Posted 2 years ago

MySQL Memory Usage

Berapa sih memory yang dipake sama mysql loe ? Ini jawabannya…. 

——————————————————————————————————

#!/bin/sh

total=0;

user=mysql

for mem in `ps -u $user -o pid,rss,command | grep -v COMMAND | awk ‘{print$2}’`;

    do let total+=$mem;

done;

echo $(($total/1024))MB

Posted 2 years ago

Nunggu yang mahal..