Skip to content

Instantly share code, notes, and snippets.

@quawn
quawn / sorter.js
Last active January 4, 2016 03:19
JS: Sort a list alphabetically
$(function() {
$.fn.sortList = function() {
var mylist = $(this);
var listitems = $('li', mylist).get();
listitems.sort(function(a, b) {
var compA = $(a).text().toUpperCase();
var compB = $(b).text().toUpperCase();
return (compA < compB) ? -1 : 1;
});
$.each(listitems, function(i, itm) {
@quawn
quawn / slack_notification.php
Last active September 9, 2015 14:03 — forked from alexstone/slack_notification.php
Fire a Slack Notification via CURL
<?php
// (string) $message - message to be passed to Slack
// (string) $room - room in which to write the message, too
// (string) $icon - You can set up custom emoji icons to use with each message
public static function slack($message, $room = "engineering", $icon = ":longbox:") {
$room = ($room) ? $room : "engineering";
$data = "payload=" . json_encode(array(
"channel" => "#{$room}",
"text" => $message,
@quawn
quawn / snippet.php
Last active September 15, 2015 20:17
Slack notification with attachment
<?php
// Source: http://blog.eddokloosterman.com/2015/09/useful-slack-notifications-for-developers/
private function _notifySlackChannel($success)
{
$attachment = new stdClass();
$attachment->fallback = "Build tests ". ($success == true? "passed" : "failed") . " for last '" . $this->_testType . "' build";
$attachment->title = "Last '" . $this->_testType . "' build " . ($success == true? "OK" : "failed" );
$attachment->text = "Check <http://tfs_url/tfs/DefaultCollection/RoosterWeb/_build|build log> for more details";
$attachment->color = $success == true? "good" : "danger" ;
$params = array(