You are viewing jackal

Agnus Dei's Journal

> recent entries
> calendar
> friends
> profile
> previous 20 entries

Wednesday, May 15th, 2013
3:31 am - Standard Google Interview Questions with Answers
If you ever have to interview with Google, here are the questions they will ask you, and here are the answers. They've been asking the same questions for 10+ years now.

Which system call returns inode information?
its the stat() system call.

What signal does the "kill" command send by default ?
TERM (15) signal by default

How many IP addresses are usable on a /23 network?
510 host addresses.

Can you describe a connection setup in TCP
3way handshake: the syn, syn+ack, ack

(comment on this)

12:35 am - REVIEW OF NEVERWINTER
REVIEW OF NEVERWINTER

It's hard to critique a game that's both "free to download" and "free to play", BUT... I have to say, I'm not very impressed by NeverWinter. Coming off having played Guild Wars 2 it's hard not to see NeverWinter as a huge let down.

First off the graphics. The graphics in Guild Wars 2 were so beyond beautiful. I would often comment to Scott during a game, "Man the graphics in this game are beautiful." because it's true. It was stunning. Meanwhile over in Neverwinter... not so great.

Then the game play, I found the controls for NeverWinter very hard to get used to. I play on a laptop with a trackpad and no mouse. So NeverWinter was impossible for me to play. I had to get a Xbox360 controller for this and even still it was hard to get used to the controls. GW2 was simple, and easy to control and easy to target (a tab targetting system).

Thirdly, everything about Guild Wars 2 was so polished. Everything. It was a grind sure, but a very polished grind. NeverWinter feels unfinished (yes - I know it's in Open Beta, but still... it's far from polished.) And then the graphics of the inventory items. Man those are bad. You can't see what anything is.

I'm let down. I'll play, but disappointed. Comparing it to Guild Wars 2 - there's really no comparison. GW2 blows Neverwinter out of the water.

(comment on this)

Sunday, May 5th, 2013
8:37 pm - Continuity Errors and Plot Holes in Iron Man 3
Here are a list of plot holes and continuity errors I was able to come up with for Iron Man 3 while sitting at a stop light.

1- The car: When Iron Man comes cracking down to Earth in Tennessee he barely missed a car WHICH GOES CRASHING OFF THE ROAD. Uhm - A car crash like that would have caused a police report and of course news media around a flying metal man falling from the sky. Yet - no mention of it after we see the car crash off the road.

2- The kid: When the kid first sees Tony Stark he informs him that he's dead according to the news paper that identifies him on the cover. Yet - 5 minutes later the kid asks Tony for his name and Tony says "The Mechanic." But the kid knew who he was because again, he identified him from the cover of the news paper. HUGE - plot hole/continuity error.

3- The hand cuffs: At the bar, the agent hand cuffs Tony behind his back. When Tony is outside the handcuffs are behind his back. Yet - magically - when Tony jumps through the glass window and then lands, the handcuffs are mysteriously now in front of him. And he fights the agent with the hand cuffs in front of him. HUGE - continuity error.

4- the hidden wrist blaster: Tony fights the first agent and never once uses the wrist blaster, not once the whole time, even though his life is at risk. Then outside he's about to die and we learn he has a hidden wrist blaster the whole time. Uhm - why didn't he use that on the first one?

5- the walkie talkie: When on the boat, Tony calls the Vice President on the phone. Yet when James Rhodes is shown talking to him on the phone, James is talking into the boats walkie talkie.

(comment on this)

Wednesday, May 1st, 2013
8:30 am - proof that Ruby is evil and should never be used !
On a NORMAL SYSTEM :

ballison@ubuntu:~$ type cd
cd is a shell builtin

SYSTEM WITH RUBY INSTALLED:

[root@pbd /tmp] type cd
cd is a function
cd ()
{
if builtin cd "$@"; then
[[ -n "${rvm_current_rvmrc:-}" && "$*" == "." ]] && rvm_current_rvmrc="" || true;
__rvm_do_with_env_before;
__rvm_project_rvmrc;
__rvm_after_cd;
__rvm_do_with_env_after;
return 0;
else
return $?;
fi
}

So Ruby is doing bad things to the cd command.

(comment on this)

Thursday, April 25th, 2013
11:09 am - my current favorite thing
curl ifconfig.me

(comment on this)

