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/html/

...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