Git Ignore Global

Create a global .gitignore file to ignore common pains:

vim ~/.gitignore_global

.DS_Store* Icon? Thumbs.db

git config --global core.excl

...continue to full essay.

Posted 01/04/2012


Execute commands on remote server via ssh

Ever want to non interactively execute commands on a remote server?

ssh breckyunits.com 'df -h'

...continue to full essay.

Posted 11/07/2011


Cool Way to Duplicate a Finder Window in the Current Directory

Sometimes I want to rearrange a directory. An easy way to do it is to use Cinch and have 2 windows side by side. It's a pain to open 2 windows to the

...continue to full essay.

Posted 10/14/2011


Great Overview of Linux Command Line

Just read an awesome overview of the command line.

...continue to full essay.

Posted 10/11/2011


Find big files in Linux

How to find files larger than a certain size:

find /etc -size +100k

Disk free space:

du

...continue to full essay.

Posted 10/06/2011


ack and ackmate

So one common problem I have is writing code at a macro level---refactoring things in multiple files. Notepad++ used to make this easy with it's fast

...continue to full essay.

Posted 09/26/2011


nohup and disown

Just read a good guide on how to keep commands running when you exit ssh:

Disown, nohup : Bash Commands.

Basically:

nohup ./mycommand &

...continue to full essay.

Posted 09/22/2011


New shortcuts

Gmail:

gi - go to inbox c - compose j/k - go up and down, enter go to a page. gt - go to sent

Mac: ctrl+a - home/start of line ctrl+e - end

...continue to full essay.

Posted 09/15/2011


Apache, SSL and self signed certificates

Just read an excellent guide about how to create self-signed certificates.

Here's what it boils down to:

The cool thing about SSL is it's just

...continue to full essay.

Posted 09/14/2011


EC2 Command Line Tools

Step 1. Download them. http://aws.amazon.com/developertools/351

Step 2. Set Java path in your .bash_profile:

export JAVA_HOME=/System/Library/

...continue to full essay.

Posted 09/13/2011


zip a directory in linux

zip -r backup mydir/

zip -r backup .

...continue to full essay.

Posted 09/09/2011


Recursive Sed

As far as I can tell, sed doesn't have a recursive mode. Here's a little script that uses perl to simulate a recursive sed:

!/bin/bash

perl -

...continue to full essay.

Posted 09/05/2011


netstat

Every wonder what's listening on what ports?

netstat -lp

...continue to full essay.

Posted 09/01/2011


Bash History

Understanding and mastering bash history can:

  1. Save you a lot of time, keystrokes, and errors.
  2. Allow you to easily create shell scripts for c
...continue to full essay.

Posted 08/17/2011


Amazing SSH Tricks

Just read an article that contains some amazing SSH tricks.

...continue to full essay.

Posted 08/16/2011


ngrep for packet monitoring

I just came across a neat command line tool, ngrep, via this site.

Sample usage:

ngrep -q -W byline "^(GET|POST) .*"

...continue to full essay.

Posted 08/13/2011


Basic Linux Monitoring

Show memory usage:

free -m

Add this to your bash_profile:

alias free="free -m"

top

Show all processes

ps -a

Disk free spa

...continue to full essay.

Posted 08/09/2011


Creating a bootable Linux USB disk on Mac

hdiutil convert -format UDRW -o ~/path/to/new.img ~/path/to/source.iso

...continue to full essay.

Posted 08/08/2011


Notepad++ HAML Syntax Highlighting and other custom extension mapping

I want my HAML files to have PHP(or Ruby) syntax highlighting.

Settings > Style Configurator

