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
"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
// 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
// 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
// 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
#!/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 |
NewerOlder