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
| import BaseHTTPServer, SimpleHTTPServer | |
| import ssl | |
| httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler) | |
| httpd.socket = ssl.wrap_socket (httpd.socket, certfile='path/to/localhost.pem', server_side=True) | |
| httpd.serve_forever() |
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 lastConnectionState; | |
| var speed = 10000; | |
| var endpoint = 'http://www.reddit.com/.json'; | |
| (function checkConnection () { | |
| var xhr = new XMLHttpRequest(); | |
| var connectionState; | |
| // probably better if we do not make this call async for a couple of reasons |
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
| function $switch (test, cases) { | |
| function doit (thing) { | |
| return (cases[thing] || cases['default'] || function () {})(); | |
| } | |
| if (test && cases) { | |
| return doit(test); | |
| } | |
| cases = test; |
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
| // http://www.codewars.com/kata/539a0e4d85e3425cb0000a88/ | |
| function add (n) { | |
| var next = add.bind(n += this | 0); | |
| next.valueOf = function () { | |
| return n; | |
| }; | |
| return next; |
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
| (function () { | |
| 'use strict'; | |
| var slice = Array.prototype.slice; | |
| Function.prototype.expect = function expect () { | |
| var argTypes = slice.call(arguments); | |
| var functionToCall = this; |
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
| angular.module('test', []).controller('Test', inject([ | |
| '$scope', | |
| '$http' | |
| ], function () { | |
| 'use strict'; | |
| this.$scope.wat = 'hallo'; |
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
| function expectRequest (method, url, data) { | |
| var $httpBackend; | |
| inject(function ($injector) { | |
| $httpBackend = $injector.get('$httpBackend'); | |
| }); | |
| function withHeaders (expectedHeaders) { | |
| return $httpBackend.expect(method, url, data, function (actualHeaders) { | |
| for (var header in expectedHeaders) { |
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
| ranger([1,2,3,5,7,8,9]) // "1:3,5,7:9" |
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
| angular | |
| .module('preload', []) | |
| .factory('preload', function ($q) { | |
| 'use strict'; | |
| function getImage (src, ignoreFailure) { | |
| var defer = $q.defer(); | |
| var img = new Image(); | |
| var resolve = defer.resolve.bind(defer, img); |
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 Thing = Weird.extend({ | |
| myProp: 'hello', | |
| getMyProp: function () { | |
| return myProp; | |
| }, | |
| setMyProp: function (value) { | |
| myProp = value; |
OlderNewer