Skip to content

Instantly share code, notes, and snippets.

View jeffskelton3's full-sized avatar
:shipit:

Jeff Skelton jeffskelton3

:shipit:
View GitHub Profile
@jeffskelton3
jeffskelton3 / angularjs filter :: summaryText
Created August 25, 2014 21:01
a filter for summarizing large amounts of text down to a desired length
.filter('summaryText', function () {
return function (value, wordwise, max, tail) {
if (!value) return '';
max = parseInt(max, 10);
if (!max) return value;
if (value.length <= max) return value;
value = value.substr(0, max);
if (wordwise) {
@jeffskelton3
jeffskelton3 / csv.js
Created March 17, 2015 15:29
sails.js CSV response type
/**
* 200 (OK) CSV Response
*
* Usage:
* return res.csv(data);
*
* @param {Object} data
* - must be an object array
* @param {String|Object} options
* - columns : column names we want for the CSV must be a string array
@jeffskelton3
jeffskelton3 / index.html
Last active August 29, 2015 14:21
Simple timer (for a friend)
<button type='button'
id="startTimer"
class='btn btn-primary'>start timer</button>
<button type='button'
id='stopTimer'
class='btn btn-danger hide'>stop timer</button>
@jeffskelton3
jeffskelton3 / opacity.less
Created June 18, 2015 03:08
LESS opacity function
/*
description - a cross browser opactity function
usage example:
.my-class{
.opacity(.50);
}
@param: amount - expects a floating point decimal.
INSERT INTO `selective_search_groups` (`id`, `date_created`, `name`, `sequence`, `group_type`, `description`)
VALUES
(3, '2014-06-11 07:07:34', 'Moods', 4, 'and', NULL),
(4, '2014-06-11 07:06:52', 'Instruments', 5, 'and', NULL),
(5, '2014-06-11 07:09:15', 'Music Styles', 2, 'and', NULL),
(7, '2014-06-11 07:07:34', 'Time', 3, 'and', NULL),
(8, NULL, 'Genre', 1, 'and', NULL),
(9, '2014-06-11 07:07:34', 'Usages', 5, 'and', NULL),
(12, '2014-06-11 07:07:34', 'Time', 6, 'and', NULL);
@jeffskelton3
jeffskelton3 / deleteCookiesByPattern
Created July 16, 2015 16:52
takes a given wildcard string and deletes any cookies that contain it in the name
function deleteCookiesByPattern(pattern){
var cookies = document.cookie.split(';');
for(var i=0;i<=cookies.length;i++){
var ck = cookies[i];
if(/pattern/.test(ck)){
document.cookie = ck + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
}
}
}
@jeffskelton3
jeffskelton3 / ajaxRequest
Created July 30, 2015 21:37
a vanilla js ajax get request
function ajaxRequest(url, onSuccess, onError){
var xmlhttp = new XMLHttpRequest(),
response = null;
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if(xmlhttp.status == 200){
response = JSON.parse(xmlhttp.responseText);
onSuccess(response);
}
else {
app.use(function(req, res, next) {
var schema = req.headers['x-forwarded-proto'];
if (schema === 'https') {
next();
}
else {
res.redirect('https://' + req.headers.host + req.url);
}
});
@jeffskelton3
jeffskelton3 / fonts-importer.less
Created October 13, 2015 16:38
a reusable less mixing for importing web fonts. Assumes all files in the same directory and name exactly the same except for their respective extensions.
.import-font(@fileName, @filePath, @fontFamily){
@font-face {
font-family: @fontFamily;
src: url('@{filePath}@{fileName}.eot');
src: url('@{filePath}@{fileName}.eot?#iefix') format('embedded-opentype'),
url('@{filePath}@{fileName}.woff') format('woff'),
url('@{filePath}@{fileName}.ttf') format('truetype'),
url('@{filePath}@{fileName}.svg#@{fileName}') format('svg');
font-weight: normal;
font-style: normal;
@jeffskelton3
jeffskelton3 / wav2mp3.sh
Created December 28, 2015 21:06
converts all wav files in a directory to mp3.
find . -name "*.wav" -exec sh -c 'ffmpeg -i $(basename {}) $(basename {} | cut -f 1 -d '.').mp3' \;