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
Show hidden characters
| { | |
| "node": true, | |
| "browser": true, | |
| "esnext": true, | |
| "bitwise": true, | |
| "camelcase": true, | |
| "curly": true, | |
| "eqeqeq": true, | |
| "immed": true, | |
| "indent": 4, |
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
| module.exports = { | |
| DB1: redis.createClient(), | |
| DB2: redis.createClient(), | |
| DB3: redis.createClient(), | |
| init: function(next) { | |
| var select = redis.RedisClient.prototype.select; | |
| require('async').parallel([ | |
| select.bind(this.DB1, 1), | |
| select.bind(this.DB2, 2), | |
| select.bind(this.DB3, 3) |
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
| define('Jasmine' , function () { | |
| beforeEach(function(){ | |
| runs(function () { | |
| getRemoteData(function(res){ | |
| this.data = res; | |
| }.bind(this)); | |
| }); | |
| waitsFor(function() { |
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
| #!/bin/bash | |
| DIR="$( cd "$( dirname "$0" )" && pwd )" | |
| echo $DIR |
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 withinCircle(x, y, centerX, centerY, radius) { | |
| return Math.pow((x - centerX), 2) + Math.pow((y - centerY), 2) < Math.pow(radius, 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
| // @credit http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points | |
| function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) { | |
| var R = 6371; // Radius of the earth in km | |
| var dLat = deg2rad(lat2-lat1); | |
| var dLon = deg2rad(lon2-lon1); | |
| var a = | |
| Math.sin(dLat/2) * Math.sin(dLat/2) + | |
| Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * | |
| Math.sin(dLon/2) * Math.sin(dLon/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
| # Method one - w | |
| w | head -n1 | cut -d":" -f4 | |
| # Method two - uptime | |
| uptime | cut -d":" -f4- | sed s/,//g | |
| # Method three - loads.d | |
| sudo loads.d | awk '/./ { printf "%.2f %.2f %.2f\n", $7, $8, $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
| function MyError(message) { | |
| this.name = 'MyError'; | |
| this.message = message; | |
| this.stack = (new Error()).stack; | |
| } | |
| MyError.prototype = new Error(); | |
| MyError.prototype.constructor = MyError; | |
| try { |
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 fs = require('fs'); | |
| fs.readdir([__dirname,'/app/images'].join(''), function(err, files) { | |
| function filter(file) { | |
| return /(\.png|\.jpg|\.jpeg)/.test(file); | |
| } | |
| var filtered = JSON.stringify(files.filter(filter)); | |
| fs.writeFile([__dirname,'/app/data/images.json'].join(''), filtered, function(err) { | |
| if (err) throw new Error(err); | |
| console.log(filtered); |
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(module) { | |
| module.controller('TestController', ['$scope', '$http', | |
| function($scope, $http) { | |
| $http.get('/api/stuffs') | |
| .then(function(data) { | |
| $scope.stuffs = data; | |
| }); | |
| }]); |
OlderNewer