Skip to content

Instantly share code, notes, and snippets.

View MindFlavor's full-sized avatar

Francesco Cogno MindFlavor

View GitHub Profile
@MindFlavor
MindFlavor / gist:99a70650961e47a3f767
Created November 4, 2014 11:09
SQL Server Elastic Demo 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement;
using System.Data.SqlClient;
using Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.Schema;
/**
@MindFlavor
MindFlavor / gist:61bf05e357cddbeffb02
Last active August 29, 2015 14:14
HandsOn - SQL Database Row-Level Security blog post demo
-----------------------------
----------- Setup------------
------- Pick a test db ------
-----------------------------
SET NOCOUNT ON;
GO
CREATE SCHEMA Sec;
GO
package main
import (
"database/sql"
"fmt"
_ "github.com/denisenkom/go-mssqldb"
"log"
"os"
"strings"
"time"
@MindFlavor
MindFlavor / detach_and_reattach_after_path_mangling.sql
Created January 18, 2016 16:26
Script creating the T-SQL script for detaching and reattaching the databases after path mangling
DECLARE @dest_path_file NVARCHAR(MAX)
DECLARE @dest_path_log NVARCHAR(MAX)
SET @dest_path_file = 'C:\pippo\pluto';
SET @dest_path_log = 'C:\pippo\plog';
DECLARE cdb CURSOR FOR
SELECT name, database_id FROM sys.databases WHERE database_id > 4;
OPEN cdb;
pub fn generate_signature(policy_name: &str, hmac_key: &str, url: &str, ttl: Duration) -> String {
let expiry = chrono::UTC::now().add(ttl).timestamp();
debug!("expiry == {:?}", expiry);
let url_encoded = utf8_percent_encode(url, HTTP_VALUE_ENCODE_SET);
debug!("url_encoded == {:?}", url_encoded);
let str_to_sign = format!("{}\n{}", url_encoded, expiry);
debug!("str_to_sign == {:?}", str_to_sign);
pub fn submit_event(namespace: &str,
event_hub: &str,
policy_name: &str,
key: &str,
event_body: (&mut Read, u64),
duration: Duration)
-> Result<(), AzureError> {
// prepare the url to call
let url = format!("https://{}.servicebus.windows.net/{}/messages",
@events =
EXTRACT SensorId int,
Data DateTime,
Value float,
State string
FROM "/user/mindflavor/sensori_arpa_2015_noheader.csv"
USING Extractors.Csv();
OUTPUT @events
TO "/user/mindflavor/output/clone.tsv"
@events =
EXTRACT SensorId int,
Data DateTime,
Value float,
State string
FROM "/user/mindflavor/sensori_arpa_2015_noheader.csv"
USING Extractors.Csv();
@gb =
SELECT COUNT( * ) AS cnt,
@stations =
EXTRACT SensorId int,
SensorType string,
Measure string,
StationId int,
StationName string,
Height int,
Province string,
City string,
Address string,
@stations =
EXTRACT SensorId int,
SensorType string,
Measure string,
StationId int,
StationName string,
Height int,
Province string,
City string,
Address string,