Showing posts with label command line. Show all posts
Showing posts with label command line. Show all posts

Saturday, July 14, 2012

Using pasteboard from command line on OSX

pbcopy, pbpaste - provide copying and pasting to the pasteboard (the Clipboard) from command line. Here are few examples

Tuesday, October 25, 2011

Launching MacVim from Command line

Put this into your .profile or .zshrc file
function mvim { /Applications/MacVim.app/Contents/MacOS/Vim -g $*; } 

Then you can use 'mvim' in the command line.

The full explanation is in the MacVim Google Groups

Monday, April 18, 2011

Failed to install db46 on Snow Leopard

I have a brand new macbook (2011/04/19) and have some trouble with installing db46 with ports

port install db46

fails badly and complains about dependencies.

The easiest fix is to install it without java (and you don't need java)

sudo port -v selfupdate
port clean db46
port install db46 +no_java


There are other articles about this problem, How to fix db46 problem macport installation
or MacPorts 1.8.2 fails to build db46 on Mac OS X 1.6.3

Saturday, March 26, 2011

Turning off case-sensitive tab completion in bash

/etc/inputrc deals with the mapping of the keyboard for certain situations.

Adding

set completion-ignore-case on

to the file turns off case-sensitivity in tab completion.


echo set completion-ignore-case on | sudo tee -a /etc/inputrc

Saturday, March 5, 2011

Building Xcode Projects From the Command Line

xcodebuild -project myProject.xcodeproj -alltargets

Sunday, February 13, 2011

Building CoffeeScript from source

CoffeeScript includes a simple build system similar to Make and Rake. Naturally, it's called Cake, and is used for the build and test tasks for the CoffeeScript language itself.

git clone https://github.com/jashkenas/coffee-script.git
cd coffee-script

To build the whole system
bin/cake build:full

To build the script for inclusion in the browser
bin/cake build:browser
or
MINIFY=false bin/cake build:browser


you may need to install uglify-js as well
npm install uglify-js

Wednesday, February 9, 2011

Get folder size on OSX

Haruka had this problem, here is a simple solution
du -sh FOLDER_NAME

du (abbreviated from disk usage) is a standard Unix program used to estimate the file space usage—space used under a particular directory or files on a file system.

Monday, February 7, 2011

Editing files in the user's path

I have lots of scripts in my path but the actual location differs.

If i have to edit them i often do
vim `which FILE_NAME`

for example
vim `which port_utility`


The which utility takes a command name and searches the path for each executable file that would be run had this commands actually been invoke.

Apache on Snow Leopard, "ulimit: open files: cannot modify limit: Invalid argument"

When I started apache on my Snow Leopard i got a weird exception

/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument


So I opened the script and found that there is something wrong with $ULIMIT_MAX_FILES

The error message says that 'cannot modify limit' so i changed its value to empty string

# ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
ULIMIT_MAX_FILES=""


Voila, it works, but deeper investigation need.

Base64 encoding

Base64 is a group of similar encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation.
Base64 encoding schemes are commonly used when there is a need to encode binary data that needs be stored and transferred over media that are designed to deal with textual data.

to encode

openssl base64 -in INPUT_FILE -out OUTPUT_FILE

and to decode from Base64:

openssl base64 -d -in INPUT_FILE -out OUTPUT_FILE

Monday, January 17, 2011

Sunday, December 26, 2010

Command-line tools on Mac OS X, Snow Leopard

allmemory, fs_usage, fuser, latency, sar, sc_usage, spindump: Display various system usage statistics.

bless, disklabel, disktool, diskutil, drutil, fsck, hdiutil, pdisk: Create, identify, manage, and fix Mac OS X disks, file systems, and disk images.

ioreg, kextstat: Show device drivers and other kernel extensions in use.

mDNS, dns-sd: Test Bonjour service discovery with these diagnostic tools.

open: Invoke launch services on an arbitrary document or application as if doubleclicking it in the Finder.

pbcopy, pbpaste: Move data between stdin/stdout and the Mac OS X pasteboard.

say: Convert text to audio output or a file via Speech Synthesizer.

shasum: Compute or validate SHA message digests.

sips: Manipulate the format and color space of bitmap images (for example, rotate,

sw_vers, uname: Display Mac OS X version information.

syslog and logger: Send, view, and manage system log messages with these modern

xattr: List, display, set, and delete file system extended attributes

You can find more information on apple.com in this documentation.

Monday, December 20, 2010

Get user id on a remote server

you have to use SSH public/private key pairs to make this work.

#!/bin/bash
uid=`ssh <your.server> 'id -u'
echo $uid

more stuff here http://bashcurescancer.com/run_remote_commands_with_ssh.html

Google App Engine Development Console from command line

When you develop on localhost the interactive console that Google provides is not convenient.
In my project I had to run few scripts in the console quite often, so instead of going to the interactive console all the time I could do it from command line.

This example executes the 'gen_pilot_data.py' script on the interactive console.

curl --data-urlencode "code=`cat src/gen_pilot_data.py`" http://localhost:8079/_ah/admin/interactive/execute

Please notice that you may have to the change the port number.

Tuesday, December 14, 2010

Tuesday, November 30, 2010

is activemq running?

Activemq is listening on the 61616 port so a simple telnet can help us.

telnet localhost 61616

If you get a response that starts with '?ActiveMQ?' it means that activemq is running.

Simulating cellular network bandwith

To turn it on

sudo su
ipfw add pipe 1 src-port http
ipfw pipe 1 config delay 200 bw 700kbit/s


To reset

ipfw flush

Thursday, November 18, 2010

Changing the computer name on terminal


sudo scutil --set HostName [NewMacComputerName]

Next flush the DNS cache on the Mac by entering the command:

dscacheutil -flushcache