This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Analytics(config) { | |
config = config || {}; | |
var ga = (_gaq || []), | |
accountKey, | |
domainName, | |
proto = (this.prototype = Object.prototype); | |
proto.accountKey = function() { | |
if (!arguments.length) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var actionCount = typeof(/*Some Controller Type In Your MVC App*/) | |
.Assembly.GetTypes() | |
.Where(t => typeof(Controller).IsAssignableFrom(t)) | |
.Where(t => t.Namespace.StartsWith("AwesomeProduct.Web")) | |
.SelectMany(t => t.GetMethods(BindingFlags.Public | BindingFlags.Instance)) | |
.Where(m => typeof(ActionResult).IsAssignableFrom(m.ReturnType)) | |
.Where(m => !m.IsAbstract) | |
.Where(m => m.GetCustomAttribute<NonActionAttribute>() == null) | |
.Count(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net.Sockets; | |
namespace prettycode.org | |
{ | |
// Author: Chris O'Brien, prettycode.org | |
public static class NetworkStreamExtensions | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title></title> | |
<style> | |
body { | |
width: 100%; | |
padding: 0; | |
margin: 0; | |
background-color: #F0F0F0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a la http://chariotsolutions.com/blog/post/angularjs-corner-using-promises-q-handle-asynchronous-calls/ | |
// http://www.webdeveasy.com/interceptors-in-angularjs-and-useful-examples/ | |
angular | |
.module('movie') | |
.factory('movieService', function ($http, $log, $q) { | |
return { | |
getMovie: function (movie) { | |
var deferred = $q.defer(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Sandbox</title> | |
<script src="//code.jquery.com/jquery-2.1.1.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.js"></script> | |
<script src="//code.highcharts.com/stock/highstock.src.js"></script> | |
</head> | |
<body ng-app="app"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.factory('formatString', [function() { | |
/* by Chris O'Brien, prettycode.org, MIT license */ | |
return function formatString() { | |
var args = Array.prototype.slice.call(arguments), | |
format = args.shift(), | |
match; | |
if (args.length === 1 && typeof args[0] === 'object') { | |
args = args[0]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en" ng-app="app"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Sandbox</title> | |
<script src="//code.jquery.com/jquery-2.1.1.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.js"></script> | |
</head> | |
<body> | |
<div ng-controller="sandboxCtrl as sandbox"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function count(type) { | |
var counter = 0; | |
return through(function countFiles(data) { | |
counter++; | |
this.queue(data); | |
}, function endStream() { | |
console.log(' ' + counter + ' ' + type + ' files processed'); | |
this.queue(null); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// problem: beeper uses setTimeouts() for multiple beeps yet has no callback | |
// solution: return a promise for when beeping is done | |
var beeper = require('beeper'), | |
_ = require('lodash'), | |
q = require('q') | |
; | |
function beep(count) { | |
return q.all(_.times(typeof count === 'undefined' ? 1 : count, function (n) { |