Textmate + WordPress = Love

Blogging solely within the confines of WordPress and its wysiwyg editor is horrible.

However,

Using the below items, you can really get moving.

Below is a screen shot of what it took to write this post.

Wordpress Textmate Bundle

Oh yea, it only takes a “cmd + ^ + P” key stroke to update and publish.

How to remove a submodule in git

  1. Delete the relevant line from the .gitmodules file.
  2. Delete the relevant section from .git/config.
  3. Run git rm –cached pathtosubmodule (no trailing slash).
  4. Commit and delete the now untracked submodule files.

Install APC on OSX Snow Leopared

  1. sudo pear update-channels
  2. brew install pcre
  3. sudo pecl install apc-3.1.6
  4. Edit php.ini
    1. extension=apc.so
    2. apc.enabled=1
    3. apc.shm_segments=1
    4. apc.shm_size=32M
    5. apc.cache_by_default=1
    6. apc.stat=1
    7. apc.rfc1867=1 //For upload progress.
    8. apc.stat=7200 //2 hours

Git Ignore .DS_Store on OSX

Execute the below to prevent .DS_Store from ever being included in any of your git repose.

git config --global core.excludesfile ~/.gitignore

echo .DS_Store >> ~/.gitignore

Redirect domain.com to www.domain.com in .htaccess or virtual host file

Just Add:

RewriteEngine on RewriteCond %{HTTPHOST} !^www.domain.com [NC] RewriteCond %{HTTPHOST} !^$ RewriteRule ^/?(.*) http://www.domian.com/$1 [L,R=301,NE]

Setting up a Rackspace Cloud Server & Ubuntu Karmic Koala

First Things First:

  1. Signup with Rackspace cloud: http://www.rackspacecloud.com/
  2. Create Server
    1. Choose Linux Version
    2. Choose server needs & name server
  3. You will receive a phone call and an Email will be sent to you with your server password and ip address.
  4. Test SSH Login:
    1. on a mac: run terminal
      1. ssh root@youripaddress
      2. then type in the password they gave you
  5. Start by updating your systems package manager.
    1. sudo apt-get update
    2. supo apt-get upgrade
    3. Answer yes to the additional space question.

Installing Git on Westhost & Redhat

  1. Install Python using your web installs
  2. download the latest source from git
  3. make NO_CURL=1 NO_MSGFMT=YesPlease NO_TCLTK=YesPlease prefix=/usr/local install
  4. That should do it.

Setting up Apache & SSL on OSX Leapord

Task:
Configure my localhost & apache to allow for ssl.
Resources
  • http://shiningthrough.co.uk/Setting-up-an-SSL-enabled-Apache-development-server-using-Phusion-Passenger-on-OS-X-Snow-Leopard
  • http://www.modssl.org/
  • http://www.entropy.ch/software/macosx/docs/mod_ssl.html
