Skip to content

Instantly share code, notes, and snippets.

View Depicus's full-sized avatar
🏠
Working from home

Brian Slack Depicus

🏠
Working from home
View GitHub Profile
@Depicus
Depicus / check website is up.php
Created December 26, 2014 14:27
Quick (unfinished) script that I run on my PI at home to check sites are up.
<?php
date_default_timezone_set('Europe/London');
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: donotreply@depicus.com (Depicus Site Monitor)' . "\r\n" .
@Depicus
Depicus / java to slack.java
Created December 26, 2014 13:29
Sending Slack hook from Java
private static void sendSlackMessage(String message)
{
String url = "https://hooks.slack.com/services/your-token-here";
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(url);
JSONObject json = new JSONObject();
try {
json.put("channel", "#general");
json.put("text", message);
json.put("username", "#java-error-bot");
@Depicus
Depicus / console log in ie.js
Created December 26, 2014 13:15
Allow Windows IE to use console log.
<script type="text/javascript">
if (!window.console) console = {log: function() {}};
</script>
@Depicus
Depicus / php to slack.php
Created December 26, 2014 13:13
PHP function to send a message to Slack
function sendSlackMessage($text, $username = "PHP Error Bot", $channel = "#general")
{
$url = "https://hooks.slack.com/services/your-token-here";
$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
Depicus / ubuntu login screen
Last active August 29, 2015 14:12
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 :)
#add the ip address to the pre login screen by editing rc.local
/sbin/ifconfig | grep "inet addr" | grep -v "127.0.0.1" | awk '{ print $2 }' | awk -F: '{ print "ip address " $2 }' > /$}' > /etc/issue