Keep your ~/.bash_history entries unique

When often using the terminal you don’t want to type certain commands over and over again. Although recent commands are stored in the .bash_history in your home-directory they will be overwritten at some point when a new terminal is opened. So you won’t be able to use Ctrl + R to search for commands you’ve typed longer time ago. Luckily there is an option to append the terminal commands instead of overwriting them.

$ shopt -s histappend


Add this command to your ~/.bash_profile and you’ll never lose a command anymore. As a side effect the .bash_history file will grow over time as well as be poluted with a lot of redundant commands. So i wrote a little ruby script to keep the ~/.bash_profile commands unique. Here we go..

#!/usr/bin/env ruby
# Ruby 1.9.2 
# encoding: utf-8
 
# This little script keeps the entries in the ~/.bash_history file unique
# Might be useful when working with: $ shopt -s histappend 
#
# author   david linse (david@8ball-media.de)
# version  0.0.1
 
history_path = "/Users/#{ENV['USER']}"
history_file = ".bash_history"
 
history = File.join history_path, history_file
 
entries = Array.new
uniques = Array.new
 
begin
  file = File.open(history).each do |line|
    entries.push line
  end
rescue
  abort "\nError! could not find: #{history} ..\n "
end
 
uniques = entries.uniq
removed = (entries.size - uniques.size).to_s
 
output = File.new(history, "w+")
output.write(uniques)
output.close
 
file.close
 
msg = ''
msg << "\nBash History Uniquifier\n\
Removed #{removed} entries from #{entries.size}, \
now #{uniques.size} in #{history}\n "
 
puts msg


You can use and/or modify it to your own needs. Maybe there is someone of you who’s running Ruby on an Windowz machine and could implement an appropriate modification and post it back.. ?

That’s it, more simple ruby stuff to come.. Thanks for reading and feel free to leave a comment.

Kindest

Update: I added some error handling for the case the history does not exist.

Posted in experiments, stuff | Tagged , , | Leave a comment

Mustek 600/1200 CU on OSX 10.5

Due the lack of a provided driver it took me some hours to get my “good old” Flatbed-Scanner Mustek 600 CU up and running on OSX 10.5 so i want to share this. May it save someone some time..

Basically all the magic is done "SANE-API" and you’ll need the following installer-packages:

  • libusb
  • SANE backends
  • TWAIN SANE Interface
  • SANE Preference Pane


which can be found here.. Download and install them in the same order. Now plug-in your scanner, launch your image-tool and fire up a scan via: File > Import > Sane.
Voila !


Keywords: Mustek, Flatbed-Scanner, OSX 10.5

Flattr this
Posted in howto | Tagged , , | 3 Comments

How to send or receive data JSON encoded data from flash to a server-side-script

As contributor in some flash-related forums i noticed, that a lot of people are asking the same question over and over again.

How to send or receive JSON-encoded data from flash to a server-side-script.. ?

So i wrote this little tutorial..

Posted in AS3, howto | Tagged , , | Leave a comment

Sending Mails Using Ant MailTask FDT/Eclipse

I allways wanted to make use of the “Post compile ant file” from Eclipse. After hours of searching, trial and (mostly) error i finally got it working. The Ant-MailTask sends a mail from within Eclipse including attachment.

The downside is that i was unable to get this running with my default Ant installation (v.1.7.1) and had to install a newer version of Ant.

I dont want to bore you with details of my odyssey but show you how it gets done in more or less four steps. Continue reading

Posted in experiments, howto | Tagged , | Leave a comment

How To Protect Your Game From Being Rebranded (AS2)

Eric Heimburg from FlashGameLicense.com wrote an article about
How to protect your game from beeing rebranded for Actionscript3.

Because i’m developing flash-based-games here and there i found this article quite interesting. After reading this post i digged in my old experiments from the good old Actionscript2 times to get familiar again with the syntax. It’s been ‘a couple of days’ since i wrote my last lines of code in AS2. But following the idea of Eric the code is pretty much the same exept a few loops more.
Continue reading

Posted in experiments | Tagged , | Leave a comment