Skip to content

Instantly share code, notes, and snippets.

@sshadmand
sshadmand / Advanced Reads
Created October 9, 2016 18:15
Arduino Pressure Sensitive Fabric Tutorial Code
#include <math.h>
int myPin = 0;
int touching = false;
int touchingCount = 0;
void setup() {
Serial.begin(9600);
}
IAB_CATEGORIES = {
"IAB1":"Arts & Entertainment",
"IAB1-1":"Books & Literature",
"IAB1-2":"Celebrity Fan/Gossip",
"IAB1-3":"Fine Art",
"IAB1-4":"Humor",
"IAB1-5":"Movies",
"IAB1-6":"Music",
"IAB1-7":"Television",
"IAB2":"Automotive",
@sshadmand
sshadmand / Audio Player
Last active October 6, 2015 22:10
Sample Polymer 1.0 Elements
<link rel="import" href="../../bower_components/polymer/polymer.html">
<!--
Plays audio files.
Example:
<audio-player></audio-player>
@demo
@sshadmand
sshadmand / Polymer Cache bust for dev
Created September 4, 2015 14:14
Gulp Compiler Helpers
/*
Based on Cachebust
Fixes issue where the original cachebust doesn't see custom polymer elements. Ignores bower_components where polymer elements reside which will cause polymer issues.
*/
var $ = require('cheerio'),
MD5 = require('MD5');
exports.busted = function(fileContents, options) {
/* For elements in Polymer. Since Polymer
@sshadmand
sshadmand / flash-animation.html
Last active August 29, 2015 14:28
Polymer 1.0 Neon Animations
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animation-behavior.html">
<link rel="import" href="../../bower_components/neon-animation/web-animations.html">
<!--
`<fade-in-animation>` animates the opacity of an element from 0 to 1.
Configuration:
```
{
@sshadmand
sshadmand / Borderizer
Created August 16, 2015 02:11
Add borders to all your elements when testing out layout element sizing.
function borderizer(){
var all = document.querySelectorAll("*");
var rgb = [0, 0, 0];
for (var i=0, max=all.length; i < max; i++) {
all[i].style.border = "solid";
all[i].style.borderWidth = "1px";
}
}
@sshadmand
sshadmand / Jquery Handlebars Extension
Last active August 29, 2015 14:25
Jquery Handlebars Rendering Extension
/*
* Requires Jquery and Handlebars
* Render a template by passing in data and prepend or replace a container in your DOM.
* return DOM object so you can chain subsequent actions.
* Example:
* $("#main-stage").renderTemplate("template-id", dataDict);
* OR
* $("#main-stage").renderTemplate("template-id", dataDict).fadeIn("fast");
*/
jQuery.fn.extend({
@sshadmand
sshadmand / Bubble icons
Created December 23, 2014 07:56
CSS Animation
<style>
.bubbles-cont {
z-index: 0;
right: 300px;
position: absolute;
}
.bubbles-cont-2 {
z-index: 0;
left: 0px;
margin-bottom: -30px;
@sshadmand
sshadmand / Truncate Words
Created December 16, 2014 20:34
Handlebar Helpers: Truncate Words
Handlebars.registerHelper('truncwords', function(text, length) {
words = text.split(" ");
new_text = text;
if (words.length > length){
new_text = "";
for (var i = 0; i <= length; i++) {
new_text += words[i] + " ";
}
new_text = new_text.trim() + "..."
}
@sshadmand
sshadmand / If Greater Than ... Else ...
Last active August 29, 2015 14:11
Handlebars Helpers: If Greater Than ... Else ...
Handlebars.registerHelper('ifgt', function(val1, val2, options) {
console.log(val1, val2)
if (val1 > val2){
return options.fn(this);
}
return options.inverse(this);
});