This file contains 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/php | |
<?php | |
$input = new stdClass(); | |
$input->ip = '70.71.72.73'; | |
$input->netmask = '255.255.255.0'; | |
$input->ip_int = ip2long($input->ip); | |
$input->netmask_int = ip2long($input->netmask); | |
// Network is a logical AND between the address and netmask |
This file contains 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://stackoverflow.com/a/21559595 | |
// ip example: 192.168.2.1 | |
function inet_aton(ip){ | |
// split into octets | |
var a = ip.split('.'); | |
var buffer = new ArrayBuffer(4); | |
var dv = new DataView(buffer); | |
for(var i = 0; i < 4; i++){ | |
dv.setUint8(i, a[i]); | |
} |
This file contains 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
// Example from https://scotch.io/tutorials/making-skinny-angularjs-controllers | |
// Search the goat database | |
$scope.searchGoats = _.debounce(function(query) { | |
$http.get('/goats/search/' + query) | |
.then(function(response) { | |
$scope.goats = response.data; | |
}); | |
}, 300); |
This file contains 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
// See http://megatuto.com/formation-JAVASCRIPT.php?JAVASCRIPT-Examples=handling+document.visibilitychange+in+AngularJS+Categorie+javascript+angularjs&article=1773 | |
angular.module('myApp', []) | |
.run(['$rootScope', '$document', function($rootScope, $document) { | |
$document[0].addEventListener("visibilitychange", function() { | |
$rootScope.$broadcast('$visibilitychange', $document[0].hidden); | |
}); | |
}]) | |
.controller('UserNavCtrl', ['$scope', '$log', | |
function($scope,$log) { | |
$scope.$on('$visibilitychange', function(event, data) { |
This file contains 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 strict"; | |
exports.queryAll = function(conn, sql, args, cb) { | |
var allRows = []; | |
conn.execute(sql, args, { | |
resultSet: true | |
}, function(err, result) { | |
if (err) return cb(err); | |
function fetch() { |
This file contains 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
/* | |
* letsencrypt certificates with node js express / http | |
* key is obvious, privkey.pem | |
* ca and cert were not obvious to me. | |
* ca uses chain.pem | |
* cert uses fullchain.pem | |
* | |
* You can test your project with https://www.ssllabs.com/ssltest/ | |
* | |
*/ |
This file contains 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
/* | |
* config/bootstrap.js | |
* Example of how to redirect all http request to https | |
* See http://jsbot.io/node/http-and-https-handle-with-sailsjs | |
* | |
*/ | |
module.exports.bootstrap = function(cb) { | |
var express = require("express") | |
var app = express(); |
This file contains 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
# https://github.com/salsita/node-pg-migrate | |
npm install node-pg-migrate |
This file contains 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 sudo before each command if not logged in as root | |
# | |
# Install nginx https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04 | |
apt-get update | |
apt-get install nginx | |
# Check that HTTP port 80 and HTTPS port 443 are open | |
ufw app status | |
# Make sure nginx starts on boot |
OlderNewer