Friendly Ghost

@vogti is writing.

It was my birthday and we found a photobooth. The rest is history.


JavaScript output in Sublime Text

Wouldn't it be nice to execute your JavaScript snippets directly where you write them? Sublime Text allows it to define build logic e.g. to call commands on the currently opened file.

First of all you need to figure out where node is installed:

$ which node
/usr/local/bin/node

SublimeText Build Tools

Afterwards create a new *.sublime-build file via Tools -> Build System -> New Build System and copy & paste the following code:

{
  "cmd": ["/usr/local/bin/node", "$file"],
  "selector": "source.js"
}

If you set your $PATH variable correctly the single node command should also do the job. I prefer the more comprehensive way.

Save this file as e.g. JavaScript.sublime-build inside the Sublime User directory: ~/Library/Application Support/Sublime Text 3/Packages/User/JavaScript.sublime-build.

Let´s see whether everything worked out correctly: You can run the build function manually from Tools -> Build or via CMD + B. In case something doesn't work correctly make sure that

  • you try to build a saved *.js file
  • Automatically or JavaScript is checked in Tools -> Build System

SublimeText console output


Bash operations based on a list of files

I have a file, which contains a list of filenames one per line. Like this:

diff.txt

123.gz  
456.gz  
789.gz  

I'm not quite sure, whether every file really exists. But if this is the case I want to do a special operations on it (find, mv, cp ...).

This can be achieved by a little bit of bash magic:

$ while read -r filename; do ionice -c3 find /search/in/dir -type f -name "$filename.gz" -print0 | xargs --null cp -t /copy/to/dir/;
done < /path/to/file.txt  

Okay, what do we have here?

  • ionice -c3 - tells the OS to only work on the command, when it has some air to breath
  • find finds your files and awaits $filename as parameter
  • xargs reads the output of the previous command and does some action withit (in this case: copying). -t is the input (output of find).

Pretty sure I'll need this again...


Rhythm Roulette

Kennt ihr Rhythm Roulette? Das Prinzip ist einfach: zufällig drei Platten wählen und daraus einen Beat bauen. Das ist nicht wirklich neu - ich beobachte das Format schon eine ganze Weile - bin aber jedes mal wieder fasziniert davon.

Dabei kommen nicht selten ziemlich stabile Tracks raus. Einen davon hat z.B. Large Professor kreiert.

Ganz neben bei finde ich es immer ziemlich spannend, wie es bei den Künstlern im Studio aussieht :)


Getting PSN Account stats

I was curious whether it's possible to get basic information about my PSN Account. Whats my current level? How much trophies did I achieve? That kind of stuff.

Since PlayStation provides such a service publicly on their website I thought it should also be available via a GET-request.

Furtunately stackoverflow could (as always) help. So this is what I came up with, for my account:

$ curl -s -X GET https://secure.us.playstation.com/playstation/psn/profile/public/userData?onlineId=eagon1337 --referer https://secure.us.playstation.com/logged-in/trophies/public-trophies/ | python -mjson.tool
{
    "avatarUrl": "//static-resource.np.community.playstation.net/avatar_m/3RD/UP40731301009_65ED8105B0C68DC79ABC_M.png",
    "curLevel": "5",
    "handle": "eagon1337",
    "isPlusUser": "1",
    "progress": "52",
    "totalLevel": "",
    "trophies": {
        "bronze": "124",
        "gold": "6",
        "platinum": "1",
        "silver": "22"
    }
}