Skip to content

Instantly share code, notes, and snippets.

@ryanwitt
ryanwitt / cpuse.js
Last active December 26, 2015 09:18
cpuse: cpu monitor for node
//
// cpuse.js - simple continuous cpu monitor for node
//
// Intended for programs wanting to monitor and take action on overall CPU load.
//
// The monitor starts as soon as you require the module, then you can query it at
// any later time for the average cpu:
//
// > var cpuse = require('cpuse');
// > cpuse.averages();
@aaronksaunders
aaronksaunders / index.html
Created May 14, 2013 02:50
SampleKinveyApp Application using AngularJS and Kinvey
<!doctype html>
<html ng-app="sampleKinveyApp">
<head>
<meta charset="utf-8">
<title>Bootstrap, from Twitter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
{"_id": "theArtist",
"title": "The Artist",
"year": 2011,
"director": "Michel Hazanavicius",
"awards": [{"event": "Academy Awards",
"awards": [{"name": "Best Picture", "notes": ""},
{"name": "Best Director", "notes": "Hazanavicius"},
{"name": "Best Actor", "notes": "Dujardin"},
{"name": "Best Costume Design", "notes": ""},
{"name": "Best Original Score", "notes": ""}]},
@EchoAbstract
EchoAbstract / DoctorREST.txt
Created February 28, 2012 03:54
Many-to-Many REST
// Find all Dr's named Joe at Mercy Hospital
GET /appdata/[appKey]/doctors/?query={"firstName": "Joe", "hospital": "Mercy"}
[{"_id": "998798ad987fe987e987bc98766",
"firstName": "Joe",
"lastName": "Brown",
"hospital": "Mercy",
"speciality": "oncology"},
{"_id": "ca6775feba86554",
@EchoAbstract
EchoAbstract / DeweyREST.txt
Created February 28, 2012 03:51
REST Requests for One-to-Many
GET /appdata/[appKey]/stories/?query={"name":"Dewey Defeats Truman"}
[{"_id": "deweyDefeatsTruman",
"name": "Dewey Defeats Truman",
"reporter": "Arthur Sears Henning"}]
GET /appdata/[appKey]/comments/?query={"storyId":"deweyDefeatsTruman"}
[{"_id": "001",
"storyId": "deweyDefeatsTruman",
@aaronshaf
aaronshaf / bookmarklet-expanded.js
Last active February 25, 2024 18:56
Copy text from Amazon's Cloud Reader. Helpful for students that need block quotes.
javascript: (function () {
new_window = window.open();
new_window.document.body.innerHTML = $("iframe")
.contents()
.find("iframe")
.contents()
.find("body")
.get(1).innerHTML;
new_window.document.body.querySelector("#content-overlays").remove();
})();
@jessefreeman
jessefreeman / ColorMap.as
Created December 16, 2010 03:22
Use this class to set up a simple color hit test based image. Simply create a png in Photoshop, add a color bar or key to the top of the file, and draw colored shapes which will be used as a bounds for the collision detection.
/*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
@richardlord
richardlord / singleton.as
Created December 15, 2010 08:40
For creating singletons from actionscript classes
package
{
function singleton( c:Class ):*
{
return c in instances ? instances[c] : instances[c] = new c();
}
}
import flash.utils.Dictionary;
var instances:Dictionary = new Dictionary( false );