Monday, March 25th, 2013
4:14 pm - How to find hard links linked to a file.
I can't gzip my logs because I've got hidden hard links... here's how to find them.


[root@pod01-ema-01 httpd]# find /var/log/httpd/ -name "*.txt" -type f -mtime +7 -exec gzip {} \;
gzip: /var/log/httpd/ema.md-access_log.2013-03-10.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-access_log.2013-03-03.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-ssl-access_log.2013-03-03.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-error_log.2013-03-09.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-ssl-error_log.2013-03-03.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-error_log.2013-03-03.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-ssl-access_log.2013-03-10.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-ssl-error_log.2013-03-10.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-error_log.2013-03-16.txt has 1 other link  -- unchanged


[root@pod01-ema-01 httpd]# stat /var/log/httpd/ema.md-access_log.2013-03-10.txt
  File: `/var/log/httpd/ema.md-access_log.2013-03-10.txt'
  Size: 70688           Blocks: 152        IO Block: 4096   regular file
Device: ca41h/51777d    Inode: 21393       Links: 2
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-03-25 20:03:28.707043413 +0000
Modify: 2013-03-10 23:59:13.394046125 +0000
Change: 2013-03-11 00:03:40.273046121 +0000


[root@pod01-ema-01 httpd]# ls -i /var/log/httpd/ema.md-access_log.2013-03-10.txt | awk '{print $1}' | xargs find . -inum 
./ema.md-access_log-20130310
./ema.md-access_log.2013-03-10.txt

(comment on this)

9:36 am - how to wget into a specific directory
wget -nc http://s3tools.org/repo/RHEL_6/s3tools.repo -P /etc/yum.repos.d/

(comment on this)

Tuesday, February 26th, 2013
10:12 am - How to convert Apache TimeStamp to MySQL TimeStamp format
# date -d "$(printf '25/Feb/2013:13:56:11\n' | sed -e 's,/,-,g' -e 's,:, ,')" '+%F %T'
2013-02-25 13:56:11

(comment on this)

Monday, February 25th, 2013
3:41 pm - parse_httpd_logs bash script
#!/bin/bash
#
# Usage
# ./parse_httpd_logs type (logfile)
# Eg: 
# parse_httpd_logs url(-summary)
#   will find top URLs in the access log entries
# parse_httpd_logs ip(-summary)
#   will find top IPs in the access log entries
# parse_httpd_logs agent(-summary)
#   will find top user agents in the log entries
# parse_httpd_logs stutus(-summary)
#   will find server status codes in the log entries

if [ $# -eq 0 ] ; then
        echo "Usage: $0 type count (logfile)"
        echo ""
        echo "Example: $0 ip"
        echo "Example: $0 ip-summary"
        echo "Example: $0 url"
        echo "Example: $0 url-summary"
        echo "Example: $0 agent"
        echo "Example: $0 agent-summary "
        echo "Example: $0 status"
        echo "Example: $0 status-epoch "
        echo "Example: $0 status-summary "
        exit
fi


type=$1

if [ "$2" == "" ]; then
  log_file="/var/log/httpd/access_log"
else
  # Sets the log file to be the second argument passed
  log_file="$2"
fi

# decide if it's cat or zcat
EXTENSION=`echo $log_file|rev | cut -d. -f1 | rev`
if [ "$EXTENSION" == "gz" ]; then
        cat_command="/bin/zcat"
else
        cat_command="/bin/cat"
fi


if [ "$type" = "ip" ]; then
  $cat_command $log_file | awk '{print $1}' | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" 
elif [ "$type" = "ip-summary" ]; then
  $cat_command $log_file | awk '{print $1}' | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" | sort -n | uniq -c | sort -rn
elif [ "$type" = "agent" ]; then
  $cat_command $log_file | awk -F\" '{print $6}'
elif [ "$type" = "agent-summary" ]; then
  $cat_command $log_file | awk -F\" '{print $6}'| sort -n | uniq -c | sort -rn
elif [ "$type" = "url" ]; then
  $cat_command $log_file | awk -F\" '{print $2}'
elif [ "$type" = "url-summary" ]; then
  $cat_command $log_file | awk -F\" '{print $2}'| sort -n | uniq -c | sort -rn
elif [ "$type" = "status" ]; then
  $cat_command $log_file | awk -F\" '{print $3}' | awk '{print $1}' 
elif [ "$type" = "status-summary" ]; then
  $cat_command $log_file | awk -F\" '{print $3}' | awk '{print $1}' | sort -n | uniq -c | sort -rn
elif [ "$type" = "status-epoch" ]; then
  $cat_command $log_file | /bin/awk 'BEGIN{
        m=split("Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec",d,"|")
        for(o=1;o<=m;o++){
        date[d[o]]=sprintf("%02d",o)
        }
        }
        {
        gsub(/\[/,"",$4); gsub(":","/",$4); gsub(/\]/,"",$5)
        n=split($4, DATE,"/")
        day=DATE[1]
        mth=DATE[2]
        year=DATE[3]
        hr=DATE[4]
        min=DATE[5]
        sec=DATE[6]
        MKTIME= mktime(year" "date[mth]" "day" "hr" "min" "sec)
        print MKTIME,$9
        }' 

fi


(comment on this)

Wednesday, January 16th, 2013
2:52 pm - using unless to create missing directory
#!/usr/bin/perl

$heap_dump_dir="/nfs/tmp/dumps";

unless(-d $heap_dump_dir){
        print "Creating $heap_dump_dir\n";
        mkdir $heap_dump_dir or die "Can not create $heap_dump_dir\n";
}

(comment on this)

Tuesday, January 15th, 2013
9:09 pm - how to convert a mkv to mpeg4-video on macosx
The following instructions will enable you to convert a .mkv file to a .m4v file WITHOUT re-encoding the file. So it takes seconds to convert the format (instead of hours).
-------------

1- Download the binary for ffmpeg ---> http://ffmpegmac.net/

2- Install the binary somewhere on your computer (I put it in /opt/local/binary_downloads ):

3- To convert the mkv file from the command line, just run this command:

$ /opt/local/binary_downloads/ffmpeg -i sample.mkv -vcodec copy -acodec copy sample.m4v 
ffmpeg version 1.0.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec  7 2012 09:31:51 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --arch=x86_64 --enable-runtime-cpudetect
  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, matroska,webm, from 'sample.mkv':
  Metadata:
    creation_time   : 1970-01-01 00:00:02
  Duration: 00:02:16.85, start: 0.000000, bitrate: 1935 kb/s
    Stream #0:0(eng): Video: h264 (Main), yuv420p, 720x304, SAR 1:1 DAR 45:19, 23.98 fps, 23.98 tbr, 1k tbn, 180k tbc (default)
    Stream #0:1(eng): Audio: aac, 48000 Hz, stereo, s16 (default)
Output #0, ipod, to 'sample.m4v':
  Metadata:
    encoder         : Lavf54.29.104
    Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 720x304 [SAR 1:1 DAR 45:19], q=2-31, 23.98 fps, 1k tbn, 1k tbc (default)
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo (default)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[ipod @ 0x7fc6c18f0e00] st:0 PTS: 67 DTS: -83 < -82 invalid, clipping
frame= 4101 fps=0.0 q=-1.0 Lsize=   32485kB time=00:02:16.84 bitrate=1944.6kbits/s    
video:29531kB audio:2758kB subtitle:0 global headers:0kB muxing overhead 0.603822%


4- I wrote a script to do this:
#!/bin/bash

echo $1
NAME=`echo $1| rev | cut -d. -f2- |rev`
echo $NAME

/opt/local/binary_downloads/ffmpeg -i $NAME.mkv -vcodec copy -acodec copy $NAME.m4v 

(comment on this)

Thursday, November 15th, 2012
12:24 pm - Tools for Debugging WebServer issues
http://coding.smashingmagazine.com/2012/10/29/powerful-command-line-tools-developers/

(comment on this)

Thursday, October 4th, 2012
11:45 am - Recovery a zero length file in xfs by reading raw blocks off the drive
I used this script I wrote to recover 90,000 files that got zero'ed out in length when a XFS/DRBD based file server crashed and mysteriously zero'ed out all the files. Luckily I had the file names that were zero'ed out (recursive find command) and then I passed each file to this script and recovered each file one at a time.

And it worked flawlessly. :)

--------------------------------------------

# cat recover_file.pl
#!/usr/bin/perl
use strict;
use File::Basename;

my $debug=1;
my $inode;
my $output_dir="/recovery";
my $output_file="/tmp/foo.out";
# print "$ARGV[0]";
my $file="$ARGV[0]";
die "Exit - Need an argument/filename" if ($ARGV[0] eq "") ;

### Create the directory to put the recoveried file
my $dirname = dirname($file);
my $basename = basename($file);
print "Filename = $file\n" if ($debug) ;
print "DIRNAME = $dirname\n" if ($debug) ;
print "BASENAME= $basename\n" if ($debug);
my $single_file_recovery_directory="$output_dir/$dirname";
if ( ! -d $single_file_recovery_directory ) {
   print "$single_file_recovery_directory is not a directory\n" if ($debug);
        print "creating $single_file_recovery_directory\n" if ($debug);
        system("/bin/mkdir -p $single_file_recovery_directory");
}
$output_file="$single_file_recovery_directory/$basename";
print "Output file : $output_file\n" if ($debug);


my $dev="/dev/drbd10";
my $inode=`ls -i $file`;
$inode=(split(/ /,$inode))[0];
chomp($inode);
print "inode ='$inode'\n" if ($debug);
die "Exit - need an inode to continue" if ($inode eq "");

my $xfs_db_results=`xfs_db -r $dev -c "inode $inode" -c "bmap"`;
print $xfs_db_results;
die "Exit - xfs_db_results returned no results" if ($xfs_db_results eq "");
#data offset 0 startblock 648428604 (2/111557692) count 299 flag 0

my ($blocks_piece,$count)=(split(/ /,$xfs_db_results))[5,7];
# $blocks_piece =~ s/\//+/;
$blocks_piece =~ s/\(//;
$blocks_piece =~ s/\)//;
my ($blocks_piece_1,$blocks_piece_2)=(split(/\//,$blocks_piece))[0,1];
print "Blocks:$blocks_piece_1,$blocks_piece_2\n" if ($debug) ;
print "Count=$count\n" if ($debug) ;

# Determine the AG size
my $agblocks=`xfs_db -r $dev -c sb -c p | grep ^agblocks | sed 's/.* = //'`;
chomp($agblocks);
# my $agblocks="268435455";  # you can hardcode the value once you know it because it doesn't change
print "AG: $agblocks\n" if ($debug);

my $skip=$agblocks*$blocks_piece_1+$blocks_piece_2;

# Copy the extent in the first file, which consists of 6460 blocks (~26MB)
# in AG 7 starting at AG-relative block 2657536:
# system("dd if=$dev bs=4096 skip=$(($agblocks * 7 + 2657536)) count=6460 of=$output_file");
print "dd if=$dev bs=4096 skip=$skip count=$count of=$output_file\n" if ($debug);
system("dd if=$dev bs=4096 skip=$skip count=$count of=$output_file\n");

(comment on this)

Friday, September 21st, 2012
12:24 pm - How to disable auto commenting in vi / vim
The nextest version of vim has auto-commenting enabled by default. This is horrible and extremely annoying.

Here's how to fix/disable the auto-commenting in vi.

:set formatoptions=
or
:set formatoptions-=cr

(1 comment | comment on this)

Thursday, September 13th, 2012
3:04 pm - random password generator
#!/usr/bin/perl

sub genRandomString {
   my ($max_length) = @_;
   $max_length ||= 10;
   return join('', map { chr(int(rand(26)) + ord('a')) } (1..$max_length));
}

my $foo=genRandomString(8) ;

print "$foo\n";

(2 comments | comment on this)

Saturday, July 14th, 2012
12:13 pm - Letter from my dad
When I was a small kid, I recall standing in the kitchen and on the radio played a Boy George song, and I remember my dad walking through and popping off the comment, "Someone needs to put a bullet in that faggot."

Fast forward to my coming out days, I remember trying to talk to my dad on the porch about me being gay.  I had been disowned and kicked out of the house, but I still tried to talk to him.  I remember him saying to me, "Don't ever even think about bringing your faggot friends around me."

Now fast forward to today.  Some 20 years later.   I got a hand written letter in the mail from my dad that reads:
Hi Son,

Recently, Malinda and I visited her daughter in S.C.  We were invited to attend church, and Malinda had been there before and liked it.

The minister preached a good sermon, and then he went off on gay people and adultery.  We were both insulted and upset with what he said.  Even her daughter said he had never done that before.

I sat there and took it, but I was really agitated as was Malinda.  I didn't even speak to him as we left the church.  As Malinda said, "We'll never go there again."  Her daughter and grand daughter were quite upset also.

Later, I decided to write him a letter and let him know how upset we were.  It will probably be thrown in the trash can, but I couldn't let it pass.

At Malinda's suggestion, I am sending you a copy of the my letter.

I realize you live this every day but it was my first encounter with biased hatred.

Please realize this is not meant to upset you.  I love you more than ever and totally support you.

Love,
Dad


And inside there was a formally typed up letter (which for someone like my dad would have taken a good amount of effort to produce) directed at the reverend where he blast him for his lack of compassion and understanding.

My dad has come a long way. 

See, the dad that raised me was this Southern bigoted racist homophobic militant asshole.  And I sometimes think that me being gay was like furthest thing for my dad to be able to accept.  In many ways it broke my dad.   It broke the world that he knew.  He couldn't be that person and still continue to love me as a son.  It forced him to change.

And now... I have to say, this is all pretty amazing to me.    I'm actually pretty amazingly proud of him. 

(comment on this)

Friday, June 29th, 2012
9:30 am - I created the Game Variant: Two-Headed Giant

I've always loved game mechanics.  I love thinking of new games to play and the process of creating them. 

Back in the 90's I played Magic.  And I thought of a new game variant that I wrote up and played with my friends.

The game variant was called "Two-Headed Giant."

I liked the game, so I went online and I published my game variant to multiple Magic forums, websites, and even to the Mtg group on livejournal.   That was during the 90's.

Now, today, this morning, I'm reading the newest rulebook for Magic the Gathering and notice there's a Game Variant  section of the rules, and there printed in the rule book is my Game Variant "Two-Headed Giant."   And it's almost word for word exactly the way I wrote it.   Players start with 30 life.  Players on the same team share turns and phases.  On and on, exactly the way I created it.

So they published my idea, which I had already published on the internet a decade ago.  And yet, they gave me no credit for it. 

I would have liked to have just gotten a credit for the game which I created.

(( Now I'm gonna have to go through archive.org and see if I can find all the original publications I did when I originally created this game variant. ))

(1 comment | comment on this)

Wednesday, May 30th, 2012
12:32 pm - Install MySQL Using MacPorts for MacOS X

Install MySQL Using MacPorts

1- Install MacPorts
http://www.macports.org/install.php

2- Update MacPorts:
sudo port selfupdate

3- Install MySQL server and client binaries:
sudo port install mysql55

4- Install MySQL server startup scripts:
sudo port install mysql55-server

5- Initialize the Database:
sudo /opt/local/lib/mysql55/bin/mysql_install_db --user=mysql

6- Start MySQL:
sudo /opt/local/share/mysql55/support-files/mysql.server start

7- Set root password:
/opt/local/lib/mysql55/bin/mysqladmin -u root password 'changepasswordhere'

8- Enable the startup script so mysql starts on boot
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql55-server.plist
– or --
sudo port load mysql55-server

9- If you need to uninstall/reinstall for whatever reason, remove the database directory when you do the uninstall
sudo port uninstall mysql55-server
cd /opt/local/var/db/
sudo rm -rf mysql55/

10- To check the contents of any package:
sudo port contents <package_name>

(comment on this)

Sunday, May 6th, 2012
6:10 pm - How to install gimp under MacOSX 10.7.3
Currently if you try to install gimp on MacOSX 10.7.3 via MacPorts (2.0.4-10.7-Lion) you'll get the following error:
# sudo port install gimp
---> Computing dependencies for gimpError: Unable to execute port: can't read "startupitem.install": no such variable
To report a bug, see ...
Here's the fix/workaround for it:
# sudo port install gimp +no_startupitem

(comment on this)

Saturday, April 28th, 2012
6:40 pm - How to fix the annoying macosx "are you sure you want to open this" dialgue
How to get rid of that annoying ass Dialogue in MacOS prompting you after you download something saying "Are you sure you want to open this. It was downloaded from the Internet."

Which gets to be EXTREMELY annoying when you download 100 photos and want to view them all at once. And each one prompts you in Preview. Actually it's worse, if you Select All the photos and try to open them at once, the first once gives you that annoying dialogue and then it quits. So it only opens ONE of them. ANNOYING APPLY BUG!!!!

This is how to fix that shit!

http://osxdaily.com/2010/09/12/disable-application-downloaded-from-the-internet-message-in-mac-os-x/

(comment on this)


> previous 20 entries
> top of page
LiveJournal.com