Then click php and under "user ext" (in the bottom

...continue to full essay.

Posted 08/03/2011


Mac Terminal Cursor Trick

If you hold the "option" key while using the Mac terminal you can use your mouse and click on where you want the cursor to go. This comes in handy if

...continue to full essay.

Posted 08/03/2011


Apache Conf and Htaccess Examples

Configuring Apache can be a pain. I'm going to try and collect links to great resources. The official docs are good, but they really need to add comme

...continue to full essay.

Posted 07/30/2011


Fix for "selinux 3.82" stuck while installing Ubuntu from USB Drive

If you are installing Ubuntu from USB and are getting stuck at the "SELINUX 3.82" screen, you'll need to edit the selinux/selinux.cnf file on the USB

...continue to full essay.

Posted 07/27/2011


My Programming Setup

Here's my setup. This is kind of for my reference but you can also check it out if you're interested.

...continue to full essay.

Posted 06/30/2011


What Happens When you Open a 1.7 GB text file?

I downloaded the Verisign Master .com TLD zone file which weighs in at a hefty 1.7 GB. What happens when I open it with different programs on my Windo

...continue to full essay.

Posted 06/27/2011


Wildcard Subdomains with GoDaddy

Just create a new A Record with * as the host and your IP in the points to field.

...continue to full essay.

Posted 05/24/2011


Quickly Set up a Web Proxy Server

Sometimes when abroad it becomes necessary to route your internet traffic through a proxy.

Here's a great article that shows how: http://articles.

...continue to full essay.

Posted 04/13/2011


A few new Tricks in Notepad++

I've been on the road for a few months programming on a Windows 7 Samsung netbook. (I didn't want to bring the Macbook with me and risk breaking it or

...continue to full essay.

Posted 04/12/2011


RVM Quick Reference

Return to the Mac OS X default Ruby install:

rvm system

Switch to Ruby 1.9.2:

rvm 1.9.2

Create a new gemset:

rvm gemset create ra

...continue to full essay.

Posted 01/12/2011


Forward a port on a remote server to your local machine with an SSH Reverse Tunnel

Say you are running a web server locally and want to show it to someone else remotely.

You have a few ways to do this:

  1. Provide your local IP
...continue to full essay.

Posted 01/04/2011


Features I Miss from Notepad++ in Textmate

Here are a few things I really miss from Notepad++:

...continue to full essay.

Posted 11/16/2010


Git ignore a file that's in the repo

Let's say you've got a file that's checked in like environment.rb that you want to edit for your local machine only and don't want to push the changes

...continue to full essay.

Posted 11/03/2010


Adjusting to a Mac

For the third time in my life I've gotten a Macbook. The previous two times I returned them. I'm hoping the third time is a charm.

After a week I'm

...continue to full essay.

Posted 11/02/2010


Remove all DS_Store files recursively

find . -type f -name ".DS_Store" -exec rm {} \;

...continue to full essay.

Posted 10/29/2010


Windows 7 Hosts File

The file is located at:

windows/system32/drivers/etc/host

Mac hosts file:

/private/etc/hosts

...continue to full essay.

Posted 09/14/2010


Rubyful Soup

I was a big fan of BeautifulSoup in Python and was excited to see a Ruby port(http://www.crummy.com/software/RubyfulSoup/).

Sadly it's no longer

...continue to full essay.

Posted 09/14/2010


VIM and Rails

Check out this guide.

filetype on " Automatically detect file types. set nocompatible " We don't want vi compatibility.

" Add recently access

...continue to full essay.

Posted 09/13/2010


PHPUnit Filter Option

Say you are running PHPUnit from the command line and want to run just a specific test as opposed to a whole class of tests.

For example, say you h

...continue to full essay.

Posted 09/10/2010


Kill a Detached Rails Webrick Server

From your rails app's root:

cat tmp/pids/server.pid

kill -9 {pid}

...continue to full essay.

Posted 09/09/2010


Cygwin SSH Client Keep Alive

Add this to your /etc/defaults/etc/ssh_config file to prevent SSH servers from disconnecting you after inactivity:

ServerAliveInterval 60

...continue to full essay.

Posted 09/06/2010


A Pretty Picture

body { margin: 0px; padding: 0px; text-align:right; } div { height: 1px; width:1px; display:inline-block; }

...continue to full essay.

Posted 09/04/2010


Augmented Gitignore

.bundle db/.sqlite3 log/*.log *.log tmp/**/* tmp/* doc/api doc/app *.swp *~ .DS_Store

Source

...continue to full essay.

Posted 09/04/2010


Windows Flush DNS

Open cmd.exe.

Run:

ipconfig /flushdns

...continue to full essay.

Posted 07/30/2010


Insert a line of text to the top of a file

If you have a massive text file you want to add a line to without opening the file, here's a quick solution:

sed -e '1i\text_to_insert' -i file.t

...continue to full essay.

Posted 06/29/2010


wget don't save file

wget -O /dev/null http://address.com

...continue to full essay.

Posted 04/27/2010


ls color scheme

found this helpful color scheme for ls. toss in your bash_profile.

alias ls="ls --color=auto" LS_COLORS="di=31;1:ln=36;1:ex=31;1:~=31;1:.html=

...continue to full essay.

Posted 04/10/2010


Dump MySQL schema only

I found this command to dump just the schema.

mysqldump -u root -pmypassword test_database --no-data=true --add-drop-table=false > test_dump.sql

...continue to full essay.

Posted 04/10/2010


gca alias for faster git

One of my most frequent commands is:

git commit -am "message"

I made a simple alias to save keystrokes:

alias gca="git commit -am "

...continue to full essay.

Posted 04/10/2010


Recursive ls

Add the -R option to ls to recursively list the contents of a directroy.

...continue to full essay.

Posted 04/10/2010


vim macros

Let's say you want to add comments to your php functions following the conventional format:

/** * Returns the sum of 2 variables. * * @param int

...continue to full essay.

Posted 04/10/2010


pwd while in a symlink directory

to get the actual directory, run:

/bin/pwd

...continue to full essay.

Posted 04/01/2010


Case sensitivity in MySQL table names and lower_case_table_names

On linux, filenames and directories are case sensitive. file and File are different files.

On Windows, filenames are not case sensitive. file and F

...continue to full essay.

Posted 03/27/2010


ANSI or ASCII and Unicode or UTF-8 and Newlines

The key things you need to know:

ANSI (aka ASCII) and UTF-8 (aka "UnicodeTransformation Format" or just "Unicode") are ways to encode text files in

...continue to full essay.

Posted 03/25/2010


The BASH Programming Language

I used to use Python, Ruby or even PHP to write backend programs that would automate things like server management tasks, development and editing task

...continue to full essay.

Posted 03/25/2010


Cygwin Error: Could not resolve hostname X: Non-recoverable failure in name resolution

I've been getting this error a lot in Cygwin on Windows 7:

Could not resolve hostname X: Non-recoverable failure in name resolution

It happens

...continue to full essay.

Posted 03/22/2010


Plugins for Notepad++

Notepad++ is my go to editor.

The default plugins are great, but if you need more just visit the notepad++ plugins list.

To install a plugin:

...continue to full essay.

Posted 03/06/2010


More tips on using rsync to deploy your website

My post on deploying a website using rsync has gotten quite a few hits.

I thought I'd add some more tips:

...continue to full essay.

Posted 03/03/2010


Linux Go Back to Previous Directory

Just type:

cd -

To go back to the last directory you were in. Basically an "undo" for the cd command.

...continue to full essay.

Posted 03/01/2010


Should your source code be in one folder or should it be nested?

There are two ways to organize source code files for a project: flat or nested.

Here's a simple example of a flat structure(1 directory, 4 files):

...continue to full essay.

Posted 02/25/2010


Bug Workaround for JS Charts Error: Not enough data to display chart

If you get this alert using JSCharts, here's a quick hack to fix it:

nullData = new Array( ); myChart.setDataArray(nullData,"null");

Add th

...continue to full essay.

Posted 02/16/2010


Change the file owner or group in Linux

Change the owner of a file or folder:

chown newowner filename

Change the group of a file or folder:

chgrp newgroup filenameorfoldername

...continue to full essay.

Posted 02/09/2010


How to load a sql file into MySql

It's very simple thanks to pipes.

mysql -u username -p < sqlfile.sql

Make sure your sql file has a "use database" line.

...continue to full essay.

Posted 02/06/2010


Shortcut for switching to a Windows directory in Cygwin

In cygwin it can be a pain to change to a Windows directory like C:\Users\breck\Documents\My Dropbox.

I made a small bash script called wcd tha

...continue to full essay.

Posted 02/01/2010


Cygwin treats the Windows Clipboard like a file

In Linux every thing is a file. This is great because it means the Windows clipboard is a file too!

Want to copy the current cygwin directory into

...continue to full essay.

Posted 01/30/2010


New tricks in Vim

I learned some new tricks with vim today.

4G - Move to line #4

mb - Mark the current spot as point b 'b - Go back to point b

vim fil

...continue to full essay.

Posted 01/29/2010


Use cat to combine or print the contents of a file

Print the contents of a file:

cat filename.txt

Pipe the contents of the file to less, so you can view it one page at a time:

cat filename

...continue to full essay.

Posted 01/26/2010


Pipes, standard output and standard input

In linux, standard input refers to the stream of bits that come from your keyboard.

Standard output refers to the stream of bits that appear on you

...continue to full essay.

Posted 01/26/2010


Run multiple commands at once

Want to know how to run two or more linux commands sequentially? It's simple: use the semicolon ;.

For instance:

cd;ls

This will change the

...continue to full essay.

Posted 01/26/2010


The only 5 git commands you need to know

What's the difference between a great programmer who acts cool around girls and a great programmer who does not use version control?

Nothing--they

...continue to full essay.

Posted 01/23/2010


Use scp to download a file from a server

You can easily grab a file off a server from the command line using secure copy:

scp user@domain.com:/home/user/fileyouwant.txt fileyouwant.txt

...continue to full essay.

Posted 01/21/2010


Clear screen in cygwin

Just hit ctrl+l

...continue to full essay.

Posted 01/20/2010


Use sed to find and replace

grep is to find what sed is to replace.

Say you noticed a few typos in a file. Say you typed imposible instead of impossible a few times in a file

...continue to full essay.

Posted 01/20/2010


Unix date command

Display the current unix timestamp:

date +%s

Handy way to view it from the command line.

...continue to full essay.

Posted 01/19/2010


Bash variables

$ FIVE=5 $ echo $FIVE 5 $ echo "The number five is $FIVE"

Variable scope

A shell script will launch a new shell that has a fresh scope.

...continue to full essay.

Posted 01/18/2010


How to fix an overwhelmed Gmail Accout

I have used the same Gmail address as my main email for over 5 years.

Since then:

I've made dozens of other emails that forward to this address. I'

...continue to full essay.

Posted 01/17/2010


Seven aliases that can save you time

Add these to your .bash_profile to speed up common tasks:

alias apr='sudo ./usr/sbin/apachectl restart' # restart apache alias www='cd /var/www/ht

...continue to full essay.

Posted 01/13/2010


List only directories using ls

the "ls" command lists all files and directories. What if you just wanted to list the directories?

ls -l | egrep '^d'

Add this to your .bash_profile

...continue to full essay.

Posted 01/13/2010


Turn off bell in cygwin

The beep on tab completion in cygwin can be annoying. Here's how to turn it off:

vim ~/.inputrc

(Then add or uncomment this line)

set bell-style no

...continue to full essay.

Posted 01/11/2010


git clone without history

If you're using a library from git in another project, you may want to download it without the history. Here's how:

git clone --depth 1 your_repo_url

...continue to full essay.

Posted 01/11/2010


Learn Symbolic Links in 30 seconds

Symbolic links are simple and can save you time.

Here's all you need to know:

ln -s actual_file_or_directory new_symbolic_link_name

Let's do a real

...continue to full essay.

Posted 01/05/2010


Create a new user in Linux

Creating a new user in Linux is dead simple.

useradd bob

passwd bob

This adds a user "bob" and then prompts you to enter a password.

...continue to full essay.

Posted 01/05/2010


Use aliases to save time

Using aliases in Linux can save you a lot of time. Here's an example:

alias www='cd /var/www/html/'

Instead of typing "cd /var/www/html/" to enter y

...continue to full essay.

Posted 12/28/2009


How I organize my Dropbox

Gmail encourages users to "search not sort". I do that.

Email works great for search. For files though, sorting is often better.

I have well over 20

...continue to full essay.

Posted 12/27/2009


Use git to get the latest source code only

Say you want to get just the source code of a git repository without all the history(without the ".git" directory). Use this:

git clone --depth 1 git

...continue to full essay.

Posted 12/27/2009


What non-web software do you use the most?

Here are the programs I use everyday, every week, and every month.

What software do you use the most? What are your "must haves"?

My Machines

My p

...continue to full essay.

Posted 12/26/2009


Fix permission problems using chmod

Permission problems driving you crazy? Here's a common command to fix them:

chmod -R 755 directoryname

Change the file permissions of all directorie

...continue to full essay.

Posted 12/25/2009


Use the linux find command to find files

Say you're looking for all files starting with the word "breck". Using the linux "find" command, it's simple:

find -name "breck*"

Will search the cu

...continue to full essay.

Posted 12/25/2009


cron in 2 steps

cron lets you schedule linux commands to execute on a regular basis.

For instance, say we want to run the command "wget http://yourdomain.com/backup.

...continue to full essay.

Posted 12/25/2009


Use grep to search multiple files at once

grep lets you search through multiple text files at once.

I recently removed a feature from a project and wanted to make sure I removed all referen

...continue to full essay.

Posted 12/22/2009


Use rsync to deploy your website

rsync is a nifty little tool that can deploy a website to a testing or production server.

Here's a one line command to deploy brecksblog:

rsyn

...continue to full essay.

Posted 12/21/2009


SSH into your server without a password

On your server:

vim /etc/ssh/sshd_config

Make sure allow rsa and the other RSA lines are uncommented

service sshd restart

Make sure the fi

...continue to full essay.

Posted 12/20/2009


Get VIM Working in Cygwin

I had trouble getting VIM behaving as expected under Cygwin.

Specifically, the backspace and arrow keys were behaving badly in insert mode.

The solu

...continue to full essay.

Posted 12/20/2009


About this Blog

I constantly want to share little coding tidbits, snippets, or stories on how to solve specific little coding problems. Instead of clogging up the mai

...continue to full essay.

Posted 12/18/2009