Skip to content

Instantly share code, notes, and snippets.

View c0bra's full-sized avatar

Brian Hann c0bra

View GitHub Profile
ADMIN="your-email@you.com"
# set alert level 90% is default
ALERT=90
df -H | grep -vE '^Filesystem|tmpfs|cdrom|^//|/mnt' | awk '{ print $5 " " $1 }' | while read output;
do
#echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $ALERT ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
@c0bra
c0bra / perldancer_wordcloud.pl
Created March 7, 2012 21:46
Make a wordcloud out of the testimonials of Dancer users
#!perl
use strict;
use warnings;
use Image::WordCloud;
use File::Slurp;
use LWP::Simple;
use HTML::Grabber;
@c0bra
c0bra / exchange.json
Created March 4, 2013 19:41
Docpad exchange.json with https:// skeleton repo urls
{
"skeletons": {
"HTML5 Boilerplate": {
"branch": "docpad-6.x",
"repo": "https://github.com/docpad/html5-boilerplate.docpad.git",
"description": "HTML5 Boilerplate skeleton for DocPad. Bare essentials for building a modern website with best practices."
},
"HTML5 Boilerplate with Grunt": {
"branch": "master",
"repo": "https://github.com/lukekarrys/html5-boilerplate.docpad.git",
var a = {'info' : 'testBuild'};
var b = {'info' : 'testBuild'};
a == b;
@c0bra
c0bra / gist:5568672
Last active December 17, 2015 06:49
<div ng-switch="user.type">
<div ng-switch-when="user" ng-include="/path/to/template.html" ng-controller="UserCtrl"></div>
<div ng-switch-when="professional" ng-include="/path/to/template.html" ng-controller="AdminProfessionalCtrl"></div>
</div>
@c0bra
c0bra / gist:5570879
Last active December 17, 2015 07:09
$scope.sections = Section.query({projectId: $scope.currentProject.id}, function(data) {
angular.forEach(data, function(section) {
$scope.$watch(section, function() {
section.$save();
}, true);
});
});
var chain = [serverRequest, undefined];
var dummyP = $q.defer();
var promise = dummyP.promise; // $q.when(config);
// apply interceptors
forEach(reversedInterceptors, function(interceptor) {
if (interceptor.request || interceptor.requestError) {
chain.unshift(interceptor.request, interceptor.requestError);
}
jade: {
build: {
options: {
pretty: true
},
files: [
{
expand: true,
src: '<%= src.jade %>',
cwd: 'src/',
@c0bra
c0bra / gist:7550460
Last active December 28, 2015 19:29
// Grunt task:
karma: {
unit: {
configFile: 'test/karma.config.js',
background: true
}
},
// test/karma.config.js
module.exports = function(config) {
/* js */
var app = angular.module('plunker', ['ngSanitize']);
app.controller('MainCtrl', function($scope, $sce) {
$scope.data = {};
$scope.val = $sce.trustAsHtml('🏠');
});