Skip to content

Instantly share code, notes, and snippets.

View jmelosegui's full-sized avatar

Juan Manuel Elosegui jmelosegui

View GitHub Profile
@jmelosegui
jmelosegui / Reset-MySqlRootPassword.ps1
Last active January 2, 2017 13:26
Resetting the Root Password on a Windows System
<#
.SYNOPSIS
Automation of the steps described on https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/resetting-permissions-windows.html
to reset the Root Password of MySql server on a Windows system.
.PARAMETER MysqlServiceName
The MySql service's name (e.g. MySQL56).
.PARAMETER RootPassword
The password for the root user
#>
Param(
@jmelosegui
jmelosegui / GetPicasaUserByEmail.cs
Last active October 4, 2016 19:35
Gets a Picasa user, hence a google user, using an email address.
using System;
using System.Collections.Generic;
using System.IO;;
using System.Net;
using System.Xml.Serialization;
namespace ConsoleApplication1
{
class Program
{
@jmelosegui
jmelosegui / Country.sql
Last active October 4, 2016 16:48
A Microsoft Sql Server script to add a country table to your database
IF OBJECT_ID('[dbo].[Country]', 'U') IS NOT NULL
DROP TABLE [dbo].[Country]
CREATE TABLE [dbo].[Country]
(
Id int NOT NULL IDENTITY(1,1),
Name varchar(80) NOT NULL,
DisplayName varchar(80) NOT NULL,
Iso char(2) NOT NULL,
Iso3 char(3) NULL,
@jmelosegui
jmelosegui / javascript-string-format.js
Last active September 12, 2016 16:32
Mimicking the .Net string format.
/*
This will format a string mimicking the .Net string format.
ie: format('test {0} - {1}', 'value 1', 'value 2');
*/
function format(value) {
var args = Array.prototype.slice.call(arguments, 1);
return value.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
@jmelosegui
jmelosegui / ufnAddBusinessDays.sql
Created March 17, 2016 18:23
ufnAddBusinessDays SqlServer function
CREATE FUNCTION [dbo].[ufnAddBusinessDays]
(
@Date DATE,
@n int -- Number of days to add or substract
)
RETURNS DATE
AS
BEGIN
DECLARE @d INT,@f INT,@DW INT;
Set @f = CAST(abs(1^SIGN(DATEPART(DW, @Date)-(7-@@DATEFIRST))) as bit)