Skip to content

Instantly share code, notes, and snippets.

View masiorama's full-sized avatar
🏠
Working from home

masiorama

🏠
Working from home
View GitHub Profile
@masiorama
masiorama / gist:4453266
Created January 4, 2013 15:07
GIT: add remote origin
cd existing_git_repo
git remote add origin git@github.com:user/repo.git
git push origin master
@masiorama
masiorama / gist:4453288
Created January 4, 2013 15:10
GIT: remove remote origin
git remote rm origin
@masiorama
masiorama / gist:4453370
Created January 4, 2013 15:19
PHP: create new Yii app via shell
path/to/php /wwwroot/yii/framework/yiic webapp /wwwroot/blog
@masiorama
masiorama / gist:4453442
Created January 4, 2013 15:27
JavaScript: frameTargetParent
if (window != window.top) {
/* inside the frame */
} else {
/* inside the parent */
}
@masiorama
masiorama / wp-query-ref.php
Created January 7, 2013 14:21 — forked from luetkemj/wp-query-ref.php
PHP: WP query reference
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@masiorama
masiorama / vhost.conf
Created January 8, 2013 08:48
Apache: skel virtual host global rewrite www to non-www
<Directory /var/www/vhosts/@domain_name@/httpdocs>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</Directory>
@masiorama
masiorama / gist:4484381
Created January 8, 2013 14:58
Apache: reconfigure vhosts
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain example.com
/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
@masiorama
masiorama / gist:4493414
Created January 9, 2013 14:14
RegExp: list of useful regular expressions
RegExpressions
(?<=<h1>).+(?=</h1>) #select che content inside the heading tag, or any html tag
@masiorama
masiorama / gist:4493819
Created January 9, 2013 15:07
Apache: set canonical urls for files insice .htaccess
#get all the pdfs and set a canonical url using the name of the file as pagename
RewriteRule ([^/]+)\.pdf$ - [E=FILENAME:$1]
<FilesMatch "\.pdf$">
Header add Link '<http://example.com/httest/%{FILENAME}e.html>; rel="canonical"'
</FilesMatch>
@masiorama
masiorama / gist:4493872
Created January 9, 2013 15:13
Apache: make files inside a dir unreachable with .htaccess
# inside .htaccess, all the files inside the dir unreachable to robots
Header set X-Robots-Tag "noindex, noarchive, nosnippet"