Skip to content

Instantly share code, notes, and snippets.

View prettycode's full-sized avatar

Chris prettycode

  • Seattle, WA
View GitHub Profile
@prettycode
prettycode / gist:e0c3187102c0dbc363c0
Created April 8, 2015 22:15
3rd party ide powershell
http://stackoverflow.com/questions/2095088/error-when-calling-3rd-party-executable-from-powershell-when-using-an-ide
@prettycode
prettycode / deglob.js
Last active August 29, 2015 14:17
Get list of files using synchronous globbing
// problem: the order of the files it finds can be different each time glob searches the exact same path
// solution: use synchronous globbing instead
var _ = require('lodash'),
glob = require('glob')
;
function deglob() {
var syncGlob = glob.sync,
patterns = _.flatten(arguments, true);
@prettycode
prettycode / beep.js
Last active August 29, 2015 14:17
Beep function that returns a promise when its done, for Node.js.
// 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) {
@prettycode
prettycode / gulpCountFiles.js
Last active August 29, 2015 14:16
Output number of files in gulp.
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);
});
}
@prettycode
prettycode / angular-template.htm
Created December 3, 2014 19:06
AngularJS template
<!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">
@prettycode
prettycode / angularjs-string-formatter-service.js
Last active October 24, 2015 04:02
Convenient String Formatter Helper/Utility Service Function in Angular JS
.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];
}
@prettycode
prettycode / highcharts-and-highstock-angular-wrapper.htm
Last active August 29, 2015 14:10
Minimalist Highcharts + Highstock AngularJS Wrapper
<!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">
@prettycode
prettycode / data-service-pattern.js
Last active August 29, 2015 14:10
AngularJS Data Service pattern
// 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();
@prettycode
prettycode / article.htm
Created June 3, 2013 14:49
HTML layout with paper-page styling.
<!doctype html>
<html>
<head>
<title></title>
<style>
body {
width: 100%;
padding: 0;
margin: 0;
background-color: #F0F0F0;
@prettycode
prettycode / NetworkStreamExtensions.cs
Last active December 18, 2015 00:18
Utility functions for NetworkStream reading operations.
using System;
using System.IO;
using System.Net.Sockets;
namespace prettycode.org
{
// Author: Chris O'Brien, prettycode.org
public static class NetworkStreamExtensions
{