Friendly Ghost

@vogti is writing.

Tristan Otto, the T-Rex

iPhone 6, used: SKRWT, VSCO, Enlight


Art in Prinzessinnengarten

iPhone 6, used: SKRWT, VSCO, Enlight


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...