Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
11 total  XML / RSS feed 

Check DNS lookup in Tiger

lookupd -configuration

Look for the following in the output:
LookupOrder: Cache FF DNS NI DS
_config_name: Host Configuration


The FF (flat file) refers to your hosts file (/etc/hosts), and Tiger does check its contents before going to DNS and Netinfo. Just a little FYI for those who may not have realized that 10.4 fixed things.


Burn ISO osx

Open Terminal and type:
hdiutil burn image.iso

Make iTunes arrows point to your own music, not the iTS

defaults write com.apple.iTunes invertStoreLinks -bool YES


This makes those little right-pointing arrows in iTunes point to your library, not the iTunes Store. If you want the iTunes Store, Option-click instead.

How to ssh into Ubuntu on Parallels by hostname

this is something that strangely doesn't happen automatically on ubuntu
in Ubuntu, just add
send host-name "dapperbox";

to your /etc/dhcp3/dhclient.conf file

you might need to do a
sudo /etc/services/networking restart


On your Mac, you can now do
ssh username@dapperbox


instead of

ssh username@1.2.3.4

Set disksleep to never

Check out man pmset for further command options!


sudo pmset -a disksleep 0 sleep 0 

Install Rails/lighttpd with DarwinPorts for Tiger

install darwinports package

Add 'export PATH=/opt/local/bin:$PATH' to ~/.bashrc

sudo port -d selfupdate

sudo port install ruby

sudo port install rb-rubygems

sudo gem install rails --include-dependencies

sudo port install readline

sudo port install lighttpd

vi /opt/local/etc/lighttpd.conf [edit lighttpd.conf to your liking]

set up launchd item for lighttpd
        -- restart lighttpd: sudo launchctl stop net.lighttpd
                             sudo launchctl start net.lighttpd

sudo port install fcgi

sudo port install rb-fcgi
         
install official OS X MySQL package (not darwinports)

sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql


Links:
darwinports package
launchd item
OS X MySQL package

Rails MySQL Session Sweeper

1) Download the launchd GUI, Lingon, from: http://lingon.sourceforge.net/

2) Add hourly job:

$RAILS_APP_DIR/script/runner 'ActiveRecord::Base.connection.delete("DELETE FROM sessions WHERE updated_at < now() - INTERVAL 1 HOUR")'


3) My launchd task plist file (yours will vary):

<?xml version="1.0" encoding="UTF-8"?>
DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Labelkey>
        us.boygeni.mysql-session-sweeper</string>
        <key>LowPriorityIOkey>
        />
        <key>ProgramArgumentskey>
        
                /users/defeated/Sites/rails_apps/boygenius/script/runnerstring>
                'ActiveRecord::Base.connection.delete("DELETE FROM sessions WHERE updated_at < now() - INTERVAL 1 HOUR")'</string>
        array>
        RunAtLoad</key>
        <true/>
        <key>StartIntervalkey>
        3600</integer>
dict>
</plist>

Rounded Mac Input Box

This html code makes an input box that looks like the one found at here (Under the search downloads box) It works only on macs(safari tiger only i believe) and does not validate. Note: type="search" is what makes it work.
<input type="search" name="blah" value="Search"/>

Set the default compiler on Mac OS X Tiger

Some stuff won't compile with the shiny new gcc 4.0 on Tiger.
To use gcc 3.3 :
sudo gcc_select 3.3


To revert to gcc 4.0 :
sudo gcc_select 4.0


(found on the forum, thanks Damelon!)

MySQL launchd item for Mac OS X Tiger

(Originally posted at Unquiet)

I had to reinstall Mysql because it wasn�t one of the things I backed up before erasing my hard drive. Since I�m now running Mac OS X 10.4 �Tiger�, I decided to set it up to start when the system boots, but the system for creating startup items has changed slightly. So I saved the following xml in /Library/LaunchDaemons/com.mysql.Mysql.plist:

<?xml version="1.0" encoding="UTF-8"?>
    DOCTYPE plist PUBLIC 
         "-//Apple Computer//DTD PLIST 1.0//EN" "
        http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Labelkey>
        com.mysql.Mysql</string>
        <key>OnDemandkey>
        />
        <key>ProgramArgumentskey>
        
                /usr/local/mysql/bin/mysqld_safestring>
        </array>
        <key>ServiceDescriptionkey>
        Mysql 4.1 Database Server</string>
        <key>UserNamekey>
        mysql</string>
        <key>WorkingDirectorykey>
        /usr/local/mysqlstring>
    </dict>
    plist>


Note that I'm using the official OSX distribution of MySQL... but with a few changes to match your database location, you can get this to work with other installs (fink, darwinports, etc).
« Newer Snippets
Older Snippets »
11 total  XML / RSS feed