Skip to content

Instantly share code, notes, and snippets.

View drewgates's full-sized avatar

Drew Gates drewgates

View GitHub Profile
@drewgates
drewgates / drew.ga.conf
Created February 25, 2017 19:37
apache vhost config example
<VirtualHost *:80>
ServerName drew.ga
ServerAdmin webmaster@localhost
DocumentRoot /var/www/drew.ga
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
@drewgates
drewgates / sonoff-espbasic-switch-simple
Last active February 10, 2017 00:37
Sonoff ESPBasic Switch Simple Control
cls
let OutputPin = 6
let LedPin = 13
let PinStatus = 1
let status = "off"
button "Toggle", [Toggle]
textbox status
interrupt 0, [Button]
wait
@drewgates
drewgates / index.html
Created November 1, 2016 21:33
jMgebV
<html>
<body>
<div>
<span id="console-prompt">> </span>
<span class="console"></span>
</div>
</body>
</html>

Keybase proof

I hereby claim:

  • I am drewgates on github.
  • I am drewga (https://keybase.io/drewga) on keybase.
  • I have a public key ASDA7mxV4J4axgHqJTuzBZQYz6Vp5F5AB5RuDi9Lfi3iDQo

To claim this, I am signing this object:

@drewgates
drewgates / prepend_to_filename_cp.sh
Created September 16, 2016 14:10
Prepend a string "nt_" to the name every file of a type ".jpg" in a directory.
#for each .jpg in this directory, make a copy with "nt_" prepended to the file name (ex. "cp example.jpg nt_example.jpg")
FILES=*.jpg
for f in $FILES
do
cp "$f" "nt_$f"
done
@drewgates
drewgates / send_email.php
Last active November 30, 2016 09:52
Send email with mailgun.
<?php
//from email can be set in the relevant curl_setopt below.
//for my purposes, I was always using the same from email and didn't need one more variable to pass into this function.
//
function send_mail($email,$subject,$msg,$mailDomain,$api) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, 'api:'.$api_key);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
@drewgates
drewgates / change_url.php
Created July 25, 2016 02:52
php script to split and rewrite a URL
<?php
myURL = 'blogs/1/2/all-blogs';
fragments = myURL.split('/');
//don't need to touch fragments[0], because we want it to stay 'blogs'
fragments[1] = 3;
fragments[2] = 8;
fragments[3] = "whatever";
newURL = fragments.join('/');
//newURL is now set to '/blogs/3/8/whatever'
?>
<iframe class="embed-responsive-item"
+ src="http://player.twitch.tv/?channel=CHANNEL_USERNAME_HERE"
+ height="200"
+ width="350"
+ frameborder="0"
+ scrolling="no"
+ muted="true"
+ autoplay=false
+ allowfullscreen>
+ </iframe>
@drewgates
drewgates / savechanges.sh
Created March 23, 2016 10:41
very simple backup script
#!/bin/bash
# Very Simple Backup Script.
# Place this script in your project folder, and use chmod +x to make it executable.
# Either run manual backups periodically with ./savechanges.sh or set up a cron job to automate.
# Enjoy!
NOW=$(date +%Y%b%d-%H_%M)
echo "backing up"
date
tar -zcf ~/streamwhus-changes-$NOW.tar.gz ./*