Skip to content

Instantly share code, notes, and snippets.

Working from home

depicus Depicus

Working from home
View GitHub Profile
Depicus / ubuntu login screen
Last active Aug 29, 2015
If you run a lot of VMs and you look at the login and wonder what the ip address is to ssh in. Because sometimes the VM console is .... fun :)
View ubuntu login screen
#add the ip address to the pre login screen by editing rc.local
/sbin/ifconfig | grep "inet addr" | grep -v "" | awk '{ print $2 }' | awk -F: '{ print "ip address " $2 }' > /$}' > /etc/issue
Depicus / php to slack.php
Created Dec 26, 2014
PHP function to send a message to Slack
View php to slack.php
function sendSlackMessage($text, $username = "PHP Error Bot", $channel = "#general")
$url = "";
$payload = array();
$payload["username"] = $username; // you can customise this
$payload["channel"] = $channel;
$payload["text"] = $text;
// set up & post curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
Depicus / console log in ie.js
Created Dec 26, 2014
Allow Windows IE to use console log.
View console log in ie.js
<script type="text/javascript">
if (!window.console) console = {log: function() {}};
Depicus / interfaces
Created Dec 26, 2014
Network config for Ubuntu servers because I can never remember :)
View interfaces
# The primary network interface
auto eth0
iface eth0 inet static
Depicus / gravatar.php
Created Dec 26, 2014
Use Gravatar avatars from php
View gravatar.php
$email = md5(strtolower(""));
$gravatar = "$email?d=404&s=50";
$headers = get_headers($gravatar,1);
if (strpos($headers[0],'200')) echo "<img src='$gravatar' style='border-radius: 25px;'>"; // OK
else if (strpos($headers[0],'404')) echo "No Gravatar"; // Not found we could show a default image here
Depicus / check website is up.php
Created Dec 26, 2014
Quick (unfinished) script that I run on my PI at home to check sites are up.
View check website is up.php
function sendmail($site,$contacts,$name,$date)
$to = $contacts;
$subject = 'Alert ' . $site . ' appears to be down - ' . $name;
$message = $site . ' is down, please check now ' .$date;
$headers = 'From: (Depicus Site Monitor)' . "\r\n" .
Depicus /
Last active Aug 29, 2015
iptables setup
sudo iptables -F
sudo iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT
sudo iptables -A INPUT -i eth0 -j DROP
sudo apt-get install iptables-persistent -y
sudo dpkg-reconfigure iptables-persistent
Depicus /
Created Jan 10, 2015
Snippet to set param in logback.xml
try {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator jc = new JoranConfigurator();
context.putProperty("WorkStationID", dateWeAreSendingFor);
ClassLoader loader = main.class.getClassLoader();
} catch (JoranException ex) {
logger.error("init logging failed", ex);
Depicus / gumby-icons.css
Created Jan 13, 2015
Working (for me) copy of just the icon section for Gumby
View gumby-icons.css
@charset "UTF-8";
.icon-note.icon-left a:before, .icon-note.icon-right a:after { content: "\266a"; height: inherit; }
i.icon-note:before { content: "\266a"; height: inherit; }
.icon-note-beamed.icon-left a:before, .icon-note-beamed.icon-right a:after { content: "\266b"; height: inherit; }
i.icon-note-beamed:before { content: "\266b"; height: inherit; }
Depicus / wol-for-asp
Last active Aug 29, 2015
Wake on Lan code for use in an ASP application
View wol-for-asp
set WakeOnLan = server.createobject("DigitalWol.Wol")
You can’t perform that action at this time.