Skip to content

Instantly share code, notes, and snippets.

@juancho618
juancho618 / db_tools.ps
Created April 25, 2019 13:18
Generate BACKUP AND RESTORE DB
#Copies and restore from DB_A to DB_B
Copy-DbaDatabase -Source $TestDB -SourceSqlCredential (Get-Credential CDC_User) -Destination $TestDB -DestinationSqlCredential (Get-Credential CDC_User) -Database CDC -NewName CDC_Test -WithReplace -BackupRestore -UseLastBackup -Force
#others:
#Backup-DbaDatabase -SqlInstance $localDb -Database TEST_DB -BackupDirectory C:\Temp\DatabaseBCKUP -IgnoreFileChecks
#Backup-DbaDatabase -SqlInstance $TestDB -SqlCredential (Get-Credential CDC_User) -Database CDC
#Backup-DbaDatabase -SqlInstance $devDB -SqlCredential (Get-Credential SCALE) -Database CDC -IgnoreFileChecks -BuildPath -BackupDirectory \devDB
@juancho618
juancho618 / RegEx VIB VBA
Last active February 19, 2020 09:18
RegEx for VIN in VBA
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer
Dim regEx As Object
Set regEx = CreateObject("VBScript.RegExp")
Dim strInput As String
Dim strPattern As String: strPattern = "^[a-zA-Z0-9]{9}[a-zA-Z0-9-]{2}[0-9]{6}"
For i = 2 To 10000
strInput = Sheet1.Cells(i, 1).Value
If (strInput <> "") Then
@juancho618
juancho618 / task.js
Created June 11, 2018 15:01
Batch processing for OCR Documents
const util = require('util');
const fs = require('fs.extra');
const path = require('path');
// const { exec } = require('child_process').exec;
const exec = util.promisify(require('child_process').exec);
// async fs function
fs.readdirAsync = dirname => {
return new Promise(function(resolve, reject) {
fs.readdir(dirname, function(err, filenames){
@juancho618
juancho618 / IBANvalidation.vba
Created May 9, 2018 11:54
Validate the IBAN on VBA
Private Sub CommandButton1_Click()
Dim ibanStr, result As String
Dim i As Integer
Dim rr As Boolean
i = 2
' ibanStr = InputBox("Enter IBAN", "As a String")
' result = VALIDATEIBAN(ibanStr)
' MsgBox (result)
Private Sub CommandButton1_Click()
Dim i, x As Integer
i = 2
While Sheet1.Cells(i, 2) <> Empty
x = 2
While Tabelle1.Cells(x, 2) <> Empty
If (Sheet1.Cells(i, 2) = Tabelle1.Cells(x, 2)) Then
Sheet1.Cells(i, 8) = "done"
Tabelle1.Cells(x, 124) = "YES"
@juancho618
juancho618 / cs
Created July 9, 2016 17:16
String Consecutive
public JsonResult Consecutivo(string id)
{
string letra = id.Substring(0, 1);
int centecima = int.Parse(id.Substring(1, 1));
int decima = int.Parse(id.Substring(2, 1));
int unidad = int.Parse(id.Substring(3, 1));
char[] alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
if (unidad<9)
{
unidad++;
@juancho618
juancho618 / gist:c5f4643273e75267aefd5abdf2709da6
Created June 30, 2016 22:42
Create a git repo via console
curl -u 'juancho618' https://api.github.com/user/repos -d '{"name":"ReservasRuby"}'
# Remember replace USER with your username and REPO with your repository/application name!
git remote add origin git@github.com:juancho618/ReservasRuby.git
git push origin master
curl -i -u "my_user_name:my_password" -X PUT -d '' 'https://api.github.com/repos/my_gh_userid/my_repo/collaborators/my_collaborator_id'