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 module = angular.module( 'my.resource', [ 'ngResource' ] ); | |
| module.factory( 'Resource', [ '$resource', function( $resource ) { | |
| return function( url, params, methods ) { | |
| var defaults = { | |
| update: { method: 'put', isArray: false }, | |
| create: { method: 'post' } | |
| }; | |
| methods = angular.extend( defaults, methods ); |
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
| class nodejs { | |
| exec { 'nvm-install': | |
| command => '/usr/bin/curl https://raw.github.com/creationix/nvm/master/install.sh | /bin/sh', | |
| creates => '/home/vagrant/.nvm', | |
| user => 'vagrant', | |
| environment => 'HOME=/home/vagrant', | |
| require => Package['curl'] | |
| } |
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
| license: gpl-3.0 | |
| height: 960 | |
| redirect: https://observablehq.com/@d3/d3-zoomable-circle-packing |
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
| //Works for 1.1.x versions. 1.0.x is similar and can be figured out using code comments | |
| myapp.factory('myHttpResponseInterceptor',['$q','$location',function($q,$location){ | |
| return { | |
| response: function(response){ | |
| return promise.then( | |
| function success(response) { | |
| return response; | |
| }, | |
| function error(response) { | |
| if(response.status === 401){ |
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
| ### | |
| # Based on: | |
| # jQuery JavaScript Library v1.4.2 | |
| # http://jquery.com/ | |
| # | |
| # Copyright 2010, John Resig | |
| # Dual licensed under the MIT or GPL Version 2 licenses. | |
| # http://jquery.org/license | |
| ### |
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
| .filter("timeago", function () { | |
| //time: the time | |
| //local: compared to what time? default: now | |
| //raw: wheter you want in a format of "5 minutes ago", or "5 minutes" | |
| return function (time, local, raw) { | |
| if (!time) return "never"; | |
| if (!local) { | |
| (local = Date.now()) | |
| } |
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
| #!/usr/bin/env node | |
| var fs = require('fs'); | |
| var outfile = "primes.txt"; | |
| var count = 0; | |
| var maxCount = 100; | |
| var primes = []; | |
| var i = 2; |
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
| // gecko and webkit | |
| // details here https://developer.mozilla.org/en-US/docs/DOM/event.initKeyEvent | |
| var keyboardEvent = document.createEvent("KeyboardEvent"); | |
| var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent"; | |
| keyboardEvent[initMethod]( | |
| "keydown", // event type : keydown, keyup, keypress | |
| true, // bubbles |
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
| // look here for more details : https://developer.mozilla.org/en-US/docs/DOM/event.initMouseEvent | |
| var mouseMoveEvent = document.createEvent("MouseEvents"); | |
| mouseMoveEvent.initMouseEvent( | |
| "mousemove", //event type : click, mousedown, mouseup, mouseover, mousemove, mouseout. | |
| true, //canBubble | |
| false, //cancelable | |
| window, //event's AbstractView : should be window | |
| 1, // detail : Event's mouse click 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
| var viewportwidth; | |
| var viewportheight; | |
| // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight | |
| if (typeof window.innerWidth != 'undefined') | |
| { | |
| viewportwidth = window.innerWidth, | |
| viewportheight = window.innerHeight | |
| } |