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