Solution:
  • Go here: http://developer.apple.com/internet/serverside/modssl.html
  • Note: when asked for “Common Name” when creating your certificate file, instead of using the 127.0.0.1 use the domain name
    you are going to use for development. ie: www.mysite.local

    # This is the Apache server configuration file providing SSL support.
    # It contains the configuration directives to instruct the server how to
    # serve pages over an https connection. For detailing information about these
    # directives see
    #
    # Do NOT simply read the instructions in here without understanding
    # what they do.  They're here only as hints or reminders.  If you are unsure
    # consult the online docs. You have been warned.
    
    # Pseudo Random Number Generator (PRNG):
    # Configure one or more sources to seed the PRNG of the SSL library.
    # The seed data should be of good random quality.
    # WARNING! On some platforms /dev/random blocks if not enough entropy
    # is available. This means you then cannot use the /dev/random device
    # because it would lead to very long connection times (as long as
    # it requires to make more entropy available). But usually those
    # platforms additionally provide a /dev/urandom device which doesn't
    # block. So, if available, use this one instead. Read the mod_ssl User
    # Manual for more details.
    #
    #SSLRandomSeed startup file:/dev/random  512
    #SSLRandomSeed startup file:/dev/urandom 512
    #SSLRandomSeed connect file:/dev/random  512
    #SSLRandomSeed connect file:/dev/urandom 512
    
    #
    # When we also provide SSL we have to listen to the
    # standard HTTP port (see above) and to the HTTPS port
    #
    # Note: Configurations that use IPv6 but not IPv4-mapped addresses need two
    #       Listen directives: "Listen [::]:443" and "Listen 0.0.0.0:443"
    #
    Listen 443
    NameVirtualHost *:443
    
    ##
    ##  SSL Global Context
    ##
    ##  All SSL configuration in this context applies both to
    ##  the main server and all SSL-enabled virtual hosts.
    ##
    
    #
    #   Some MIME-types for downloading Certificates and CRLs
    #
    AddType application/x-x509-ca-cert .crt
    AddType application/x-pkcs7-crl    .crl
    
    #   Pass Phrase Dialog:
    #   Configure the pass phrase gathering process.
    #   The filtering dialog program (`builtin' is a internal
    #   terminal dialog) has to provide the pass phrase on stdout.
    SSLPassPhraseDialog  builtin
    
    #   Inter-Process Session Cache:
    #   Configure the SSL Session Cache: First the mechanism
    #   to use and second the expiring timeout (in seconds).
    #SSLSessionCache         "dbm:/private/var/run/ssl_scache"
    SSLSessionCache        "shmcb:/private/var/run/ssl_scache(512000)"
    SSLSessionCacheTimeout  300
    
    #   Semaphore:
    #   Configure the path to the mutual exclusion semaphore the
    #   SSL engine uses internally for inter-process synchronization.
    SSLMutex  "file:/private/var/run/ssl_mutex"
    
    ##
    ## SSL Virtual Host Context
    ##
    ServerName www.mysite.local
    ServerAlias www.mysite.local
    #   General setup for the virtual host
    DocumentRoot "/Users/markevans/Sites/www.mysite.com"
    ServerAdmin mark@mysite.com
    
    ErrorLog "/Users/markevans/Sites/logs/www.mysite.com/error_log"
    CustomLog "/Users/markevans/Sites/logs/www.mysite.com/ssl_request_log" \
    "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile /Users/markevans/Sites/sslcerts/www.mysite.com/server.crt
    SSLCertificateKeyFile /Users/markevans/Sites/sslcerts/www.mysite.com/server.key
    
  • Handy Degbugging Command lines

  • sudo apachectl configtest
  • http -S

Single .htaccess file in your git repo for both your dev and production server

Problem:

You want to have dev.yoursite.com and www.yoursite.com but you don’t want dev.yoursite.com visible to the public.

Solution:

If your using apache(which many of us are),

.htaccess and .htpasswd to the rescue.

In your .htaccess file add:

SetEnvIf Host yourstagingserver.com passreq AuthType Basic AuthName “Staging Server” AuthUserFile /path/to/.htpasswd Require valid-user Order allow,deny Allow from all Deny from env=passreq Satisfy any

Configure your password file on both dev & production

Wherever you specify the /path/to/.htpasswd file navigate to that folder from the console and type “htpasswd -c .htpasswd mark”   where mark is the first user you want to create a login for. For each additonal person type “htpasswd .htpasswd linda”  where linda is the next username you want to add to the .htpasswd file. Each time  it will  prompt you to type in the password twice.(your password will be stored in the .htpasswd file) encrypted next to the username you created.

*Note:

AuthUserFile expects an absolute path, but if you don't start your path with a forward slash, it defaults to the directory you specify in your httpd.conf file as ServerRoot.

Country Codes in PHP Array

