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 i = 0; | |
| function ticktack() { | |
| console.log('ticktack'.substr((i % 2) * 4, 4)); | |
| i++; | |
| } | |
| ticktack(); | |
| ticktack(); | |
| ticktack(); | |
| ticktack(); |
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
| // put some number | |
| var a = 200000; | |
| [a].toString().replace(/(\d)(?=(\d{3})+$)/g , '$1,'); | |
| // -> 200,000 |
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
| file_response = function( req, res ){ | |
| var deploied_file = ('any_file'); | |
| if( path.existsSync( deploied_file ) && fs.statSync( deploied_file ).isFile() ){ | |
| var type = mime.types[ | |
| path.extname( deploied_file ).substr(1) | |
| ]; | |
| // when file is .txt add charset=utf-8 | |
| type = [ | |
| type, | |
| 'charset=' + mime.charsets.lookup( type ) |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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('app') | |
| .filter('regex', function() { | |
| return function(input, field, regex) { | |
| var pattern = new RegExp(regex); | |
| var out = []; | |
| for (var i = 0; i < input.length; i++){ | |
| if(pattern.test(input[i][field])) | |
| out.push(input[i]); | |
| } | |
| return out; |
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('app') | |
| .filter('leftpad', function () { | |
| return function (input, length) { | |
| return ('00000000000000000000' + String(input)).slice(-length); | |
| }; | |
| }); |
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('app') | |
| .filter('percentage', ['$filter', function ($filter) { | |
| return function (input, decimals) { | |
| return $filter('number')(input * 100, decimals) + '%'; | |
| }; | |
| }]); |
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('app') | |
| .filter('abbreviate', function () { | |
| return function (text, length, end) { | |
| if (isNaN(length)) length = 20; | |
| if (typeof end === 'undefined') | |
| end = "..."; | |
| if (text.length <= length || text.length - end.length <= length) { | |
| return text; | |
| } | |
| else { |
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('app') | |
| .filter('tick', function () { | |
| var map = { | |
| '0': '×', | |
| '1': '○' | |
| }; | |
| return function(input) { | |
| if (typeof input == 'undefined'){ | |
| return ''; |
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 sendReport() { | |
| MailApp.sendEmail( | |
| "[email protected]", | |
| "title", | |
| "body" | |
| ); | |
| } |
NewerOlder