Skip to content

Instantly share code, notes, and snippets.

@ksheedlo
ksheedlo / demo.js
Last active October 24, 2015 06:26
'use strict';
global.Promise = global.Promise || require('bluebird');
var request = require('request'),
fetch = require('node-fetch');
exports.getRequest = function getRequest() {
return new Promise(function (resolve, reject) {
request({
'use strict';
// ksheedlo: I'm working on a node/web micro library for this, but it's not published yet
angular.module('myApp')
.factory('Types', function () {
return {
toInt: function (x) {
return parseInt(x, 10);
},
toFloating: function (x) {
@ksheedlo
ksheedlo / CLI output
Last active August 29, 2015 14:13
Typescript-require relative paths bug
$ node explode.js
fs.js:427
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory '/Users/ken/typescript-require-min-bug/tmp/tsreq/ship.js'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.readFileSync (fs.js:284:15)
at runJS (/Users/ken/typescript-require-min-bug/node_modules/typescript-require/index.js:91:20)
at Object.require.extensions..ts (/Users/ken/typescript-require-min-bug/node_modules/typescript-require/index.js:22:3)
import random
import string
print ''.join(random.sample(string.letters + string.digits, 20))

The best place to start learning about how to test your Angular code is the Unit Testing section of the AngularJS Developer Guide. Some of the important takeaways from the guide are that

  • dependency injection is the best way to get ahold of dependencies for testing purposes. Angular has this built in, but you can help by not manipulating the DOM in your application (e.g., controller) logic.
  • use the $compile service to bind scope to a directive's DOM for testing

Some other helpful practices I've discovered through experience:

@ksheedlo
ksheedlo / goto.js
Created March 4, 2014 21:04
goto-in-javascript
function goto (func, line) {
var code = func.toString()
.split('\n')
.slice(line)
.join('\n');
var curlies = 0;
for (var i = 0; i < code.length; i++) {
if (code[i] === '{') {
curlies--;
}
@ksheedlo
ksheedlo / bower.json
Last active December 31, 2015 05:19
HTML5 Drag n Drop
{
"name": "dnd-demo",
"version": "0.0.1",
"authors": [
"Ken Sheedlo <ovrkenthousand@gmail.com>"
],
"description": "HTML5 drag-n-drop table prototype",
"main": "index.js",
"license": "MIT",
"private": true,
@ksheedlo
ksheedlo / error-message-minification-with-minerr.md
Last active December 21, 2015 03:29
Error Message Minification with MinErr

With the release of AngularJS 1.2.0rc1, the Angular team announced our new error message minification service, called MinErr (pronounced "miner"). MinErr provides more insight to developers about error conditions in their app, while also reducing code size. To ease the transition, let's take a detailed look at MinErr and try to answer any questions that might come up.

What is MinErr and why did you build it?

Angular has had some cryptic and confusing error messages in the past.

@ksheedlo
ksheedlo / brew doctor
Created May 20, 2013 06:47
haskell-platform failed to build on 10.8
$ brew doctor
Your system is ready to brew.
@ksheedlo
ksheedlo / fortunes.txt
Created April 16, 2013 08:06
Fun with Linux programs
_____________________________________
/ You have the body of a 19 year old. \
| Please return it before it gets |
\ wrinkled. /
-------------------------------------
\ /\ ___ /\
\ // \/ \/ \\
(( O O ))
\\ / \ //
\/ | | \/