This is an awesome tagline

Expandmenu Shrunk


  • [BASH] How to list only the hidden files in a directory

    Because of work and my general desire to know things I have been learning Bash scripting.  One of the quirks I came across was wild card expansion.  In particular I was trying to find a command to list hidden files and directories in the current directory.

    I tried

    ls -al .*

    but it came up with a strange result.

    jeffsmith@10-201-8-85:~/test/subtest$ pwd
    /home/jeffsmith/test/subtest
    jeffsmith@10-201-8-85:~/test/subtest$ ls -al .*
    -rw-r--r-- 1 jeffsmith jeffsmith    0 2012-12-26 02:37 .hidden1
    -rw-r--r-- 1 jeffsmith jeffsmith    0 2012-12-26 02:37 .hidden2
    
    .:
    total 16
    drwxr-xr-x 4 jeffsmith jeffsmith 4096 2012-12-26 02:40 .
    drwxr-xr-x 3 jeffsmith jeffsmith 4096 2012-12-26 02:34 ..
    -rw-r--r-- 1 jeffsmith jeffsmith    0 2012-12-26 02:40 file1
    -rw-r--r-- 1 jeffsmith jeffsmith    0 2012-12-26 02:40 file2
    -rw-r--r-- 1 jeffsmith jeffsmith    0 2012-12-26 02:37 .hidden1
    -rw-r--r-- 1 jeffsmith jeffsmith    0 2012-12-26 02:37 .hidden2
    drwxr-xr-x 2 jeffsmith jeffsmith 4096 2012-12-26 02:38 .hiddenDir1
    drwxr-xr-x 2 jeffsmith jeffsmith 4096 2012-12-26 02:38 .hiddenDir2
    
    ..:
    total 12
    drwxr-xr-x  3 jeffsmith jeffsmith 4096 2012-12-26 02:34 .
    drwx------ 56 jeffsmith jeffsmith 4096 2012-12-26 02:34 ..
    -rw-r--r--  1 jeffsmith jeffsmith    0 2012-12-26 02:35 file1
    -rw-r--r--  1 jeffsmith jeffsmith    0 2012-12-26 02:35 file2
    -rw-r--r--  1 jeffsmith jeffsmith    0 2012-12-26 02:35 file3
    -rw-r--r--  1 jeffsmith jeffsmith    0 2012-12-26 02:36 .hidden1
    -rw-r--r--  1 jeffsmith jeffsmith    0 2012-12-26 02:36 .hidden2
    -rw-r--r--  1 jeffsmith jeffsmith    0 2012-12-26 02:36 .hidden3
    drwxr-xr-x  4 jeffsmith jeffsmith 4096 2012-12-26 02:40 subtest
    
    .hiddenDir1:
    total 8
    drwxr-xr-x 2 jeffsmith jeffsmith 4096 2012-12-26 02:38 .
    drwxr-xr-x 4 jeffsmith jeffsmith 4096 2012-12-26 02:40 ..
    -rw-r--r-- 1 jeffsmith jeffsmith    0 2012-12-26 02:35 file1
    -rw-r--r-- 1 jeffsmith jeffsmith    0 2012-12-26 02:35 .hidden1
    
    .hiddenDir2:
    total 8
    drwxr-xr-x 2 jeffsmith jeffsmith 4096 2012-12-26 02:38 .
    drwxr-xr-x 4 jeffsmith jeffsmith 4096 2012-12-26 02:40 ..
    -rw-r--r-- 1 jeffsmith jeffsmith    0 2012-12-26 02:35 file1
    -rw-r--r-- 1 jeffsmith jeffsmith    0 2012-12-26 02:35 .hidden1
    

    first it shows the two hidden files in the folder (great!), then is lists all the files/directories (not so great), then it lists all the files in the parent directory (huh?), then is lists the contents of the two hidden directories.  The problem is the wild card expansion of *.  What the command actually sees is (ls -al . .. .hidden1 .hidden2 .hiddenDir1 .hiddenDir2), or other words all the files and directories that start with a period including the period and periodperiod entries.

    To list the hidden files we need a tool with a bit more finesse, enter find!

    TL;DR

    find `pwd` -maxdepth 1 -type f -name .\*

    This returns what I am looking for

    jeffsmith@10-201-8-85:~/test/subtest$ find `pwd` -maxdepth 1 -type f -name .\*
    /home/jeffsmith/test/subtest/.hidden2
    /home/jeffsmith/test/subtest/.hidden1

    this command is a little complex so I will go through it section by section.

    1. find this is command name
    2. `pwd` this is a back tick replacement.  It execuates the pwd command and insert the results here.
    3. -maxdepth 1 this tells find to only search this directory (normally find will recursively search the directory structure.
    4. -type f only look for files
    5. -name .\* look for entries with the name .\* (the backslash is to prevent Bash from expanding the *


  • gamer-dialects

    I am acutely aware that different cultures have their own language. Gamers are no exception but even within the gamer subculture there are sub-subcultures and have their own dialects. I think this article is a great example http://themittani.com/news/blood-spilled-over-irc-csaa . I understood the article and I think most people could read it and get the jist but wouldn’t get the finer points. i.e., What is a CSAA and why is it such a bad/good thing. What is TiDi and how is it helpful to “reps”. What is reps?

    Can you think of other gamer sub-cultures that have their own dialects and what are some examples?



  • Cynical Game Designers

    As an old man (mid 30′s) I am amazed at the lack of innovative design in modern AAA titles.  They tend to be fun but usually they are old tropes with a bit of polish.  Sometimes they polish the graphics and remove a cool feature like LAN play (I am look at your Starcraft II and Diablo 3).

    It was with this in mind that I found this article (http://keithburgun.net/cynicism-of-the-90s-era-game-designer/) and interesting read.   He discusses the changes in game design from the 90′s (My personal favorite era) to today and why the 2000s hurt modern game design.

    tl;dr; The article is good read it.

    http://keithburgun.net/cynicism-of-the-90s-era-game-designer/



  • [LQC] Finding your user ID

    Here is a Linux Quick Command.  We hope to have a couple of these each week.

    If you ever need to find your user or group ID on a Linux machine you can type in the command id.  Simple huh. Here is a bit more in depth discussion to follow.

    Command: id

    NAME
    id – print real and effective user and group IDs

    SYNOPSIS
    id [OPTION]… [USERNAME]

    DESCRIPTION
    Print user and group information for the specified USERNAME, or (when USERNAME omitted) for the current user.

    EXAMPLE RESULT
    uid=1941(jeff) gid=1941(jeff) groups=1941(jeff)



  • [SQL] Using the same forgeign key in two different columns.

    I am working on a simple app for Eve Online.  As such I downloaded the data dump for Inferno.  The database had a table for all the jump gates (a way to get from one area of the game to the next).  Unfortunately the table does not include the system name only a ID of the “from system” and the “to system”.  I wanted to retrieve a list of all the gates exiting a particular system.  When I wrote my initial query I wrote something like this

    SELECT
    `mapSolarSystemJumps`.fromSolarSystemID, `mapSolarSystemJumps`.toSolarSystemID
    FROM `mapSolarSystemJumps`
    WHERE `mapSolarSystemJumps`.fromSolarSystemID='30002998';

    This worked well at listing the gate ID of the destinations but not the name of destinations.  But I couldn’t find a way to include the names.  Then I found out about LEFT JOINS.  I setup a new query which did exactly what I wanted.


    SELECT
    A.solarSystemName as fromName, A.solarSystemID as fromID, Round(CEIL(A.security*10)/10,1),
    B.solarSystemName as toName, B.solarSystemID as toID, Round(CEIL(B.security*10)/10,1)
    FROM
    `mapSolarSystemJumps`
    LEFT JOIN `mapSolarSystems` A ON A.solarSystemID= `mapSolarSystemJumps`.fromSolarSystemID
    LEFT JOIN `mapSolarSystems` B ON B.solarSystemID= `mapSolarSystemJumps`.toSolarSystemID
    WHERE
    A.solarSystemName = 'New Caldari'

    This lists the from/to for each gate in a specified system (In this case “New Caldari”) as well as the security level as it is displayed in the game.



  • [EVE] Transporting PLEX is hard (not really but this guy makes it appear that way).

    As many (many just some) know I play with internet spaceship (Eve Online).  One of the reasons I can do this with my limited income is because they offer a way to pay for a subscription with an in game item called a PLEX.  How PLEX work is player A buys a time card on the CCP website (or an approved reseller) and instead of redeeming it for time they redeem it for an in game item.  This in game item is treated just like any other in game item, it can be bought, sold, traded, moved from one location to another.  So while it is not a direct dollar to ISK (in game currency) translation, a PLEX is worth one month of game play which is worth 15$.  Someone somewhere paid the 15$ for the PLEX.

    Now that you understand the value of a PLEX imagine transporting a PLEX in game knowing that any other play could potentially attack you and destroy your ship and its precious cargo.  Now imagine transporting many of these, like lets say 90 (90 *15 = 1350$) would you travel in the seedy underbelly of the game.  A place where you are probably going to die regardless of your cargo?  Probably not but this guy did.

    http://themittani.com/news/alod-90-plex-new-record-stupidity