Ramblings Of a Madman

Yeah, like i would know a good description…

Posts for Tag: tips

JAVA JScrollPane change scrollbar width or height

It's actually pretty simple. Just do something like this, adjusting to the horizontal scrollbar and/or the height that you want:

yourScrollPcane.getVerticalScrollBar().setPreferredSize(new Dimension(85, Integer.MAX_VALUE));

Miner Wars 2081 saved games directory/folder

The files live in this folder (at least on Windows 7 and possibly 8):


If you use the standalone client, the files will be inside PUBLIC. If you are using STEAM, then they will be under STEAM. This way if, like me, you move from the standalone version to steam you can copy your save games and start the game from where you left it :)

Date and time in ruby

Time.now will give you the current date (and time), like so:

Time.now 2012-11-22 22:35:01 +0000

You can also request all the date parts individually:

Time.now.hour 22 Time.now.min 35 Time.now.sec 01 Time.now.day 22 Time.now.month 11 Time.now.year 2012

Cool (and easy), right? If you want to change a date, you can add seconds to it:

t = Time.now 2012-11-22 22:35:01 +0000 t2 = t + 10 # 10 Seconds 2012-11-22 22:35:11 +0000 t3 = t + 10*60 # 10 minutes 2012-11-22 22:45:01 +0000 t4 = t + 10*60*60 # 10 hours 2012-11-23 08:35:01 +0000

If you happen to be developing a Ruby on Rails application then it gets even easier:

t = Time.now 2012-11-22 22:35:01 +0000 t2 = t + 1.hour 2012-11-22 23:35:01 +0000

That's right, in Rails numerals get some extra methods injected into them, like hour, hours, minute, minutes, second, seconds, day, days, and so on... And people still ask me why i love Ruby (and Rails)... :)

Update server not available (error- 12) on OSX

Here's the definitive fix for this annoying-as-hell problem:

1. Run the following on the command line: sudo /Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Resources/GoogleSoftwareUpdateAgent.app/Contents/Resources/install.py --uninstall 2. Restart Chrome.

Taken from here.


Future me

If you still haven't heard of futureme.org, then you definitely need to check it out. It's a service that will store messages addressed to yourself sometime in the future. I've been using it for a few years now and i'm always amazed when i get my own message from the past and see how much my life has changed in one year alone. Imagine if you send yourself a message to be read 10 years from now :)

Check it out. Some laughs are definitely guaranteed next year ;)

How to get the "watch" command line tool on OSX

1. Download it. curl -O http://sveinbjorn.org/files/software/watch-0.3-macosx.zip 2. Unzip and move into folder.

2. Make file executable. chmod +x watch 3. Move it to somewhere in $PATH. sudo mv watch /usr/local/bin/ 4. Done.


Export Mysql result as CSV

Don't ask me how the sed magic works, but it does. Taken from here.

Running this: mysql -u<USER> -p<PASSWORD> <DATABASE> -B -e "select * from videos_video;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' will produce something like this: "id","title","url" "1","video 1","http://youtube(...)" "2","video 2","http://youtube(...)" "3","video 3","http://youtube(...)" Just pipe it to a .csv file and you're done :)

Nice tweaks for OSX

I think most of them work on both Snow Leopard and Lion. Not sure about previous versions. Just type the ones you want to activate/deactivate on the command line and have fun. # Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs) defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

# Enable the 2D Dock defaults write com.apple.dock no-glass -bool true

# Disable menu bar transparency defaults write -g AppleEnableMenuBarTransparency -bool false

# Expand save panel by default defaults write -g NSNavPanelExpandedStateForSaveMode -bool true

# Expand print panel by default defaults write -g PMPrintingExpandedStateForPrint -bool true

# Disable shadow in screenshots defaults write com.apple.screencapture disable-shadow -bool true

# Enable highlight hover effect for the grid view of a stack (Dock) defaults write com.apple.dock mouse-over-hilte-stack -bool true

# Enable spring loading for all Dock items defaults write enable-spring-load-actions-on-all-items -bool true

# Disable press-and-hold for keys in favor of key repeat defaults write -g ApplePressAndHoldEnabled -bool false

# Disable auto-correct defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

# Disable window animations defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false

# Disable disk image verification defaults write com.apple.frameworks.diskimages skip-verify -bool true defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true

# Automatically open a new Finder window when a volume is mounted defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true

# Avoid creating .DS_Store files on network volumes defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

# Disable Safari's thumbnail cache for History and Top Sites defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2

# Enable Safari's debug menu defaults write com.apple.Safari IncludeDebugMenu -bool true

# Remove useless icons from Safari's bookmarks bar defaults write com.apple.Safari ProxiesInBookmarksBar "()"

# Disable send and reply animations in Mail.app defaults write com.apple.Mail DisableReplyAnimations -bool true defaults write com.apple.Mail DisableSendAnimations -bool true

# Disable Resume system-wide defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false

# Enable Dashboard dev mode (allows keeping widgets on the desktop) defaults write com.apple.dashboard devmode -bool true

# Reset Launchpad rm ~/Library/Application\ Support/Dock/*.db

# Show the ~/Library folder chflags nohidden ~/Library

# Disable local Time Machine backups sudo tmutil disablelocal

# Kill affected applications for app in Safari Finder Dock Mail; do killall "$app"; done

# Fix for the ancient UTF-8 bug in QuickLook (http://mths.be/bbo) echo "0x08000100:0" > ~/.CFUserTextEncoding The original source can be found here.