Skip to content

Instantly share code, notes, and snippets.

View rberrelleza's full-sized avatar
👋
Hi friend!

Ramiro Berrelleza rberrelleza

👋
Hi friend!
View GitHub Profile
@rberrelleza
rberrelleza / WaitForProcess.cmd
Created March 27, 2012 22:24
Script that blocks the command line until process starts running
@echo off
set loops=0
set process=%1
:WaitForProcessToStart
if /i %loops% gtr 10 (
echo Process didn't started on time
exit /b 1
)
@rberrelleza
rberrelleza / UseServiceBusFromPowershell.ps1
Created March 27, 2012 23:55
Send and receive messages to a Service Bus queue via PowerShell
Import-Module "PATH_TO_Microsoft.ServiceBus.dll"
#Create the required credentials
$tokenProvider = [Microsoft.ServiceBus.TokenProvider]::CreateSharedSecretTokenProvider("owner", "YOUR_ISSUERSECRET")
$namespaceUri = [Microsoft.ServiceBus.ServiceBusEnvironment]::CreateServiceUri("sb", "YOUR_NAMESPACE", "");
$namespaceManager = New-Object Microsoft.ServiceBus.NamespaceManager $namespaceUri,$tokenProvider
#Create a queue
$queue = $namespaceManager.CreateQueue("MyPowershellQueue");
@rberrelleza
rberrelleza / QueryTableSize.sql
Created May 11, 2012 00:13
Query to see the size of all tables on a DB
select sysobj.name, sum(reserved_page_count) * 8.0 / 1024 as 'total size (MB)'
from sys.dm_db_partition_stats sysstats, sys.objects sysobj
where sysstats.object_id = sysobj.object_id and sysobj.schema_id = schema_id('dbo')
group by sysobj.name;
@rberrelleza
rberrelleza / UTCToLocal.sql
Created July 11, 2012 22:21
Transform UTC to LocalTime on SQL Server 2008
SELECT Convert(datetime, SWITCHOFFSET(CONVERT(datetimeoffset,[ColumnWithUTCTime]), DATENAME(TzOffset, SYSDATETIMEOFFSET()))) AS LocalTime
FROM TABLE
@rberrelleza
rberrelleza / WebClientClientCertificateAuth.cs
Created September 13, 2012 01:53
Use client certificate authentication with System.Net.WebClient
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography.X509Certificates;
using System.Net;
using System.Net.Security;
namespace WebClientClientCertificateAuth
{
@rberrelleza
rberrelleza / delete
Created December 19, 2012 23:29
Delete all files and folders recursevely on *nix
rm -Rf
@rberrelleza
rberrelleza / title
Created December 21, 2012 22:26
Update terminal title
title=$1
echo -n -e "\033]0;$title\007"
@rberrelleza
rberrelleza / killall
Last active December 11, 2015 07:59
kill all processes that match
kill -9 `ps aux | grep 'my_rogue_process.py' | grep -v grep | awk '{print $2}'`
@rberrelleza
rberrelleza / get_ip
Created January 25, 2013 02:39
Script to get the ip of a machine assigned to a variable on UBUNTU.
MACHINE_IP=`ifconfig eth0 | grep inet | grep -v inet6 | awk '{print substr($2, 6)}'`
echo $MACHINE_IP
@rberrelleza
rberrelleza / get_windows_amis.py
Last active December 13, 2015 23:29
Python script to get all the valid windows AMI from an AWS region
import boto.ec2
if __name__ == '__main__':
zones = ['us-east-1', 'us-west-2', 'us-west-1', 'eu-west-1', 'ap-southeast-1',
'ap-northeast-1', 'ap-southeast-2', 'sa-east-1']
for zone in zones:
connection = boto.ec2.connect_to_region(
region_name=zone,