Skip to content

Instantly share code, notes, and snippets.

View samdoidge's full-sized avatar

Sam Doidge samdoidge

View GitHub Profile
@samdoidge
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
var buttons = document.getElementsByClassName('button-class');
for(var i = 0; i < buttons.length; i++)
buttons[i].click();
/*
* 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 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 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 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
samdoidge / gist:2912c4b4e8690e79097f
Created May 19, 2014 12:29
If CodeIgniter gives 'No input file specified'
check permissions on folder - chown'ing to plesk user
@samdoidge
samdoidge / gist:fb880394887490b7ea4d
Last active August 29, 2015 14:01
locate: can not open `/var/lib/mlocate/mlocate.db': No such file or directory
run
sudo updated
to fix
@samdoidge
samdoidge / gist:0594a8429d2ded5094f2
Created May 7, 2014 03:22
.htaccess remove www
<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 April 28, 2014 13:21
Copy without SVN files
rsync -avzr --exclude=.svn /dir/ /dir-copy/
@samdoidge
samdoidge / grep-exclude-file-extension
Created October 11, 2013 10:50
grep exclude file extension, recursively search through current directory
grep -r --exclude '*.sql' 'search string' .
@samdoidge
samdoidge / grep-file-extension
Last active December 25, 2015 06:29
grep recursively through the current folder with a specific file extension
grep -r --include="*.php" "search string" .