Skip to content

Instantly share code, notes, and snippets.

View robksawyer's full-sized avatar
🎯
Focusing

Rob Sawyer robksawyer

🎯
Focusing
View GitHub Profile
@robksawyer
robksawyer / Gruntfile.js
Created May 22, 2013 15:46
A basic Gruntfile.js to get started with.
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
@robksawyer
robksawyer / package.json
Last active December 17, 2015 14:59
A basic package.json file to get started with.
{
"name": "Project-Name",
"version": "0.1.0",
"lang": "en",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-cli": "~0.1.7",
"grunt-init": "~0.2.0",
"grunt-contrib-jshint": "~0.3.0",
"grunt-contrib-watch": "~0.3.1",
@robksawyer
robksawyer / _palette.scss
Last active December 20, 2015 13:09
A palette mixin.
@import "compass";
@import "compass/css3";
@import "compass/css3/images";
$base-color-transparent: transparent;
$base-color-white: rgb(255,255,255);
$base-color-black: rgb(0,0,0);
$custom-color-kia-red: rgb(196,23,44);
$custom-color-kia-text-gray: rgb(88,88,88);
$custom-color-kia-light-gray: rgb(162,162,162);
<?php
App::uses('AppModel', 'Model');
App::uses('AttachmentBehavior', 'Uploader.Model/Behavior');
App::uses('FileValidationBehavior', 'Uploader.Model/Behavior');
/**
* Attachment Model
*
* @property User $User
* @property CheeseProducer $CheeseProducer
@robksawyer
robksawyer / sails_referrer_view
Created October 22, 2014 07:08
Returns the referring view in SailsJS.
//Returns just the referring view. This can be used in the res.redirect or res.view.
var referrer = req.header('Referer').replace(req.protocol + "://" + req.host + ":" + req.port + '/', '');
return res.view(referringView, {result: false, errors: error_object});
//I'm trying to get the errors in the view via:
//<% sails.log(errors); %>
@robksawyer
robksawyer / gist:f739b110f580e025420e
Created October 31, 2014 05:04
SailsJS: Ajax Image Upload
//Source: https://github.com/balderdashy/sails/issues/27
var UUIDGenerator = require('node-uuid');
var DirectoryController = {
// uploads a file to a directory
upload: function(req, res) {
// Parse form data from server
var parsedFormData = JSON.parse(req.param('data'));
@robksawyer
robksawyer / scope issues
Created October 31, 2014 07:03
Simple file processing function.
/**
* CampaignController
*
* @description :: Server-side logic for managing campaigns
* @help :: See http://links.sailsjs.org/docs/controllers
*/
module.exports = {
fileExtension: function(fileName) {
@robksawyer
robksawyer / appHelper.js
Last active August 29, 2015 14:10
This is inside of test/helpers/appHelper.js
/*
* Location: /test/helpers/appHelper.js
*
* @description :: Provides 'lift' and 'lower' methods to set up
* and tear down a Sails instance (for use in tests)
*/
var Sails = require('sails'),
should = require('should'),
async = require('async'),
lifted = false,
'use strict';
/*
* Location: /test/bootstrap.test.js
*
* @description :: This file is run before all other tests.
*/
var should = require('chai').should(),
appHelper = require('./helpers/appHelper');