This file contains 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
# redirects for url params | |
RewriteEngine On | |
RewriteRule ^([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1 | |
RewriteRule ^([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1 | |
RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1&subpage=$2 | |
RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1&subpage=$2 | |
# index file priority | |
DirectoryIndex index.html index.htm index.php welcome.html |
This file contains 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
# download stable Drupal | |
drush dl drupal | |
# install Drupal site with admin/admin acc | |
sudo drush site-install standard --account-name=admin --account-pass=admin --db-url=mysql://drupal7:drupal7@localhost/drupal7 | |
# clear drupal cache | |
drush cc | |
# download and enable module |
This file contains 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
(?<=start)(.*)(?=end) // lazy - it will select until LAST occurence | |
(?<=start)(.*?)(?=end) // not lazy - it will select until FIRST occurence |
This file contains 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
# undo commit and REVERT the files to the last HEAD | |
git reset --hard HEAD~1 | |
# undo commit but PRESERVE the files before the last commit | |
git reset HEAD~1 |
This file contains 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
// Works in modern browsers + IE9, but Modernizr has a polyfill baked in for function.bind. | |
// Hat tip Paul Irish | |
var o = $( {} ); | |
$.subscribe = o.on.bind(o); | |
$.unsubscribe = o.off.bind(o); | |
$.publish = o.trigger.bind(o); | |
// Usage | |
$(document.body).on( 'click', function() { |
This file contains 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
find . -not -perm 755 -type f -exec chmod 755 {} \; |
This file contains 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
find . -type f -exec ls -s {} \; | sort -n -r | head -10 |
This file contains 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
find . -name "*.html" -exec bash -c 'cp "{}" "$(dirname "{}")"/index.html' \; |
This file contains 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
#searches for 'search_term' and prints all columns | |
awk '/search_term/' file.txt | |
#searches for 'search_term' and prints columns 1 and 4 separated with tab (the first column is index 1) | |
awk '/search_term/ {print $1 "\t" $4}' file.txt | |
#searches for 'search_term' and prints the number of occurances | |
awk '/search_term/{++cnt} END {print "Count = ", cnt}' file.txt | |
#print lines having more than 18 characters |
This file contains 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
find ./ -path '*/images/*.png' -type f -exec pngquant -f --ext .png {} \; |
OlderNewer