Skip to content

Instantly share code, notes, and snippets.

View cpereira7's full-sized avatar

cpereira7

  • Portugal
View GitHub Profile
param (
[Parameter(Mandatory=$true)]
[string]$source,
[Parameter(Mandatory=$true)]
[string]$destination
)
# Get all files to be copied
$files = Get-ChildItem -Path $source -Recurse -File
@cpereira7
cpereira7 / ListasLigadas.c
Created May 13, 2018 23:02
Antigo exercício de listas ligadas em C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _CRT_SECURE_NO_WARNINGS
struct cliente
{
int nif;
char nome[100];
/*
* Created by SharpDevelop.
* User: cpereira7
* C#, DataTable, Interfaces
*/
using System;
using System.Data;
namespace ReportGenerator
{
@cpereira7
cpereira7 / SQLPostgres.cs
Last active January 24, 2025 07:50
Select data from Postgres Database using Npgsql
/*
* Created by SharpDevelop.
* User: cpereira7
* Date: 08-11-2015
* Time: 20:06
* C#, Npgsql
*/
using System;
using System.Data;
using System.Diagnostics;
@cpereira7
cpereira7 / Csv2Doc.cs
Last active November 4, 2017 19:45
Permite criar vários documentos Word a partir de um template e substituição de campos por dados de um ficheiro CSV
using System;
using System.Collections.Generic;
using System.Reflection;
using System.IO;
using System.Diagnostics;
using System.Linq;
using Novacode;
namespace Csv2Doc
{
private static string DadosInput()
{
ConsoleKeyInfo key;
string document = "";
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("\nData: ");
Console.ForegroundColor = ConsoleColor.White;
do
{
@cpereira7
cpereira7 / exportPDF.cs
Last active November 4, 2017 19:44
Guardar documentos docx em pdf
private void ExportPDF(string nome)
{
var wordApp = new Microsoft.Office.Interop.Word.Application();
var wordDocument = wordApp.Documents.Open(nome);
wordDocument.Save();
wordDocument.ExportAsFixedFormat(nome.Replace("docx", "pdf"), Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF);
wordDocument.Close(Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges,
Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat,
false);
@cpereira7
cpereira7 / MYVLOOKUP.vbs
Created August 24, 2017 18:05
PROCV - Valores multiplos.
Function MYVLOOKUP(lookupval, lookuprange As Range, indexcol As Long)
Dim r As Range
Dim result As String
result = ""
For Each r In lookuprange
If r = lookupval Then
result = result & " - " & r.Offset(0, indexcol - 1)
End If
Next r
MYVLOOKUP = result
@cpereira7
cpereira7 / Split_Data.vbs
Last active August 24, 2017 01:28
Permite a divisão de uma tabela em multiplas sheets. Segundo ficheiro cria uma cópia para cada folha do livro.
Sub parse_data()
Dim lr As Long
Dim ws As Worksheet
Dim vcol, i As Integer
Dim icol As Long
Dim myarr As Variant
Dim title As String
Dim titlerow As Integer
vcol = 1
Set ws = Sheets("Folha1")