A PHP array list of all of the countries.
$options["AF"] = "Afghanistan";  
$options["AX"] = "Åland Islands";  
$options["AL"] = "Albania ";  
$options["DZ"] = "Algeria ";  
$options["AS"] = "American Samoa";  
$options["AD"] = "Andorra";  
$options["AO"] = "Angola ";
$options["AI"] = "Anguilla ";
$options["AQ"] = "Antarctica ";
$options["AG"] = "Antigua and Barbuda ";
$options["AR"] = "Argentina";
$options["AU"] = "Australia ";
$options["AT"] = "Austria ";
$options["AZ"] = "Azerbaijan";
$options["BS"] = "Bahamas ";
$options["BH"] = "Bahrain ";
$options["BD"] = "Bangladesh ";
$options["BB"] = "Barbados ";
$options["BY"] = "Belarus";
$options["BE"] = "Belgium ";
$options["BZ"] = "Belize ";
$options["BJ"] = "Benin ";
$options["BM"] = "Bermuda ";
$options["BT"] = "Bhutan";
$options["BO"] = "Bolivia ";
$options["BA"] = "Bosnia and Herzegovina ";
$options["BW"] = "Botswana ";
$options["BV"] = "Bouvet Island ";
$options["BR"] = "Brazil";
$options["IO"] = "British Indian Ocean Territory ";
$options["BN"] = "Brunei Darussalam ";
$options["BG"] = "Bulgaria ";
$options["BF"] = "Burkina Faso ";
$options["BI"] = "Burundi";
$options["KH"] = "Cambodia ";
$options["CM"] = "Cameroon ";
$options["CA"] = "Canada ";
$options["CV"] = "Cape Verde ";
$options["KY"] = "Cayman Islands ";
$options["CF"] = "Central African Republic ";
$options["TD"] = "Chad ";
$options["CL"] = "Chile ";
$options["CN"] = "China ";
$options["CX"] = "Christmas Island";
$options["CC"] = "Cocos (Keeling) Islands ";
$options["CO"] = "Colombia ";
$options["KM"] = "Comoros ";
$options["CG"] = "Congo ";
$options["CD"] = "Congo, the Democratic Republic of the";
$options["CK"] = "Cook Islands ";
$options["CR"] = "Costa Rica ";
$options["CI"] = "Côte D'Ivoire";
$options["HR"] = "Croatia ";
$options["CU"] = "Cuba ";
$options["CY"] = "Cyprus ";
$options["CZ"] = "Czech Republic ";
$options["DK"] = "Denmark";
$options["DJ"] = "Djibouti ";
$options["DM"] = "Dominica ";
$options["DO"] = "Dominican Republic ";
$options["EC"] = "Ecuador ";
$options["EG"] = "Egypt";
$options["SV"] = "El Salvador ";
$options["GQ"] = "Equatorial Guinea ";
$options["ER"] = "Eritrea ";
$options["EE"] = "Estonia ";
$options["ET"] = "Ethiopia ";
$options["FK"] = "Falkland Islands (Malvinas) ";
$options["FO"] = "Faroe Islands ";
$options["FJ"] = "Fiji ";
$options["FI"] = "Finland ";
$options["FR"] = "France";
$options["GF"] = "French Guiana ";
$options["PF"] = "French Polynesia ";
$options["TF"] = "French Southern Territories ";
$options["GA"] = "Gabon ";
$options["GM"] = "Gambia ";
$options["GE"] = "Georgia ";
$options["DE"] = "Germany ";
$options["GH"] = "Ghana ";
$options["GI"] = "Gibraltar ";
$options["GR"] = "Greece";
$options["GL"] = "Greenland ";
$options["GD"] = "Grenada ";
$options["GP"] = "Guadeloupe ";
$options["GU"] = "Guam ";
$options["GT"] = "Guatemala";
$options["GG"] = "Guernsey ";
$options["GN"] = "Guinea ";
$options["GW"] = "Guinea-Bissau ";
$options["GY"] = "Guyana ";
$options["HT"] = "Haiti";
$options["HM"] = "Heard Island and Mcdonald Islands ";
$options["VA"] = "Holy See (Vatican City State) ";
$options["HN"] = "Honduras ";
$options["HK"] = "Hong Kong ";
$options["HU"] = "Hungary";
$options["IS"] = "Iceland ";
$options["IN"] = "India ";
$options["ID"] = "Indonesia ";
$options["IR"] = "Iran, Islamic Republic of ";
$options["IQ"] = "Iraq ";
$options["IE"] = "Ireland ";
$options["IM"] = "Isle of Man ";
$options["IL"] = "Israel ";
$options["IT"] = "Italy ";
$options["JM"] = "Jamaica";
$options["JP"] = "Japan ";
$options["JE"] = "Jersey ";
$options["JO"] = "Jordan ";
$options["KZ"] = "Kazakhstan ";
$options["KE"] = "KENYA";
$options["KI"] = "Kiribati ";
$options["KP"] = "Korea, Democratic People's Republic of ";
$options["KR"] = "Korea, Republic of ";
$options["KW"] = "Kuwait ";
$options["KG"] = "Kyrgyzstan";
$options["LA"] = "Lao People's Democratic Republic ";
$options["LV"] = "Latvia ";
$options["LB"] = "Lebanon ";
$options["LS"] = "Lesotho ";
$options["LR"] = "Liberia";
$options["LY"] = "Libyan Arab Jamahiriya ";
$options["LI"] = "Liechtenstein ";
$options["LT"] = "Lithuania ";
$options["LU"] = "Luxembourg ";
$options["MO"] = "Macao";
$options["MK"] = "Macedonia, the Former Yugoslav Republic of ";
$options["MG"] = "Madagascar ";
$options["MW"] = "Malawi ";
$options["MY"] = "Malaysia ";
$options["MV"] = "Maldives";
$options["ML"] = "Mali ";
$options["MT"] = "Malta ";
$options["MH"] = "Marshall Islands ";
$options["MQ"] = "Martinique ";
$options["MR"] = "Mauritania";
$options["MU"] = "Mauritius ";
$options["YT"] = "Mayotte ";
$options["MX"] = "Mexico ";
$options["FM"] = "Micronesia, Federated States of ";
$options["MD"] = "Moldova, Republic of";
$options["MC"] = "Monaco ";
$options["MN"] = "Mongolia ";
$options["ME"] = "Montenegro ";
$options["MS"] = "Montserrat ";
$options["MA"] = "Morocco";
$options["MZ"] = "Mozambique ";
$options["MM"] = "Myanmar ";
$options["NA"] = "Namibia ";
$options["NR"] = "Nauru ";
$options["NP"] = "Nepal";
$options["NL"] = "Netherlands ";
$options["AN"] = "Netherlands Antilles ";
$options["NC"] = "New Caledonia ";
$options["NZ"] = "New Zealand ";
$options["NI"] = "Nicaragua";
$options["NE"] = "Niger ";
$options["NG"] = "Nigeria ";
$options["NU"] = "Niue ";
$options["NF"] = "Norfolk Island ";
$options["MP"] = "Northern Mariana Islands";
$options["NO"] = "Norway ";
$options["OM"] = "Oman ";
$options["PK"] = "Pakistan ";
$options["PW"] = "Palau ";
$options["PS"] = "Palestinian Territory, Occupied";
$options["PA"] = "Panama ";
$options["PG"] = "Papua New Guinea ";
$options["PY"] = "Paraguay ";
$options["PE"] = "Peru ";
$options["PH"] = "Philippines";
$options["PN"] = "Pitcairn ";
$options["PL"] = "Poland ";
$options["PT"] = "Portugal ";
$options["PR"] = "Puerto Rico ";
$options["QA"] = "Qatar";
$options["RE"] = "Réunion ";
$options["RO"] = "Romania ";
$options["RU"] = "Russian Federation ";
$options["RW"] = "Rwanda ";
$options["SH"] = "Saint Helena";
$options["KN"] = "Saint Kitts and Nevis ";
$options["LC"] = "Saint Lucia ";
$options["PM"] = "Saint Pierre and Miquelon ";
$options["VC"] = "Saint Vincent and the Grenadines ";
$options["WS"] = "Samoa";
$options["SM"] = "San Marino ";
$options["ST"] = "Sao Tome and Principe ";
$options["SA"] = "Saudi Arabia ";
$options["SN"] = "Senegal ";
$options["RS"] = "Serbia";
$options["SC"] = "Seychelles ";
$options["SL"] = "Sierra Leone ";
$options["SG"] = "Singapore ";
$options["SK"] = "Slovakia ";
$options["SI"] = "Slovenia";
$options["SB"] = "Solomon Islands ";
$options["SO"] = "Somalia ";
$options["ZA"] = "South Africa ";
$options["GS"] = "South Georgia and the South Sandwich Islands ";
$options["ES"] = "Spain";
$options["LK"] = "Sri Lanka ";
$options["SD"] = "Sudan ";
$options["SR"] = "Suriname ";
$options["SJ"] = "Svalbard and Jan Mayen ";
$options["SZ"] = "Swaziland";
$options["SE"] = "Sweden ";
$options["CH"] = "Switzerland ";
$options["SY"] = "Syrian Arab Republic ";
$options["TW"] = "Taiwan, Province of China ";
$options["TJ"] = "Tajikistan";
$options["TZ"] = "Tanzania, United Republic of ";
$options["TH"] = "Thailand ";
$options["TL"] = "Timor-Leste ";
$options["TG"] = "Togo ";
$options["TK"] = "Tokelau";
$options["TO"] = "Tonga ";
$options["TT"] = "Trinidad and Tobago ";
$options["TN"] = "Tunisia ";
$options["TR"] = "Turkey ";
$options["TM"] = "Turkmenistan";
$options["TC"] = "Turks and Caicos Islands ";
$options["TV"] = "Tuvalu ";
$options["UG"] = "Uganda ";
$options["UA"] = "Ukraine ";
$options["AE"] = "United Arab Emirates";
$options["GB"] = "United Kingdom ";
$options["US"] = "United States ";
$options["UM"] = "United States Minor Outlying Islands ";
$options["UY"] = "Uruguay ";
$options["UZ"] = "Uzbekistan";
$options["VU"] = "Vanuatu ";
$options["VA"] = "Vatican City State ";
$options["VE"] = "Venezuela ";
$options["VN"] = "Viet Nam ";
$options["VG"] = "Virgin Islands, British ";
$options["VI"] = "Virgin Islands, U.S. ";
$options["WF"] = "Wallis and Futuna";
$options["EH"] = "Western Sahara ";
$options["YE"] = "Yemen ";
$options["CD"] = "Zaire ";
$options["ZM"] = "Zambia ";
$options["ZW"] = "Zimbabwe ";