Skip to content

Instantly share code, notes, and snippets.

View designfrontier's full-sized avatar

Daniel Sellers designfrontier

View GitHub Profile
// abs.js
const FILES = require('fs');
module.exports = {
absorb: (htmlPath) => {
let html = FILES.readFileSync(htmlPath, 'utf8');
html = html.replace(/(<absorb\s(.+)\/>)/g, function(absorbElement) {
let filePath = '', fileType = '', jsMod = '';
if (absorbElement.indexOf('css=') >= 0) {
writeln("setting up server...")
server := HttpServer clone do(
setPort(8090)
renderResponse := method(request, response,
list("path", "uri", "body") foreach(k,
v := request perform(k)
response body appendSeq(k .. ": " .. v .. "<br>")
)
const ajax = require('utils/ajax');
const Promise = require('Promise');
/*
* The queue itself...
*
* @param {String} retryConut The number of times that it should retry a request
* before it gives up and rejects it.
*
* @return {object}
@designfrontier
designfrontier / queue.js
Last active May 12, 2016 15:57
pseudo-ish code change queue
const saveQueue = [
slide,
slide1,
slide2,
slide
];
const attemptedSlides = {};
const running = false;
@designfrontier
designfrontier / getCurrentBG.js
Last active January 12, 2016 17:17
get Background color
getComputedBG = function (elem) {
var rtn = window.getComputedStyle(elem)['background-color'],
element = elem,
isTransparent = function (color) {
return color === 'rgba(0, 0, 0, 0)' || color === 'transparent'
};
while (element !== null && isClear(rtn)) {
element = element.parentElement;
rtn = window.getComputedStyle(element)['background-color'];
@designfrontier
designfrontier / gist:8029846
Created December 18, 2013 21:07
creates a 200 char summary with html tags intact
var createSummary = function(str){
var str = str
//tag replacement stuff
, tagRegex = /<[^>]*>?/g
, markerRegexGlobal = /~/g
, markerRegex = /~/
, marker = '~'
//other vars that we will need
, refString = str.replace(tagRegex, marker) //replace out tags
, i = 0
@designfrontier
designfrontier / compressed version
Last active December 25, 2015 15:39
line length marker now with Jquery inclusion built in
javascript:!function(){var a=document.createElement("script"),b=function(){var a=$("p"),b=0,c="",d="";for(b=0;b<a.length;b++)c=$(a[b]).text(),d=c.slice(0,45)+"*"+c.slice(45,70)+"*"+c.slice(70),$(a[b]).text(d)};a.src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js",document.getElementsByTagName("head")[0].appendChild(a),setTimeout(b,500)}();
@designfrontier
designfrontier / gist:4495292
Created January 9, 2013 18:00
Some nasty and fascinating JS recursion or your viewing pleasure. Paste in web inspectors js console and then work your way down through the arrays...
t = ['john'];
c = ['daniel','joe'];
t.push(c);
c.push(t);
c;
@designfrontier
designfrontier / app.js
Created December 1, 2015 18:59
return a 500 error for all requests
var http = require('http');
var server = http.createServer(function (req, res) {
console.log(req.url);
if (req.url !== '/api/presence' && req.url !== '/api/heartbeat') {
res.statusCode = 500;
res.end('error');
} else {
res.end('works');
}
@designfrontier
designfrontier / post-checkout
Last active November 26, 2015 00:06
post-commit hook for clearing node_modules
#!/bin/sh
rm -rf node_modules/
npm install