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.Execute commands on remote server via ssh
Ever want to non interactively execute commands on a remote server?
...continue to full essay.ssh breckyunits.com 'df -h'
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.Great Overview of Linux Command Line
Find big files in Linux
How to find files larger than a certain size:
find /etc -size +100k
Disk free space:
...continue to full essay.du
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.nohup and disown
Just read a good guide on how to keep commands running when you exit ssh:
Disown, nohup : Bash Commands.
Basically:
...continue to full essay.nohup ./mycommand &
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.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.EC2 Command Line Tools
Step 1. Download them. http://aws.amazon.com/developertools/351
Step 2. Set Java path in your .bash_profile:
...continue to full essay.export JAVA_HOME=/System/Library/
zip a directory in linux
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:
...continue to full essay.!/bin/bash
perl -
netstat
Every wonder what's listening on what ports?
...continue to full essay.netstat -lp
Bash History
Understanding and mastering bash history can:
- Save you a lot of time, keystrokes, and errors.
- Allow you to easily create shell scripts for c
Amazing SSH Tricks
Just read an article that contains some amazing SSH tricks.
...continue to full essay.ngrep for packet monitoring
I just came across a neat command line tool, ngrep, via this site.
Sample usage:
...continue to full essay.ngrep -q -W byline "^(GET|POST) .*"
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.Creating a bootable Linux USB disk on Mac
- Download the ISO
- Convert iso to img on terminal:
hdiutil convert -format UDRW -o ~/path/to/new.img ~/path/to/source.iso
- Open Disk Utili
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.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.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.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.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.
- Macbook Air. 4GB. 256GB HD.
- VMWare Fusio
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.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.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.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.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:
...continue to full essay.rvm gemset create ra
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:
- Provide your local IP
Features I Miss from Notepad++ in Textmate
Here are a few things I really miss from Notepad++:
- When you doubleclick a word in Notepad++, all occurrences of that word are highlighted in gre
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.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.Remove all DS_Store files recursively
Windows 7 Hosts File
The file is located at:
windows/system32/drivers/etc/host
Mac hosts file:
...continue to full essay./private/etc/hosts
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.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.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.Kill a Detached Rails Webrick Server
From your rails app's root:
...continue to full essay.cat tmp/pids/server.pid
kill -9 {pid}
Cygwin SSH Client Keep Alive
Add this to your /etc/defaults/etc/ssh_config file to prevent SSH servers from disconnecting you after inactivity:
...continue to full essay.ServerAliveInterval 60
A Pretty Picture
body { margin: 0px; padding: 0px; text-align:right; } div { height: 1px; width:1px; display:inline-block; }
...continue to full essay.Augmented Gitignore
.bundle db/.sqlite3 log/*.log *.log tmp/**/* tmp/* doc/api doc/app *.swp *~ .DS_Store
Source
...continue to full essay.Windows Flush DNS
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:
...continue to full essay.sed -e '1i\text_to_insert' -i file.t
wget don't save file
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.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.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.Recursive ls
Add the -R option to ls to recursively list the contents of a directroy.
...continue to full essay.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.pwd while in a symlink directory
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.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.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.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.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.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:
- use the "--delete" option if you wan
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.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.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.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:
...continue to full essay.chgrp newgroup filenameorfoldername
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.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
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.New tricks in Vim
I learned some new tricks with vim today.
...continue to full essay.4G - Move to line #4
mb - Mark the current spot as point b 'b - Go back to point b
vim fil
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:
...continue to full essay.cat filename
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.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.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.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.Clear screen in cygwin
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.Unix date command
Display the current unix timestamp:
date +%s
Handy way to view it from the command line.
...continue to full essay.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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:
...continue to full essay.rsyn
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.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.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.