Skip to content

Instantly share code, notes, and snippets.

@srounce
srounce / randomString.js
Created July 21, 2014 10:58
random alpha numeric string
function randomString(length) {
var str = "";
length = length || 1;
while(str.length < length) {
str += (Math.round(Math.random() * 36)).toString(36)
}
return str;
}
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
Session.setDefault("Template.myTemp.navigationState", 0)
Template.myTemp.navigationStateClass = function() {
return ["open", "half-open", "closed"][Session.get("Template.myTemp.navigationState")]
}
Handlebars.registerHelper("debug", function(optionalValue) {
if (optionalValue) {
return console.log("Value:", optionalValue);
} else {
return console.log("Current Context:", this);
}
});
<input type="checkbox" id="role_admin" name="role_admin" <!--data:ei7myswxkeejwecx7--="">&gt; admin
@srounce
srounce / myclass.js
Created January 23, 2013 13:39
For cloudbender
module.exports = exports = function(cArgs) {
var private = Math.random() * 1000;
function MyClass(args)
{
console.log('I am: ');
console.log(this);
}
MyClass.prototype.get = function()
#!/bin/sh
NODE_ENV="production"
node $1
@srounce
srounce / statman.js
Last active October 11, 2015 17:18
A static file server with a few frills..
var http = require('http')
, path = require('path')
, url = require('url')
, fs = require('fs')
, mime = require('mime')
, StatMan
, server;
StatMan = function( server )
{
@srounce
srounce / Countdown.js
Created September 17, 2012 15:46
Calculate time until/since etc...
if (typeof define !== 'function') {
var define = require('amdefine')(module);
}
define(function(require) {
"use strict";
var CountDown,
WEEK_MILLIS, DAY_MILLIS, HOUR_MILLIS, MINUTE_MILLIS;
@srounce
srounce / app.js
Created September 15, 2012 17:41
Cleaner routes in main js file
// Path: <project>/
var config = require('./config');
var express = require('express');
var app = express();
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(function(err, req, res, next){