Never been to CodeSnippets 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!)

2 total

fsinfo

fsinfo - get file status information with Apple's FSMegaInfo sample code
See: FSMegaInfo by Apple and FSMegaInfoGUI by Ross Tulloch

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export IFS=$' \t\n'

/usr/bin/sudo /bin/mkdir -p /usr/local/bin
/usr/bin/sudo /usr/sbin/chown root:wheel /usr/local /usr/local/bin
/usr/bin/sudo /bin/chmod 0755 /usr/local /usr/local/bin

cd ~/Desktop
curl -LO http://developer.apple.com/samplecode/FSMegaInfo/FSMegaInfo.zip
unzip -qq FSMegaInfo.zip

open -e ~/Desktop/FSMegaInfo/Read\ Me\ About\ FSMegaInfo.txt


file -ik ~/Desktop/FSMegaInfo/build/Debug/FSMegaInfo
otool -Lmv $_
otool -hmVv $_
otool64 -hmVv $_
lipo -detailed_info $_


/usr/bin/sudo /bin/cp -i ~/Desktop/FSMegaInfo/build/Debug/FSMegaInfo /usr/local/bin
ls -l /usr/local/bin/FSMegaInfo

/usr/bin/sudo /bin/ln -is /usr/local/bin/FSMegaInfo /usr/local/bin/fsinfo
ls -l /usr/local/bin/fsinfo


# create a test file
testfile="${HOME}/Desktop/testfile.txt"
jot -b 'sample text' 10 | cat -n > $testfile


FSMegaInfo help
fsinfo help
fsinfo help 2>&1 | grep -i info

fsinfo -v help stat
fsinfo stat $testfile

fsinfo -v help FSGetCatalogInfo
fsinfo -v help FSGetCatalogInfo 2>&1 | grep -i finder
fsinfo -v FSGetCatalogInfo $testfile
fsinfo -v FSGetCatalogInfo -kFSCatInfoGettableInfo $testfile
fsinfo -v FSGetCatalogInfo -kFSCatInfoGettableInfo $testfile 2>&1 | grep -i encod


# createDate

fsinfo -v FSGetCatalogInfo -kFSCatInfoCreateDate $testfile
fsinfo -v FSGetCatalogInfo -kFSCatInfoAccessDate,kFSCatInfoContentMod,kFSCatInfoAttrMod,kFSCatInfoCreateDate $testfile

stat -x $testfile | tail -n 3
stat -f $'%N:\nlast accessed:\t\t%Sa\nlast modified:\t\t%Sm\nlast inode change:\t%Sc' $testfile

touch -f $testfile

stat -x $testfile | tail -n 3
stat -f $'%N:\nlast accessed:\t\t%Sa\nlast modified:\t\t%Sm\nlast inode change:\t%Sc' $testfile

fsinfo -v FSGetCatalogInfo -kFSCatInfoCreateDate $testfile
fsinfo -v FSGetCatalogInfo -kFSCatInfoAccessDate,kFSCatInfoContentMod,kFSCatInfoAttrMod,kFSCatInfoCreateDate $testfile

Using notify-send with IRSSI

Requires libnotify, have fun!

use strict;
use vars qw($VERSION %IRSSI);

use Irssi;
$VERSION = '0.0.3';
%IRSSI = (
        authors     => 'Chrelad',
        contact     => 'blah@blah.blah',
        name        => 'notify',
        description => 'Display a pop-up alert for different events.',
        url         => 'http://google.com',
        license     => 'GNU General Public License',
        changed     => '$Date: 2007-02-07 12:00:00 +0100 (Thu, 7 Feb 2008) $'
);

#--------------------------------------------------------------------
# Created by Chrelad
# Feb 7, 2008
#--------------------------------------------------------------------

#--------------------------------------------------------------------
# The notify function for public message
#--------------------------------------------------------------------

sub pub_msg {
        my ($server,$msg,$nick,$address,$target) = @_;
        `notify-send -t 8000 "${target} : ${nick}" "${msg}"`;
}

#--------------------------------------------------------------------
# Irssi::signal_add_last / Irssi::command_bind
#--------------------------------------------------------------------

Irssi::signal_add_last("message public", "pub_msg");
#- end
2 total