Skip to content

Instantly share code, notes, and snippets.

View peterssonjesper's full-sized avatar

Jesper Petersson peterssonjesper

View GitHub Profile
module.exports = function(grunt) {
grunt.initConfig({
jshint: ...
watch: ...
jasmine: ...
sass: ...
requirejs: ...
});
grunt.registerTask('jslint', [], function() {
module.exports = function(grunt) {
grunt.initConfig({
jshint: ...
watch: ...
jasmine: ...
sass: ...
requirejs: ...
});
grunt.loadNpmTasks('grunt-contrib-jshint');
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
// Task configuration.
jasmine: {
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
// Task configuration.
jasmine: {
var MyModule = function() {
this.myMethod = function() {
return "Hello world";
};
};
istanbul: {
src: '<%= jasmine.all.src %>',
options: {
vendor: '<%= jasmine.all.options.vendor %>',
specs: '<%= jasmine.all.options.specs %>',
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'coverage/json/coverage.json',
report: [
{type: 'html', options: {dir: 'coverage/html'}},
watch: {
js: {
files: [
'public/javascripts/src/**/*.js',
'public/javascripts/spec/**/*.js'
],
tasks: ['jasmine:all']
}
}
describe("My module", function() {
it("answers to myMethod() correctly", function() {
var instance = new MyModule();
expect(instance.myMethod()).toEqual("Hello world");
});
});
@peterssonjesper
peterssonjesper / create-boxshadow-css.js
Created October 17, 2012 23:46
Creates a boxshadow based on an image
// Create an empty canvas
var canvas = document.createElement('canvas');
// Create an image
var img = new Image();
img.src = "http://path/to/image.png";
// Wait for image to be downloaded
img.onload = function() {
// Draw the image on the canvas
@peterssonjesper
peterssonjesper / grunt.js
Created October 11, 2012 19:44
Sample grunt configuration
module.exports = function(grunt) {
grunt.initConfig({
// Javascript minification
min : {
code : {
'src' : [
'public/js/file1.js',
'public/js/file2.js',
'public/js/file3.js'
],