Skip to content

Instantly share code, notes, and snippets.

@davideicardi
davideicardi / cleanRequire.js
Created August 13, 2015 23:25
Clean up node js require cache
function cleanRequireCache(){
Object.keys(require.cache).forEach(function(key) {
delete require.cache[key];
});
}
function cleanRequire(path){
delete require.cache[require.resolve(path)];
return require(path);
@davideicardi
davideicardi / script.js
Created August 13, 2015 23:27
Create promise from node async function
function denodifyMethod(funcName){
return function(){
return Q.npost(this, funcName, arguments);
}
}
serviceBusService.createTopicIfNotExistsQ = denodifyMethod("createTopicIfNotExists");
.myClass.ng-enter, .myClass.ng-leave {
-webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 5s;
transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 5s;
}
.myClass.ng-enter,
.myClass.ng-leave.ng-leave-active {
opacity:0;
}
@davideicardi
davideicardi / install.bash
Last active January 6, 2017 00:37
Installing graphite and statsd within an Azure Docker
sudo docker run -d \
--name graphite \
--restart=always \
-v /home/webplu/graphite/storage:/opt/graphite/storage \
-v /home/webplu/log:/var/log \
-p 80:80 \
-p 2003:2003 \
-p 8125:8125/udp \
hopsoft/graphite-statsd
@davideicardi
davideicardi / index.json
Last active November 18, 2015 16:01
Json-ld experiments
{
"@context": {
"@vocab": "http://schema.org/",
"myCustomProperty": null,
"@base": "https://gist.github.com/davideicardi/94e9f338a11328061e42",
"slug": "@id",
"type": "@type"
},
"slug": "people",
"type": "DataFeed",
@davideicardi
davideicardi / mongo-docker.bash
Last active July 16, 2023 18:18
Running mongodb inside a docker container (with mongodb authentication)
# Create a container from the mongo image,
# run is as a daemon (-d), expose the port 27017 (-p),
# set it to auto start (--restart)
# and with mongo authentication (--auth)
# Image used is https://hub.docker.com/_/mongo/
docker pull mongo
docker run --name YOURCONTAINERNAME --restart=always -d -p 27017:27017 mongo mongod --auth
# Using the mongo "localhost exception" (https://docs.mongodb.org/v3.0/core/security-users/#localhost-exception)
# add a root user
@davideicardi
davideicardi / azureServceBus.js
Last active January 26, 2016 08:38
RabbitMq and Azure Service Bus Node.js class wrappers (RabbitMqChannel, AzureSubscription)
"use strict";
const debug = require("debug")("azureServiceBus");
const events = require("events");
const azure = require("azure");
/*
Class wrapper around Azure Service Bus Topic/Subscription API.
Usage:
@davideicardi
davideicardi / dns.aspx
Last active September 1, 2016 15:22
Host name resolution diagnostic page
<!-- directives -->
<% @Page Language="C#" %>
<%@ Import namespace="System.Net" %>
<!-- call example:
https://server/_diagnostics/dns.aspx?hostName=microsoft.com
-->
<script runat="server">
private string HostName2IP(string hostname)
{
@davideicardi
davideicardi / mongo.aspx
Last active September 1, 2016 15:21
MongoDb diagnostic page
<!-- directives -->
<% @Page Language="C#" %>
<%@ Import namespace="MongoDB.Bson.Serialization" %>
<%@ Import namespace="MongoDB.Bson.Serialization.Conventions" %>
<%@ Import namespace="MongoDB.Driver" %>
<%@ Import namespace="MongoDB.Bson" %>
<!-- call example:
https://server/_diagnostics/mongo.aspx?connectionString=mongodb%3A%2F%2Fserver%3A27017%2Ftest&collectionName=logs
@davideicardi
davideicardi / forge-array-behavior.html
Last active November 10, 2018 22:22
Polymer web components sample for Deltatre's Forge
<script>
(function() {
function InvalidEntityError(message) {
this.message = message;
var last_part = new Error().stack.match(/[^\s]+$/);
this.stack = `${this.name} at ${last_part}`;
}
Object.setPrototypeOf(InvalidEntityError, Error);
InvalidEntityError.prototype = Object.create(Error.prototype);
InvalidEntityError.prototype.name = "InvalidEntityError";