Skip to content

Instantly share code, notes, and snippets.

@jonjaques
jonjaques / example.coffee
Last active August 29, 2015 13:57
Simple logging service (wraps $log) for Angular.js
app = angular.module 'demo', []
app.controller 'TestCtrl', ($scope, Logger)->
Logger.log 'generic log...' # generic log...
log = Logger.makeLogger 'TestCtrl'
log.log 'prefixed log' # TestCtrl: prefixed log
$scope.doStuff = ()->
def sass_literals(file_path)
engine = Sass::Engine.for_file(file_path, {})
environment = Sass::Environment.new
keyvals = []
engine.to_tree.children.each do |node|
next unless node.kind_of? Sass::Tree::VariableNode
if node.expr.kind_of? Sass::Script::Tree::Literal
value = node.expr.perform(environment)
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="bdr-app">
<template>
</template>
<script>
@jonjaques
jonjaques / node.webpack.ts
Created February 26, 2015 18:57
TypeScript definitions for webpack require()
// Type definitions for Node.js v0.11.13
// Project: http://nodejs.org/
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/************************************************
* *
* Node.js v0.11.13 API *
* *
************************************************/
/**
* redirect javascript bookmarklet
*/
// javascript:location.href='http://example.com/?uri='+encodeURIComponent(location.href)
/**
* bookmarklet loaded on site
*/
(function(){
@jonjaques
jonjaques / buttonselect.js
Created June 23, 2015 23:23
React Bootstrap ButtonGroup with Radio/Checkbox behavior
import React from 'react'
import { ButtonGroup } from 'react-bootstrap'
export default React.createClass({
propTypes: {
children: React.PropTypes.node,
type: React.PropTypes.oneOf(['checkbox', 'radio']),
value: React.PropTypes.any,
onChange: React.PropTypes.func,
@jonjaques
jonjaques / app.html
Created May 13, 2012 03:02
Less version for reusability and (slightly) more semantic HTML. Full-height 2-column fixed-width plus fluid with header.
<!doctype html>
<html lang="en">
<head>
<title>Test</title>
<link rel="stylesheet/less" type="text/css" href="app.less">
<script src="http://cdnjs.cloudflare.com/ajax/libs/less.js/1.3.0/less-1.3.0.min.js" type="text/javascript"></script>
</head>
<body>
<header id="appHeader">Header here</header>
@jonjaques
jonjaques / elements.html
Created July 5, 2012 21:33
HTML5 Element Page
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
@jonjaques
jonjaques / dog.js
Created July 20, 2012 20:56
Prototypical Inheritance Pattern
var Dog = function(name){
var name = name,
numberOfBarks = function(volume){
for(var i = 10; volume >= i; i--){
if(volume % 3 === 0){
return volume / 3;
}
}
@jonjaques
jonjaques / main.js
Created December 4, 2012 06:55
Knockout Bookmarklet template, w/ html template loading
// You create your bookmarklet by instantiating
// a new Bookmarklet function, then pass in the options like so.
// This example checks to see if the var is already defined, and makes
// sure not to overwrite it. This could happen if the user clicks on
// the bookmarklet more than once.
(function(global) {
global.Doublestock = new Bookmarklet({
css: [
'css/styles.css'