Skip to content

Instantly share code, notes, and snippets.

View alex-seville's full-sized avatar

Alex Seville alex-seville

View GitHub Profile
@alex-seville
alex-seville / jsViews in Backbone
Created June 7, 2012 14:53
Using jsViews in backbone to make an editable area (http://jsfiddle.net/XuXtS/4/)
var Form = Backbone.Model.extend({});
var FormView = Backbone.View.extend({
events: {
"click .save": "save",
"click .edit": "edit",
"click .cancel": "cancel"
},
initialize: function() {
//set up our input form template
$.templates({
@alex-seville
alex-seville / test.js
Created October 16, 2012 16:48
test uglify parse
// sample on how to use the parser and walker API to instrument some code
var jsp = require("uglify-js").parser;
var pro = require("uglify-js").uglify;
function instrument(code) {
var ast = jsp.parse(code, false, true); // true for the third arg specifies that we want
// to have start/end tokens embedded in the
// statements
var w = pro.ast_walker();
@alex-seville
alex-seville / falafel_test.js
Created October 18, 2012 02:17
instrumenting code with falafel
var falafel = require('falafel');
var intro = "\"tracking code start\";\n";
var checkForOneLiner = function (node) {
if (linesToAddBrackets.indexOf(node.type) > -1){
var bracketsExistObject = node.consequent || node.body;
if( bracketsExistObject && bracketsExistObject.type != "BlockStatement") {
bracketsExistObject.update("{\n"+bracketsExistObject.source()+"\n}");
}
}
@alex-seville
alex-seville / builder.js
Created October 24, 2012 17:38
qunit coverage with require
//used to wrap requirejs in our code
var _ = require("underscore"),
fs = require("fs");
var template = fs.readFileSync(__dirname+"/template",'utf8');
var requirejs = fs.readFileSync(__dirname+"/require.js",'utf8');
var compiled = _.template(template);
var result = compiled({requirejs: requirejs});
@alex-seville
alex-seville / lib-blanket.js
Created October 29, 2012 16:22
custom loading in node
var fs = require("fs");
var oldLoader = require.extensions['.js'];
//find current scripts
require.extensions['.js'] = function(module, filename) {
if (filename.indexOf("/src/") > -1){
var content = fs.readFileSync(filename, 'utf8');
// Parse the file content and give to module.exports
var covintro = "/* automatically generated by JSCoverage - do not edit */";
@alex-seville
alex-seville / coverage.html
Created October 30, 2012 16:32
mocha reporter, converted from jade to underscore
<html>
<head>
<title>Coverage</title>
<script>
headings = [];
onload = function(){
headings = document.querySelectorAll('h2');
};
@alex-seville
alex-seville / all.tests.qunit.js
Last active December 10, 2015 12:08
issue 156 change require syntax changed syntax of all.tests.qunit
/// <reference path="require.js" />
/// <reference path="qunit.js" />
define(['../tests/base/base.qunit.test',
'../tests/ui/ui.qunit.test'],
function (){}
);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="stylesheet" type="text/css" href="jasmine/jasmine.css"/>
<script type="text/javascript" src="jasmine/jasmine.js"></script>
<script type="text/javascript" src="jasmine/jasmine-html.js"></script>
<link rel="shortcut icon" type="image/png" href="jasmine/jasmine_favicon.png"/>
<!--<script type="text/javascript" src="Coverage/blanket_jasmine.js" data-cover-flags="ignoreError autoStart" data-cover-only="code/"></script>-->
@alex-seville
alex-seville / blanket-jasmine-brackets-adapter.js
Created January 17, 2013 02:25
A Blanket.js adapter for use in Brackets.
(function () {
if (! jasmine) {
throw new Exception("jasmine library does not exist in global namespace!");
}
function elapsed(startTime, endTime) {
return (endTime - startTime)/1000;
}
@alex-seville
alex-seville / gist:5268621
Created March 29, 2013 03:40
Using blanket without data-cover attribute
Option 1.
If you have access to the blanket script tag
<script data-cover-filter="src/" src="blanket.js"></script>
Option 2.
Create a new script block and set the blanket options manually