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 »
27 total  XML / RSS feed 

4455

// description of your code here
abphoneformats.plist

// insert code here..
plutil -convert xml1 some_file.plist

Common macports commands

Installs a package
port install package

uninstalls a package
port uninstall package

shows all ports currently installed
port installed

shows all ports not currently installed, you may want to pipe the output of this command to grep to limit the output
port uninstalled

search for a port whose name matches the regex
port search regex

shows meta information on a package
port info package

shows the latest version of all available ports
port list

Compressing a directory with rar on Linux

I've been struggling to get this to work for so long that when I finally got it going I had to throw it up here so I wouldn't lose it.
rar a -m5 -R output.rar /etc/

This will create a max compression (not taking into account dictionary sizes and the like) archive of the entire etc directory.

Disconnect Windows 2000 RDP session from command line

I use SSH to gain access to my Windows 2000 command line, so that will be reflected in the below steps.


Step #1: Connect to the server if you are not sitting at it
ssh username@win2000server -i privatekey

Step #2: Find out which sessions are currently active
query session

 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>console                                     0  Conn    wdcon
 rdp-tcp                                 65536  Listen  rdpwd
 rdp-tcp#7         fakeuser                  1  Active  rdpwd

Step #3: We want to kill the connection with an ID of 1 (we can tell by the username and that it is active)
tsdiscon 1 /v

Disconnecting sessionID 1 from sessionname RDP-Tcp#7

That's it :) Easy eh?

Delete all Dreamweaver notes directories

find ~/sites -name _notes -print0 | xargs -0 rm -rf

Human Readable ls and df commands

Simple but useful to know...

To get a ls (file list) or df (disk free) to show in K,M or G instead of *huge* numbers of bytes without commas, use the -h flag.

ls -lh
df -h

Burn ISO osx

Open Terminal and type:
hdiutil burn image.iso

concatenate files

The correct syntax for the cat command is:

cat file1 file2 ... [fileN] > file

where file1, file2, fileN are the download images and "file" is the .iso file you are creating.

Access subversion repository on Textdrive via ssh

I found it really difficult to get svn via svn+ssh geting to work because I made two erorrs:
I used not my main user. However, only the main user can get shell access necessary for svn via ssh.
I used a wrong path.

In order to get things going set up subversion following the usual directives in the knowledge base and then access your repository like this:
(OS X terminal here)
% svn co svn+ssh://mainuser@yourdomain.tld/home/mainuser/svn/repositoryname/

This should do the trick.

Remember not to use ssh and http(s) at the same time. It's either or.

disable built-in isight

sudo chmod a-rx /System/Library/QuickTime/QuickTimeUSBVDCDigitizer.component/Con
tents/MacOS/QuickTimeUSBVDCDigitizer

and to restore:
sudo chmod a+rx /System/Library/QuickTime/QuickTimeUSBVDCDigitizer.component/Con
tents/MacOS/QuickTimeUSBVDCDigitizer

fast user switch from the command line

#!/bin/sh  
MENUEXTRAS="/System/Library/CoreServices/Menu Extras"
CGSESSION="$MENUEXTRAS/User.menu/Contents/Resources/CGSession"
if [[ -z $1 ]]; then
    "$CGSESSION" -suspend
else  
    USERID=`id -u $1`;
    if [[ -z $USERID ]]; then
        exit -1;
    fi;
    "$CGSESSION" -switchToUserID $USERID
fi;

power off the displays

this really powers off the displays, unlike other solutions which just put them to the dimmest setting
#!/bin/sh
  
MAGIC_NUMBER=107374183
PMSET=/usr/bin/pmset
GREP=/usr/bin/grep
AWK=/usr/bin/awk
SLEEP=/bin/sleep
    
$PMSET force -a displaysleep $MAGIC_NUMBER
$SLEEP 1
$PMSET force -a displaysleep `$PMSET -g | $GREP displaysleep | $AWK '{print $2}'`
$SLEEP 1

/etc/sysctl.conf

These are my settings for sysctl.conf
# Max number of incoming connections in queue
kern.ipc.somaxconn=512
# Maximum number of processes
kern.maxproc=2048
kern.maxprocperuid=1024
# Network buffers; 2K each; check current usage with `netstat -m`
kern.ipc.nmbclusters=2048
kern.ipc.maxsockets=2048
# Maximum segment size; other possible values are 1452 and 1460
net.inet.tcp.mssdflt=1440
# Window scaling is only necessary if buffers > 64K
net.inet.tcp.rfc1323=0
# Increase buffer sizes
kern.ipc.maxsockbuf=131070
net.inet.tcp.sendspace=32768
net.inet.tcp.recvspace=65535
net.inet.udp.recvspace=65535
net.inet.udp.maxdgram=57344
net.inet.raw.recvspace=65535
# Max number of ICMP "Unreachable" and also TCP RST packets per second
net.inet.icmp.icmplim=50
# Stop redirects
net.inet.icmp.drop_redirect=1
net.inet.icmp.log_redirect=1
net.inet.ip.redirect=0
# Stop source routing
net.inet.ip.sourceroute=0
net.inet.ip.accept_sourceroute=0
# Stop broadcast ECHO response
net.inet.icmp.bmcastecho=0
# Stop other broadcast probes
net.inet.icmp.maskrepl=0
# Cuts down on the number of tiny packets
net.inet.tcp.delayed_ack=1
# Turn off forwarding/routing
net.inet.ip.forwarding=0
# Defend against sequence number attacks
net.inet.tcp.strict_rfc1948=1
# Defend agains stealth simple port scans
net.inet.udp.blackhole=1
net.inet.tcp.blackhole=2
# Expire dead connections
net.inet.tcp.always_keepalive=1
net.inet.tcp.keepintvl: 1500
net.inet.tcp.keepinit: 3000
# Verbose firewall logging
net.inet.ip.fw.verbose=1
net.inet.ip.fw.verbose_limit=65535
# Prevent core dumps
kern.coredump=0

Create an ecrypted sparse disk image to store private stuff

hdiutil create Private -type SPARSE -encryption -fs HFS+J -volname Private

If you want it to be case-sensitive AND journaled, you can't simply use HFSX+J, you have to use HFSX, then issue this command:
diskutil enableJournal /Volumes/Private

Lock the keychain when idle

Lock the keychain when system sleeps or is idle for 10 minutes.
security set-keychain-settings -l -u -t 600

Boot in verbose mode

Watch startup messages.
sudo nvram boot-args=-v

check for file collisions when downgrading from HFSX to HFS

when converting from HFSX to HFS (case-sensitive to case insensitive), run this command to verify there will be no file collisions:
2>/dev/null find . -print | tr "[:upper:]" "[:lower:]"  | sort | uniq -d

repair disk permissions from the command line

sudo diskutil repairPermissions /

Refresh rate in Vienna

Change the default refresh rate in seconds for the Vienna RSS reader to whatever you want. Anything less than 1800 seconds might be considered bad netiquette, but it's useful if you're only subscribed to internal feeds (e.g., activeCollab, Connector).

defaults write uk.co.opencommunity.vienna2 CheckFrequencyInSeconds 60

twitter from the command line

Replace username/password with your info. The message is posted as the status text.

curl -u username:password -d status="" http://twitter.com/statuses/update.xml
« Newer Snippets
Older Snippets »
27 total  XML / RSS feed