Skip to content

Instantly share code, notes, and snippets.

View carlozamagni's full-sized avatar
🎯
Focusing

Carlo Zamagni carlozamagni

🎯
Focusing
  • Technogym
  • Bologna
View GitHub Profile
var Hapi = require('hapi');
var server = new Hapi.Server();
server.connection({
host: 'localhost',
port: 8000
});
server.ext('onRequest', function (request, reply) {
@carlozamagni
carlozamagni / pubsub_logger.js
Last active November 8, 2017 18:04
Log a pubsub topic to console
'use strict'
const PubSub = require('@google-cloud/pubsub')
const pubSubClient = PubSub({
projectId: '<project-id>',
keyFilename: 'service_account_test.json'
})
var topic = pubSubClient.topic('<topic-name>');

Creating Neat .NET Core Command Line Apps

Every reason to get more HackerPoints™ is a good one, so today we're going to write a neat command line app in .NET Core! The Common library has a really cool package Microsoft.Extensions.CommandlineUtils to help us parse command line arguments and structure our app, but sadly it's undocumented.

No more! In this guide, we'll explore the package and write a really neat console app. We'll get good practices, a help system and argument parsing for free. Oh, it also involves ninjas. Insta-win.

@carlozamagni
carlozamagni / test.js
Created September 18, 2017 14:06 — forked from treo/test.js
Accessing a SOAP web service which requires a client certificate using node-soap 0.4.3
var soap = require('soap'),
fs = require('fs');
client = soap.createClient('https://some-webserv.ic/something.wsdl', {
wsdl_options: {
cert: fs.readFileSync('cert.pem'),
key: fs.readFileSync('keyfile.key')
}
}, function(err, client){
console.log(client.describe());
@carlozamagni
carlozamagni / webcam-lapse.js
Last active February 23, 2017 13:15
NodeJs timelapse
'use strict'
const NodeWebcam = require( "node-webcam" );
var opts = {
width: 1280,
height: 720,
delay: 0,
quality: 100,
output: "jpeg",
@carlozamagni
carlozamagni / publish-simple-message.js
Last active December 27, 2018 10:30
Receive and Publish operations via AWS SNS using Nodejs
// PUBLISH TO AWS SNS //
const AWS = require('aws-sdk')
// external config file
// const config = require('./configuration.js')
const config = {'SNS_ACCESS_KEY_ID':'', 'SNS_SECRET_KEY_ID':''}
const topicArn = ''
// perform auth
AWS.config.update({
@carlozamagni
carlozamagni / Dockerfile
Created January 20, 2017 15:53
Dockerfile for centos6-node
FROM centos:centos6
RUN yum install -y gcc-c++ make
RUN curl -sL https://rpm.nodesource.com/setup_6.x | bash -
RUN yum -y update && yum -y install nodejs
CMD node -v
'use strict'
const http = require("http")
const addr = process.argv[2]
const port = process.argv[3]
console.log('\nBinding tester to port: ' + port + '\n')
var server = http.createServer(function(request, response) {
class Person {
constructor(props) {
this.firstName = props.firstName || 'John';
this.lastName = props.lastName || 'Doe';
}
getFullName() {
return this.firstName + ' ' + this.lastName;
}
}