Skip to content

Instantly share code, notes, and snippets.


Sam Doidge samdoidge

View GitHub Profile
samdoidge / click-all-buttons-matching-class-on-page.js
Created October 16, 2022 12:46
Click all buttons on a page matching a specific class name
View click-all-buttons-matching-class-on-page.js
var buttons = document.getElementsByClassName('button-class');
for(var i = 0; i < buttons.length; i++)
View Lazy load Disqus comments.js
* <div class="comments"></div>
var comments = document.getElementsByClassName('comments')[0],
disqusLoaded = false;
function loadDisqus() {
samdoidge /
Last active November 22, 2016 21:52
Setup a DigitalOcean LAMP 16.04 image ready for Laravel. Creates a swap file, generates ssh key, installs required packages and composer.
# Run with the following:
# curl -s | 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 /
Last active September 6, 2016 08:54
Recursively loop through a direcctory, cutting files down to 11 lines maximum - creating a new file of the same name in a Test folder.
for file in *; do head -n 11 "$file" > ../Test/"$file"; done
samdoidge / gist:2912c4b4e8690e79097f
Created May 19, 2014 12:29
If CodeIgniter gives 'No input file specified'
View gist:2912c4b4e8690e79097f
check permissions on folder - chown'ing to plesk user
samdoidge / gist:fb880394887490b7ea4d
Last active August 29, 2015 14:01
locate: can not open `/var/lib/mlocate/mlocate.db': No such file or directory
View gist:fb880394887490b7ea4d
sudo updated
to fix
samdoidge / gist:0594a8429d2ded5094f2
Created May 7, 2014 03:22
.htaccess remove www
View gist:0594a8429d2ded5094f2
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]
samdoidge / content
Created April 28, 2014 13:21
Copy without SVN files
View content
rsync -avzr --exclude=.svn /dir/ /dir-copy/
samdoidge / grep-exclude-file-extension
Created October 11, 2013 10:50
grep exclude file extension, recursively search through current directory
View grep-exclude-file-extension
grep -r --exclude '*.sql' 'search string' .
samdoidge / grep-file-extension
Last active December 25, 2015 06:29
grep recursively through the current folder with a specific file extension
View grep-file-extension
grep -r --include="*.php" "search string" .