Skip to content

Instantly share code, notes, and snippets.

@davideicardi
davideicardi / Program.cs
Created May 8, 2014 21:25
C# console application to convert video files inside a directory using HandBrakeCLI
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HBConvertVideoBatch
{
@davideicardi
davideicardi / install-graphite.md
Created June 26, 2014 23:12
Install graphite on Ubuntu 14.04
@davideicardi
davideicardi / SmartCollection.js
Last active October 31, 2017 10:22
mongodb library for node.js (Q promise support, schema validation)
var Q = require("q");
//var mongoClient = require("mongodb").MongoClient;
//var ObjectID = require("mongodb").ObjectID;
//var schema = require('validate');
function SmartCollection (mongoDb, collectionName, schema, indexes) {
this._mongoDb = mongoDb;
this._collectionName = collectionName;
this._collection = mongoDb.collection(collectionName);
@davideicardi
davideicardi / script.ps1
Created November 6, 2014 18:35
Running ssh commands on a Azure VM with powershell
Function Install-PoshSsh
{
# https://github.com/darkoperator/Posh-SSH
# http://www.powershellmagazine.com/2014/07/03/posh-ssh-open-source-ssh-powershell-module/
if(-not(Get-Module -name posh-ssh))
{
$webclient = New-Object System.Net.WebClient
$url = "https://github.com/darkoperator/Posh-SSH/archive/master.zip"
Write-Host "Downloading latest version of Posh-SSH from $url" -ForegroundColor Cyan
@davideicardi
davideicardi / kuduSiteUpload.ps1
Last active July 29, 2022 01:43
Upload a local directory to an Azure Website using kudu and powershell
Param(
[Parameter(Mandatory = $true)]
[string]$websiteName,
[Parameter(Mandatory = $true)]
[string]$sourceDir,
[string]$destinationPath = "/site/wwwroot"
)
# Usage: .\kuduSiteUpload.ps1 -websiteName mySite -sourceDir C:\Temp\mydir
@davideicardi
davideicardi / ChangeAzureBlobContentType.ps1
Created November 12, 2014 10:52
Change Azure blobs content type (batch)
Based on: https://gallery.technet.microsoft.com/scriptcenter/How-to-batch-change-the-47e310b4
#---------------------------------------------------------------------------------
#The sample scripts are not supported under any Microsoft standard support
#program or service. The sample scripts are provided AS IS without warranty
#of any kind. Microsoft further disclaims all implied warranties including,
#without limitation, any implied warranties of merchantability or of fitness for
#a particular purpose. The entire risk arising out of the use or performance of
@davideicardi
davideicardi / rabbitmq_ubuntu.sh
Last active July 18, 2018 12:08
Install rabbitmq on ubuntu and configure the cluster
Run the following script on each machine of the cluster:
sudo add-apt-repository 'deb http://www.rabbitmq.com/debian/ testing main'"
sudo apt-get update
sudo apt-get -q -y --force-yes install rabbitmq-server=3.4.1-1
sudo invoke-rc.d rabbitmq-server stop
echo 'MYCOOKIEVALUE' | sudo tee /var/lib/rabbitmq/.erlang.cookie
sudo chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
sudo chmod 400 /var/lib/rabbitmq/.erlang.cookie
@davideicardi
davideicardi / getAzureWebSitePublishingFile.ps1
Created November 16, 2014 20:01
Get an azure website publising xml file using PowerShell
Function Get-AzureWebSitePublishXml
{
Param(
[Parameter(Mandatory = $true)]
[String]$WebsiteName
)
# Get the current subscription
$s = Get-AzureSubscription -Current
if (!$s) {throw "Cannot get Windows Azure subscription."}
@davideicardi
davideicardi / Invoke-AdoNetSqlCmdl.ps1
Created March 23, 2015 18:42
Invoke a T-SQL batch file or string using ADO.NET and Power Shell
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 3.0
<#--------------------------------------------------------------------------
https://gallery.technet.microsoft.com/scriptcenter/The-PowerShell-script-for-2a2456c4
.SYNOPSIS
Script for running T-SQL files in MS SQL Server
Andy Mishechkin
@davideicardi
davideicardi / diThreeJsViewer.js
Created April 19, 2015 09:18
Angular Js directive that display a three.js model
// usage:
// <di-three-js-viewer three-js-object="device3DModel"></di-three-js-viewer>
app.directive('diThreeJsViewer', [function() {
function createThreeJsCanvas(parentElement, object) {
var width = 400;
var height = 400;
var scene = new THREE.Scene();