Skip to content

Instantly share code, notes, and snippets.

Avatar

Sam Doidge samdoidge

View GitHub Profile
View Lazy load Disqus comments.js
/*
* http://christian-fei.com/tutorials/how-to-lazy-load-disqus-comments/
*
* <div class="comments"></div>
*/
var comments = document.getElementsByClassName('comments')[0],
disqusLoaded = false;
function loadDisqus() {
@samdoidge
samdoidge / ubuntu-lamp-laravel-setup.sh
Last active Nov 22, 2016
Setup a DigitalOcean LAMP 16.04 image ready for Laravel. Creates a swap file, generates ssh key, installs required packages and composer.
View ubuntu-lamp-laravel-setup.sh
# Run with the following:
# curl -s https://gist.githubusercontent.com/samdoidge/55e4d3332448cc7f2f9a2cbe1124c247/raw/7c434cabc84a550dbdb95f2fa4c6ce129e70475a/ubuntu-lamp-laravel-setup.sh | bash -s 1g
# Last argument is swapfile size. 1g = 1 gigabyte.
set -e
sudo fallocate -l $1 /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
@samdoidge
samdoidge / recursively-cut-files.sh
Last active Sep 6, 2016
Recursively loop through a direcctory, cutting files down to 11 lines maximum - creating a new file of the same name in a Test folder.
View recursively-cut-files.sh
for file in *; do head -n 11 "$file" > ../Test/"$file"; done
@samdoidge
samdoidge / gist:2912c4b4e8690e79097f
Created May 19, 2014
If CodeIgniter gives 'No input file specified'
View gist:2912c4b4e8690e79097f
check permissions on folder - chown'ing to plesk user
@samdoidge
samdoidge / gist:fb880394887490b7ea4d
Last active Aug 29, 2015
locate: can not open `/var/lib/mlocate/mlocate.db': No such file or directory
View gist:fb880394887490b7ea4d
run
sudo updated
to fix
View gist:0594a8429d2ded5094f2
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.samdoidge.com$ [NC]
RewriteRule ^(.*)$ http://samdoidge.com/$1 [R=301,L]
</IfModule>
@samdoidge
samdoidge / content
Created Apr 28, 2014
Copy without SVN files
View content
rsync -avzr --exclude=.svn /dir/ /dir-copy/
@samdoidge
samdoidge / grep-exclude-file-extension
Created Oct 11, 2013
grep exclude file extension, recursively search through current directory
View grep-exclude-file-extension
grep -r --exclude '*.sql' 'search string' .
@samdoidge
samdoidge / grep-file-extension
Last active Dec 25, 2015
grep recursively through the current folder with a specific file extension
View grep-file-extension
grep -r --include="*.php" "search string" .