This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p /home/zach/domains/website.com/{public,logs} | |
nano /home/zach/domains/website.com/public/index.html | |
server { | |
listen 80; | |
server_name www.website.com; | |
rewrite ^/(.*) http://website.com/$1 permanent; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Please note that if you want to install for root only, using a per-user install, then you must prepopulate root's $HOME/.rvmrc with the following BEFORE you attempt to install: | |
echo 'export rvm_prefix="$HOME"' > /root/.rvmrc | |
echo 'export rvm_path="$HOME/.rvm"' >> /root/.rvmrc | |
This overrides the checking done that assumes that if root is executing the install it must be a Multi-User installation type, and that RVM must go into /usr/local/rvm. This also negates the need to use sudo, as the combination of all these factors effectively turns it into a Per-User installation type specifically for the root user only. Please note that this is not a typical, or generally supported installation type. | |
Install RVM | |
curl -L https://get.rvm.io | sudo bash -s stable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SearchEngineReferrerMiddleware(object): | |
""" | |
Usage example: | |
============== | |
{% if request.session.search_engine %} | |
You searched for {{ request.session.search_term }} using {{ request.session.search_engine }}. | |
{% endif %} | |
""" | |
SEARCH_PARAMS = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// REQUIRED PARAMETERS | |
$status = 'http://www.mylink.com'; | |
$email = '[email protected]'; | |
$pass = 'yourpassw0rd'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Commands to backup a website from root access to ssh with mysql database | |
cd to directory of website | |
# Compress | |
tar czf filename.tar.gz * | |
mysqldump -u root -ppassword databasename | gzip -9 > filename.sql.gz | |
# Decompress | |
tar xzf filename.tar.gz | |
gunzip filename.sql.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a method to using your Ubuntu 12.04 server without the Unity desktop on a very fast remote desktop program. This is by far the best method to managing your Ubuntu server if you like GUI. | |
apt-get install --no-install-recommends ubuntu-desktop | |
apt-get --yes purge unity unity-2d unity-2d-places unity-2d-panel unity-2d-spread | |
apt-get --yes purge unity-asset-pool unity-services unity-lens-* unity-scope-* | |
apt-get --yes purge liboverlay-scrollbar* | |
apt-get --yes purge appmenu-gtk appmenu-gtk3 appmenu-qt | |
apt-get --yes purge firefox-globalmenu thunderbird-globalmenu | |
apt-get --yes purge unity-2d-common unity-common | |
apt-get --yes purge libunity-misc4 libunity-core-5* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: you-app-name-here | |
version: 1 | |
runtime: python | |
api_version: 1 | |
default_expiration: "30d" | |
handlers: | |
- url: /(.*\.(appcache|manifest)) | |
mime_type: text/cache-manifest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
audio | |
files | |
files/index.html | |
flash | |
fonts | |
images | |
javascript | |
stylesheets | |
videos | |
app.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. If a method can be static, declare it static. Speed improvement is by a factor of 4. | |
2. echo is faster than print. | |
3. Set the maxvalue for your for-loops before and not in the loop. | |
4. Unset your variables to free memory, especially large arrays. | |
5. Avoid magic like __get, __set, __autoload | |
6. require_once() is expensive | |
7. Use full paths in includes and requires, less time spent on resolving the OS paths. | |
8. If you need to find out the time when the script started executing, $_SERVER['REQUEST_TIME'] is preferred to time() | |
9. See if you can use strncasecmp, strpbrk and stripos instead of regex | |
10. str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql -u root -p | |
CREATE DATABASE testing; | |
GRANT ALL PRIVILEGES ON testing.* TO test_user@localhost IDENTIFIED BY 'test_pass'; | |
FLUSH PRIVILEGES; |