Skip to main content
  1. Posts/

Day 28 - All asides

OldDays tools ruby

Just stuff.

Oh, hi there.
Oh, hi there.


Aside: Some games
#

  • Finished Volume, and really enjoyed it. Made sure to get 100% of the achievements, which was mercifully open to even someone of my limited skill.
  • Purchased and played through The Beginner’s Guide. As expected, I really enjoyed it. Definitely akin to The Stanley Parable, but different enough in premise and execution to be something new.
  • Finally started playing The Talos Principle and am enjoying it so far.

Aside: The near future
#

I’m definitely doing the upcoming AI course from nucl.ai, and will work it into this blog.


Aside: The slightly further future
#

After a coworker pointed it out, I was glad to see Riot Games using Erlang. It’s my intention to rewrite the IoK server emulator entirely in a different technology stack, and Erlang is very likely to be a part of that.


Aside: Cleaning up my filesystem
#

Having a lot of CDs from various parts of the world, my hard drives are full of music files with interesting sets of characters in their file names. This has caused a few problems with some cloud backup utils, some music utils, even Windows and/or Mac OS X freaking out about the files. After the dozenth annoying crash, I looked around for a quick-and-easy way to sanitize the file names. Not finding exactly what I wanted, I took some of the Ruby code I’d found and morphed it into this monstrosity:

rename_invalid.rb
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
if DirName == nil
  puts "usage:"
  puts ""
  puts "rename_invalid.rb DIRECTORY_NAME"
  puts ""
else

  def check_dir_contents(dirname)
    reasonable = /^[a-zA-z0-9\ \-\.]+$/
    dirs_to_check = []
    # puts "Checking directory #{dirname}..."
    Dir.chdir(dirname)
    Dir.glob("*").each do |file_name |
      # puts "What about this? #{file_name}"

      unless reasonable.match(file_name)
        puts file_name
        new_name = ""
        file_name.each_char do | namechar |
          if reasonable.match(namechar)
            new_name << namechar
          else
            # puts "I don't like: #{namechar}"
            new_name << '_'
          end
        end
        puts "New name: #{new_name}"
        if File.exists?(new_name)
          puts "Oops, that file already exists!"
        else
          File.rename(file_name,new_name)
          file_name = new_name
        end
      end
      if Dir.exists?(file_name) && file_name != "." && file_name != ".."
        dirs_to_check << file_name
      end
    end
    dirs_to_check.each do | dir_to_check|
      check_dir_contents(File.join(dirname,dir_to_check))
    end
  end

  check_dir_contents(DirName)

end

More to come
More to come

Day 28 code - utils