Skip to content

Instantly share code, notes, and snippets.

View neagle's full-sized avatar

Nate Eagle neagle

View GitHub Profile
@neagle
neagle / prevent-orphans
Created November 15, 2012 20:49
Prevent Orphans in Text with Jekyll (Liquid)
<h2><a class="title" href="{{ post.url }}">
{% assign titleWords = post.title | split:&nbsp; %}
{% for word in titleWords %}{% if forloop.last %}&nbsp;{% else %} {% endif %}{{ word }}{% endfor %}
</a></h2>
#!/usr/bin/env node
var convert = require('color-convert');
var OPC = new require('../fadecandy/examples/node/opc')
var client = new OPC('localhost', 7890);
// This is set in the CAVA config file
const bars = 100;
const frame = [];
@neagle
neagle / cava_ascii_output_parser.js
Created May 28, 2020 21:35
This is just a quick example of how to use the raw ASCII output from CAVA in an application
// A minimal set of NodeJS code for parsing incoming ASCII data from CAVA and turning it into useful data.
// This code would need to have cava's output piped to it:
// Ex: $ cava -p ~/.config/cava/raw | node cava_ascii_output_parser.js
process.stdin.setEncoding('utf8');
let str = '';
process.stdin.on('readable', () => {
let chunk;
" _
" ___ __ _ __ _| | ___
" / _ \/ _` |/ _` | |/ _ \
"| __/ (_| | (_| | | __/
" \___|\__,_|\__, |_|\___|
" |___/
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@neagle
neagle / index.js
Last active February 8, 2016 04:20
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var mongoose = require('mongoose');
var _ = require('lodash');
// Set up a Schema with some required elements, and a field with an array
var ThingSchema = new mongoose.Schema({
name: {
type: String,
required: true
@neagle
neagle / build.js
Last active January 12, 2016 15:19
A simple custom Grunt task to build a group of targets for a task based on a prefix. This allows for easy grouping, based on namespace.
/**
* Build a group of targets based on a prefix
*
* Ex: grunt build:less:debug
*
* This would run all less targets that begin with "debug_":
* debug_web
* debug_sidebar
* debug_self_help
* debug_self_help_theme
define([], function () {
var Wiser = window.Wiser || {};
if (typeof Wiser === 'object') {
Wiser.utils = Wiser.utils || {};
if (typeof Wiser.utils === 'object') {
/* WiserTogether Utility Functions
*
*/
@neagle
neagle / Array.prototype.indexOf()
Created February 27, 2012 22:00
Shim for Array.prototype.indexOf()
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
    for (var i = (start || 0), j = this.length; i < j; i++) {
        if (this[i] === obj) { return i; }
      }
      return -1;
}
}
// Totally intolerable
var express = require('express')
, routes = require('./routes')
, http = require('http');
// Better
var express = require('express'),
routes = require('./routes'),
http = require('http');
================================================================================
Error executing action `start` on resource 'service[postfix]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /sbin/service postfix start ----
STDOUT: Starting postfix: [FAILED]