plog
plog - project+log CMS
Behold, a blog to document the process of installing archlinux. Arch will be sharing the drive with Windows 7, so for the sake of completion, I'll make a note of how to set up a dual boot with the GRUB bootloader. I'll be installing both OS's from scratch, starting with Windows.
I installed Windows 7 from a USB stick using Microsoft's Windows 7 USB/DVD tool. You'll need a computer running Windows 7 already to do this. I booted with the USB drive, and installed Windows on the entire 100GB drive with a single partition. Once installed, via Start Menu > Administrative Tools > Computer Management > Disk Manamagent, select 'Shrink Partition' on the main Windows parition to create another partition for Arch. The default value for the shrink is 50%, so for my setup the value for the new disk size was ~50GB, and that's fine.
Note about this install. I have an old Linksys (Cysco) WMP54G Wireless PCI Card. Strangely, all the drivers from Linksys/Cysco's website didn't work, but following this blog post, the generic RALink drivers worked great.
I downloading the Core Image via torrent from http://www.archlinux.org/download/. This ISO includes all core packages so the system doesn't need to be online to install.
Once downloaded, I followed my notes on how to create a bootable ISO onto another USB drive with yet another machine. There are also numerous free tools available to make a bootable ISO on Windows. After booting into Arch with the USB stick, boot into Arch, and type:
/arch/setup
The installation article on the archwiki is an excellent resource.
It's pretty straight forward until the drive partitions. My 100GB drive can only support 4 logical partitions, so the rest have to be Logical. Note: The numbers are out of order, because I used Logical partitions for everything except for the Windows partitions and /home. Logical partitions end up being counted last in the partition table, but I made my /home folder LAST so I could use the up the remaining space on the drive. You'll also need to set the /boot partition's 'bootable' flag to true.
• sda1
Windows 7 System Reserved
• sda2
Windows 7
• sda5
/boot - 100MB is enough
• sda6
/ - about 25GB is appropriate
• sda7
swap - between 1024MB and 4096MB
• sda4
/home - use rest of hard drive
Some of these, namely boot, swap, and home, are optional.
At minimum, you'll need the core packages that are already selected. I also included certain key packages such as OpenSSH. Basically, include any packages you need for internet connectivity, as everything else will be updated from the net.
Configure system does multiple things, including setting the root password, network settings, and some other configuration tools. Here's a reference of where Arch installs all the base config files for the system.
/etc/rc.conf system config /etc/fstab filesystem mountpoints /etc/mkinitcpio.conf initramfs config /etc/modprobe.d/modprobe.conf kernel modules /etc/resolv.conf dns servers /etc/hosts network hosts /etc/locale.get glibc locals /etc/pacman.conf pacman.confg /etc/pacman.d/mirrorlist pacman mirror list
You should edit any of these files that are specific to your system. At minimum I enabled my network card in rc.conf.
You'll also need to enable at least one mirror in pacman.d/mirrorlist if you plan to update the system or download new packages.
Install Bootloader will install and help you configure the bootloader you selected in the Select Packages stage (GRUB, in my case). After double-checking your bootloader configuration, you'll be prompted for a disk to install the loader to. You should install GRUB to the MBR of the installation disk, in this case sda1.
Once installed, exit the installer, remove the USB, type reboot in the command line, and the system will reboot. If all went well, you should be dropped into a login screen where you can log in with root and the password you chose during install.
You can create new users interactively with adduser.
You can install/update packages with Arch's package manager, pacman.
Before installing any packages, sync the package list with:
pacman --sync --refresh
To add a new package (vim, in this case), type:
pacman -S vim
next: getting node and a webserver installed.
Working with various interfaces that output json or xml results in lots of situations where you have a single-line, unformatted output. Here's a quick way to format json, xml from the CLI.
via the command line:
format json
cat unformatted.json | python -m json.tool
format json from clipboard
pbpaste | python -m json.tool
format xml from clipboard
pbpaste | xmllint --format -
xmllint is part of libxml2 and installed by default on OSX. Be aware that xmllint cleans up XML as well as formatting it, ocassionally modifying the output.
for all above examples, you can pipe back to the clipboard with | pbcopy at the end of the command, or output to a file with > output.json or > output.xml.
Since there is no equivilent to /dev/dsp or /dev/audio on OSX, you need to install an alternative like sox.
Install sox by either downloading the OSX binary from http://sox.sourceforge.net/
or
install homebrew, and then install sox with brew install sox
cat audio from /dev/urandom/ :
cat /dev/urandom | sox -traw -r44100 -b16 -u - -tcoreaudio
audio from an executable
cat > test.c
main(t) {
for( t = 0;;t++)
putchar( t * ((( t >> 12 ) | (t >> 8)) & (63& (t >> 4 ))));
}
[ctrl-c]
gcc test.c -o test ./test | sox -traw -r8000 -b8 -u - -tcoreaudio
history | awk {'print $2'} | sort | uniq -c | sort -k1 -rn | head
example
// brand new netbook 24 ls 14 cd 12 defaults 9 unzip 8 ssh 5 mv 3 mkdir 3 chmod 3 cat 2 unrar
// quilime.com 173 git 140 ls 84 cd 18 emacs 15 cat 13 mv 12 rm 5 ln 4 mkdir 4 ./scripts/content
The default Cygwin install emulates a terminal in a command window similar to the DOS prompt with a limited feature set.
For a full featured x-term, you can install Cygwin-X along with Cygwin:
Install the following packages:
Optional Packages
~/.XDefaults
dark theme:
! terminal colors ------------------------------------------------------------ ! tangoesque scheme *background: #111111 *foreground: #babdb6 ! Black (not tango) + DarkGrey *color0: #000000 *color8: #555753 ! DarkRed + Red *color1: #ff6565 *color9: #ff8d8d ! DarkGreen + Green *color2: #93d44f *color10: #c8e7a8 ! DarkYellow + Yellow *color3: #eab93d *color11: #ffc123 ! DarkBlue + Blue *color4: #204a87 *color12: #3465a4 ! DarkMangenta + Mangenta *color5: #ce5c00 *color13: #f57900 !DarkCyan + Cyan (both not tango) *color6: #89b6e2 *color14: #46a4ff ! LightGrey + White *color7: #cccccc *color15: #ffffffSome more themes on the Arch forums.
~/.bashrc
To enable color ls and human readable size format, add:
alias ls='ls -h --color=tty'By default, the .bashrc in CygwinX has many options you can uncomment.
~/.emacs Disable emacs temp (~) file pooping
(setq make-backup-files nil)
Result:
Other emulators for Windows: - Terminator/
diskutil list
Determines the device node assigned to your flash media (e.g. /dev/disk2)
diskutil unmountDisk /dev/disk#
Replace # with the disk number from the last command; in the previous example, # is 2)
sudo dd if=/path/to/example.iso of=/dev/diskN bs=1m
Replace /path/to/example.iso with the path to the iso; for example: ./windows7.iso. After typing in your sudo password, the process will start invisibly.
diskutil eject /dev/disk#
Remove your flash media device when the command completes. Done!
Referenced from BurningIsoHowto
Bonus tip! You want to see how far the dd copy is coming along? Run in another terminal instance:
$ sudo killall -INFO dd
The process info will display in the original terminal.
via Terminal
show hidden files:
defaults write com.apple.finder AppleShowAllFiles TRUE killall Finder
hide hidden files:
defaults write com.apple.finder AppleShowAllFiles FALSE killall Finder
copy /b file1+ file2 output
eg
copy /b picture.jpg + archive.rar file.jpg
Open file.jpg with the default application, it will show the picture "picture.jpg". Change the extension to "file.rar" or if you try to open "file.jpg" with an archiver you will get the contents of "archive.rar".
ssh-keygen -t rsa // linux ssh-copy-id [user@]host // osx cat ~/.ssh/id_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys" eval `ssh-agent` ssh-add
alias ls='ls --color' export CLICOLOR=1 export LSCOLORS=gxFxCxDxBxgggdabagacad export EDITOR='emacs'
# color ls
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=GxFxCxDxBxegedabagacad
# minimal prompt
# export PS1="
# $PWD
# : "
# current git branch
export PS1="
\[\033[38m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]\`ruby -e \"
print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').
gsub(/^\* (.+)$/, '(\1) ')\"\`\[\033[37m\]
$\[\033[00m\] "
# aliases
alias ff="find . -type f -name "
for k in $(ls *.JPG); do convert $k -resize 50% -quality 80 r_$k; done
*.bat file structure
REM // .bat comment syntax C:\Progra~1\Autodesk\Maya2010\bin\render -s 1 -e 30 -im output_image myscene.ma C:\Progra~1\Autodesk\Maya2010\bin\render -s 1 -e 30 -im output_image2 anotherscene.ma
The path to render.exe must be the 8.3 character DOS version.
To execute the file, save as a *.bat and double click it in Explorer.
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
#!/bin/bash # Shell script to create file named after the current date # YYYY-MM-DD format DATE=$(date +%Y"-"%m"-"%d) echo -e "new file" > $DATE
ls | nl -nrz -w2 | while read a b; do mv "$b" filename.$a.png; done;
Function to return location of intersect with poly mesh and spherical object moving in the positive direction on the Y axis.
global proc intersectSphereY()
{
print(". . . . . go go go\n");
int $iter = 50;
float $start[3] = {0, -0.5, 0};
float $limit[3] = {0, 5.0, 0};
$mesh = "test_mesh";
$tmpCN = "cpom";
$obj = "rod1";
float $radius = 0.5;
float $curPos[3] = {0, 0, 0};
for ($i = 0; $i <= $iter; $i++)
{
$mesh = "test_mesh";
$shape = `listRelatives -shapes $mesh`;
createNode -n $tmpCN closestPointOnMesh;
connectAttr -f ($shape[0] + ".outMesh") ($tmpCN + ".inMesh");
setAttr ($tmpCN + ".inPosition") $curPos[0] $curPos[1] $curPos[2];
$cpom = `getAttr ($tmpCN + ".position")`;
if ( pointDist($curPos, $cpom) <= $radius ) {
return ". . bonk\n";
}
$curPos[1] = ($limit.y) / $iter * $i;
setAttr ($obj + ".translateY") $curPos[1];
delete $tmpCN;
}
return ". nope\n";
}
global proc float pointDist(float $p1[], float $p2[])
{
return sqrt(
(($p1[0] - $p2[0]) * ($p1[0] - $p2[0])) +
(($p1[1] - $p2[1]) * ($p1[1] - $p2[1])) +
(($p1[2] - $p2[2]) * ($p1[2] - $p2[2])));
}
intersectSphereY;

Shell script that slices a single image into any number of vertical and horizontal sections.
#!/bin/bash
#@author gabriel dunne <quilime.com>
IMAGE=$1
IMAGE_W=$2
IMAGE_H=$3
ROWS=$4
COLS=$5
if [ $# -eq 0 ]
then
echo "usage: image width height rows cols"
echo "example: ./slice.sh Sunset.jpg 800 600 16 16"
exit
else
for (( x = 1; x <= COLS; x++ ))
do
for (( y = 1 ; y <= ROWS; y++ ))
do
let CROP_X = `expr $IMAGE_W-IMAGE_W/$x`
let CROP_Y = `expr $IMAGE_H-IMAGE_H/$y`
let CROP_W = `expr $IMAGE_W/$ROWS`
let CROP_H = `expr $IMAGE_H/$COLS`
echo -n "crop ${CROP_W}x${CROP_H}+${CROP_X}+${CROP_Y} result: [${x},${y}]_$IMAGE"
echo ""
convert $IMAGE -crop ${CROP_W}x${CROP_H}+${CROP_X}+${CROP_Y} [${x},${y}]_$IMAGE
done
done
fi
navigate to slice.sh in your terminal and do
chmod +x slice.sh ./slice.sh Sunset.jpg 800 600 16 16replace Sunset.jpg with your image name.
process selection list
string $select[] = ls -sl;
for ( $node in $select ) // process each
{
/* ... */
}
if node exists
string $node = "object";
if ( objExists $node )
{
// The node exists
}
Strip component
string $node = "pCube1.f[2]";
string $no_component = match "^[^\.]*" $node;
// Result: "pCube1" //
Extract component or attribute, with '.'
string $node = "pCube1.f[2]"; string $component =match "\\..*" $node; // Result: ".f[2]" //string $nodeAttr = "blinn1.color"; string $attrName =
match "\\..*" $nodeAttr; // Result: ".color" //
Extract attribute name, without '.'
string $node = "pCube1.f[2]"; string $component = `substitute "^[^.]*\\." $node ""`; // Result: "f[2]" // string $nodeAttr = "blinn1.color"; string $attrName = `substitute "^[^.]*\\." $nodeAttr ""`; // Result: "color" //
Extract parent UI control from full path
string $uiControl = "OptionBoxWindow|formLayout52|formLayout55|button6";
string $uiParent = substitute "|[^|]*$" $uiControl "";
// Result: OptionBoxWindow|formLayout52|formLayout55 //
Strip trailing Line Break (\n), if any.
This is useful when processing text input read from a file using fgetline.
string $input = "line\n";
$string $line = match "^[^(\r\n)]*" $input;
// Result: "line" //
Extract directory from path.
Keep the trailing slash for ease of use.
string $path = "C:/AW/Maya5.0/bin/maya.exe";
string $dir = match "^.*/" $path;
// Result: "C:/AW/Maya5.0/bin/"
Extract file from path
string $path = "C:/AW/Maya5.0/bin/maya.exe";
string $filepart = match "[^/\\]*$" $path;
// Result: "maya.exe"
Strip numeric suffix
string $node = "pCube1|pCubeShape223"; string $noSuffix =
match ".*[^0-9]" $node; // Result: "pCube1|pCubeShape"
Extract numeric suffix
string $node = "pCube1|pCubeShape223";
string $suffix = match "[0-9]+$" $node;
// Result: "223" //
Extract short name of DAG or control path
string $dagPath = "pCube1|pCubeShape223";
string $shortName = match "[^|]*$" $dagPath;
// Result: pCubeShape223 //