Skip to content

Instantly share code, notes, and snippets.

View danielkhan's full-sized avatar

Daniel Khan danielkhan

  • Sentry
  • Linz / Austria
  • X @dkhan
View GitHub Profile
// Define some functions and pretend they need to
// be asynchronous just for demonstration purposes
function plus(n1, n2, cb) {
return cb(n1+n2);
}
function minus(n1, n2, cb) {
return cb(n1-n2);
}
function isValidUser(username, cb) {
if(username !== 'Frank') cb("Access denied!");
cb("Access granted!")
}
isValidUser("Tom", function(msg) {
// This will output "Access denied!" AND "Access granted!"
console.log(msg);
/**
* Simple userland heapdump generator using v8-profiler
* Usage: require('[path_to]/HeapDump').init('datadir')
*
* @module HeapDump
* @type {exports}
*/
var fs = require('fs');
var profiler = require('v8-profiler');
/**
* Simple userland CPU profiler using v8-profiler
* Usage: require('[path_to]/CpuProfiler').init('datadir')
*
* @module CpuProfiler
* @type {exports}
*/
var fs = require('fs');
var profiler = require('v8-profiler');
// Require the http core module
var http = require('http');
// Create a server and provide a function (callback) that
// gets called for every request
http.createServer(function (req, res) {
// Speccify a content type
res.writeHead(200, {'Content-Type': 'text/plain'});
// Write into the response object sent to the client
{
"name": "SomeTestproject",
"version": "0.0.1",
"description": "Some description",
"main": "main.js",
"dependencies": {
"express": "^4.12.2",
"mongodb": "^1.4.33",
"mysql": "^2.5.5",
"restify": "^2.8.5"
module.exports.version = '0.0.1';
module.exports.add = function (a, b) {
return a + b;
};
var myAdder = require('./adder');
console.log(myAdder.version); // will print 0.0.1
console.log(myAdder.add(4, 23)); // will print 27
@danielkhan
danielkhan / jsadk.js
Last active August 29, 2015 14:24
Adding dtagentApi to a document.
<body>
// Your content
// [..]
// Include our ADK
<script src="/<path>/<to>/dtagentApi.js"></script>
<script>
// Use jQuery
jQuery(function ($) {
// Make sure that Dynatrace / UEM is present
@danielkhan
danielkhan / godaddy-ssl-howto
Last active August 29, 2015 14:26 — forked from ideaoforder/godaddy-ssl-howto
GoDaddy + Nginx SSL
openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
http://support.godaddy.com/help/article/3601/generating-a-certificate-signing-request-nginx
http://support.godaddy.com/help/article/4976/rekeying-an-ssl-certificate
# Be sure to remember to chain them!
cat gd_bundle-g2-g1.crt >> yourdomain.crt
# Move 'em
sudo mv yourdomain.crt /etc/ssl/certs/yourdomain.crt