Skip to content

Instantly share code, notes, and snippets.

View edwardteach42's full-sized avatar

Edward Teach edwardteach42

View GitHub Profile
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@edwardteach42
edwardteach42 / .gitignore
Created January 11, 2012 22:58 — forked from miles/.gitignore
Augmented .gitignore for Rails in Aptana
.bundle
.settings
.project
db/*.sqlite3*
log/*.log
*.log
tmp/**/*
tmp/*
doc/api
doc/app
@edwardteach42
edwardteach42 / .htaccess
Created January 18, 2012 16:32
Redirecting non-www to www with .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
@edwardteach42
edwardteach42 / gist:1685193
Created January 26, 2012 21:22
Get Number of Followers on Twitter
/**
* Get Number of Twitter Followers
*
* LICENSE: distributions of the source code without
* authors permission is forbidden, For written
* permission please contact jeffmthomas@gmail.com.
*
* Can also use the following to pull with $getData:
* id
* name
@edwardteach42
edwardteach42 / gist:1685210
Created January 26, 2012 21:25
Get Number of Likes for a URL
https://api.facebook.com/method/fql.query?query=SELECT%20like_count%20FROM%20link_stat%20WHERE%20url=%22http://www.example.com%22
@edwardteach42
edwardteach42 / gist:1719597
Created February 1, 2012 21:33
Store Array to Database field as CSV
<?php
$array = array('value1', 'value2', 'value3');
$comma_separated = implode(",", $array);
print $comma_separated; // value1,value2,value3
//when you pull it back out, explode it, and then you will have your array!
?>
@edwardteach42
edwardteach42 / gist:1725285
Created February 2, 2012 19:33
Insert After XX Number of Rows - PHP
<?php
$i = 1;
while ($x < 17){
echo 'Data ' . $i . '<br>';
//Change Value to how many rows you want to insert after.
if( ($i % 3) == 0 ){
echo 'Snippet of text--<br>';
}
@edwardteach42
edwardteach42 / gist:1975320
Last active October 1, 2015 10:37
Host a git repository on Amazon EC2
Set Up CentOS Server
Use Rightscale CentOS Community Server Image ami-09496d4c
*****AS ROOT*****
$ yum update
$ yum install git mysql mysql-libs httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-mcrypt
$ echo 'service httpd restart' >> /etc/rc.local
$ ssh-keygen -t rsa -C "email@example.com"
$ useradd git
$ passwd git
$ cd /home/git
@edwardteach42
edwardteach42 / gist:2911422
Created June 11, 2012 17:23
List all $_POST's as Variables in PHP
foreach ( $_POST as $key => $value ){
echo '$' . $key . ' = $_POST[\'' . $key . '\'];<br />';
}
@edwardteach42
edwardteach42 / gist:4560435
Created January 17, 2013 22:28
Set Up a CentOS Server on EC2 with Git Deployment

#CentOS Server on EC2 with Git Deployment


##Use Rightscale CentOS Community Server Image ami-09496d4c

###Step 1: SSH into the server and do the following

BE SURE YOU PERFORM THESE ACTIONS AS ROOT OR SU

$ yum update

$ yum install git mysql mysql-libs httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-mcrypt