Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| // LZW-compress a string | |
| function lzw_encode(s) { | |
| var dict = {}; | |
| var data = (s + "").split(""); | |
| var out = []; | |
| var currChar; | |
| var phrase = data[0]; | |
| var code = 256; | |
| for (var i=1; i<data.length; i++) { | |
| currChar=data[i]; |
| """ | |
| A perl Data.Dumper clone for Python | |
| Author: simon@log4think.com | |
| 2011-07-08 | |
| Copyright 2011 Jinyu LIU | |
| 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 all copies or substantial portions of the Software. |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000This is a script that adds a fully functional Fork button to your own Gist.
If a Fork button is already present in the page, this bookmarklet will set focus to it instead of adding another one.
The change is temporary and the button will disappear as soon as you navigate away from that Gist (clicking the Fork button does this for you as well). Meaning you will have to run the script every new page load.
Copy the contents from bookmarklet.js, open Scracthpad (Ctrl+F4), paste it there. Back in browser, swwitch to tab with your Gist you want to fork. Back in Scratchpad, "Run" it. Save and/or bookmark the Scratchpad file for future use.
Protractor is the end to end test case runner for AngularJS. These end to end test cases can be repurposed to record performance metrics when the scenario is being run. This is a sample repository with an example of how this can be done.
Install all dependencies using npm install
| // Somewhere in your controllers for this given example | |
| // Example functions | |
| $scope.itemOnLongPress = function(id) { | |
| console.log('Long press'); | |
| } | |
| $scope.itemOnTouchEnd = function(id) { | |
| console.log('Touch end'); | |
| } |
| Regular expression cheat sheet for Varnish | |
| Varnish regular expressions are NOT case sensitive. Varnish uses POSIX | |
| regular expressions, for a complete guide, see: "man 7 regex" | |
| Basic matching: | |
| req.url ~ "searchterm" | |
| True if req.url contains "searchterm" anywhere. | |
| req.url == "searchterm" |
| app.directive('faFastScroll', ['$parse', function ($parse) { | |
| var Interval = function(min, max) { | |
| this.min = min || 0; | |
| this.max = max || 0; | |
| }; | |
| Interval.prototype.clip = function(min, max) { | |
| if(this.max <= min || this.min >= max) { | |
| this.min = this.max = 0; |
| function getWatchers(root) { | |
| root = angular.element(root || document.documentElement); | |
| var watcherCount = 0; | |
| function getElemWatchers(element) { | |
| var isolateWatchers = getWatchersFromScope(element.data().$isolateScope); | |
| var scopeWatchers = getWatchersFromScope(element.data().$scope); | |
| var watchers = scopeWatchers.concat(isolateWatchers); | |
| angular.forEach(element.children(), function (childElement) { | |
| watchers = watchers.concat(getElemWatchers(angular.element(childElement))); |
| <!-- View it live here: http://codepen.io/anon/pen/waZOjB --> | |
| <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.4/angular.min.js"></script> | |
| <script type="text/javascript" src="https://cdn.rawgit.com/JustMaier/6ef7788709d675bd8230/raw/3d39d50e66d8d77e05656ed7dd09298be7e86f1f/ngClickCopy.js"></script> | |
| <script> | |
| angular.module('app', ['ngClickCopy']) | |
| </script> | |
| <div ng-app="app"> | |
| <button ng-click-copy="Hello World">Copy</button> | |
| </div> |