Skip to content

Instantly share code, notes, and snippets.

View girliemac's full-sized avatar
📝
Working mostly on writing docs these days

Tomomi ❤ Imura girliemac

📝
Working mostly on writing docs these days
View GitHub Profile
@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!"
@kylebarrow
kylebarrow / bb10viewport.html
Created June 19, 2012 18:50
BB10 Alpha viewport test
<!DOCTYPE html>
<html lang="en">
<head>
<title>Screen Test</title>
<meta charset="utf-8">
<!--
Default device width vieport:
BB10 Alpha viewport width = 768px
-->
<!-- <meta name="viewport" content="width=device-width"> -->
@rauchg
rauchg / ms.md
Created December 21, 2011 00:25
Milliseconds conversion utility.
@davidcalhoun
davidcalhoun / htmlentities.js
Created June 15, 2011 07:43
Shortest HTMLEntities in JavaScript ever
/* From Ben McMahan:
http://www.quora.com/What-are-the-most-interesting-HTML-JS-DOM-CSS-hacks-that-most-web-developers-dont-know-about/answer/Ben-McMahan
Example usage:
HTMLEntities('<div id="foo">bar</div>'); // '&lt;div id="foo"&gt;bar&lt;/div&gt;'
*/
function HTMLEntities(a) {
var b = document.createElement('a');
@nils-werner
nils-werner / ReadDirAssistant.js
Created June 8, 2011 10:44
Simple FileIO Service for WebOS
var ReadDirAssistant = function() {
}
ReadDirAssistant.prototype.run = function(future) {
var fs = IMPORTS.require("fs");
var path = this.controller.args.path;
fs.readdir(path, function(err, files) { future.result = { path: path, files: files }; });
}
@jessefreeman
jessefreeman / layers_to_sprite_sheet.js
Created March 15, 2011 01:15
This is a PS script to make Sprite Sheets out of layers. Modified from http://www.garagegames.com/community/blogs/view/11527
// Put this file in Program Files\Adobe\Photoshop\Presets\Scripts\
// In PhotoShop menu File > Automate > Scripts: layersToSprite.js
// Arrange layers into a sprite sheet.
if (documents.length > 0)
{
// --------------------------
docRef = activeDocument;
@codepo8
codepo8 / localstorage.js
Created August 25, 2010 14:44
Store the state of a rendered form the easy way
<script>
// test for localStorage support
if(('localStorage' in window) && window['localStorage'] !== null){
var f = document.getElementById('mainform');
// test with PHP if the form was sent (the submit button has the name "sent")
<?php if(isset($_POST['sent']))){?>
// get the HTML of the form and cache it in the property "state"
localStorage.setItem('state',f.innerHTML);