Skip to content

Instantly share code, notes, and snippets.

@dprea
dprea / ng-src-onerror.js
Created January 10, 2016 02:21
Angular ng-src onerror such as image resolves to a broken src
/**
* First is the Angular Directive method of solving.
* Second is the inline onerror fix that results in a default image.
* SOURCE: http://stackoverflow.com/questions/27549134/angularjs-ng-src-condition-if-not-found-via-url
*/
var myApp = angular.module('myApp',[]);
myApp.directive('onErrorSrc', function() {
return {
@dprea
dprea / meaninstall.md
Created January 11, 2016 09:07
New Mean Stack (At least Cloud 9)

#INSTALLING MEAN STACK

  1. sudo apt-get update -qq
  2. sudo apt-get install gcc make build-essential
  3. npm rebuild
  4. npm install -g bower
  5. npm install -g node-sass
  6. npm install -g autoprefixer
  7. npm install -g gulp
  8. npm install -g gulp-sass
@dprea
dprea / article.server.model.js
Last active January 17, 2016 15:39
MEAN.js 0.4.2 - Mongoose.js Discriminator Schemas
'use strict';
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
/**
* Article Schema
@dprea
dprea / linux-count-files-in-dir.md
Created January 22, 2016 04:27
Linux Commands - Count Files in directory
$ find . -type f | wc -l

Explanation: find . -type f finds all files ( -type f ) in this ( . ) directory and in all sub directories, the filenames are then printed to standard out one per line.

This is then piped | into wc (word count) the -l option tells wc to only count lines of its input.

Together they count all your files.

@dprea
dprea / import_json_appsscript.js
Created January 25, 2016 03:25 — forked from chrislkeller/import_json_appsscript.js
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@dprea
dprea / autovim.sh
Last active January 27, 2016 21:06
Shell Script - Open Vim then Write Text then Save and Quit Vim
# Uses Vim to create a text file (file.txt) with text 'hello'
# Save and quit Vim
vim file.txt -c '$put =\'hello\' -c 'wq'
# -----------------------------------------------------------------------------------------
# SOURCE http://stackoverflow.com/questions/5978108/open-vim-from-within-bash-shell-script
# -----------------------------------------------------------------------------------------
# vim -c
# -c => pass ex commands.
# Example: vim myfile.txt -c 'wq' to force the last line of a file to be newline terminated
# (unless binary is set in some way by a script)
@dprea
dprea / JS Function Declaration vs Expression.markdown
Last active February 8, 2016 02:20
JS Function Declaration vs Expression
@dprea
dprea / GMAP_Data_Store_Locator.md
Created February 8, 2016 16:31
Google Maps API
@dprea
dprea / click_workable_items.js
Created February 9, 2016 08:44
Small jQuery Script for finding Workable.com Links
/**
* Makes the Workable Job Items(.whr-item) Clickable
*
* @author: Dustin Rea
*/
var whrClickable = function() {
setTimeout(function() {
jQuery('.whr-item').click(function() {
window.location = jQuery(this).find('.external').attr('href');
return false;