Skip to content

Instantly share code, notes, and snippets.

View pnmcosta's full-sized avatar
🥷
coding remotely

Pedro Maia Costa pnmcosta

🥷
coding remotely
View GitHub Profile
@pnmcosta
pnmcosta / adapter.go
Last active July 31, 2023 09:07
Pocketbase ApiScenario TestAppFactory with mocks
package main
//go:generate go run -mod=mod github.com/golang/mock/mockgen -package main -destination=adapter_mock.go -source=./adapter.go -build_flags=-mod=mod
type (
ExternalAdapter interface {
ExternalCall() error
}
externalAdapter struct {
}
@pnmcosta
pnmcosta / computeFileHash.ps1
Created August 27, 2019 14:48
PS script to compute a new file hash for a modified BACPAC
param (
[string]$fileName = "model.xml"
)
If (Test-Path $fileName) {
$modelXmlPath = Resolve-Path $fileName
} else {
Write-Host ("File " + (Resolve-Path .) + "\" + $fileName + " does not exist");
exit;
}
@pnmcosta
pnmcosta / components-properties.html
Last active November 13, 2018 10:52
Total.js CMS Admin Component
<script total>
// register component in admin group
exports.group = 'admin';
exports.install = function() {
// MODEL: /schemas/properties.js
ROUTE('GET #admin/api/properties/ *Property --> @query', ['&admin', 'id:properties']);
ROUTE('GET #admin/api/properties/{id}/ *Property --> @read', ['&admin', 'id:properties']);
};
exports.uninstall = function() {
@pnmcosta
pnmcosta / totaljs-cms-deep-clean.js
Created November 1, 2018 12:24
Total.js Scripts
require('total.js');
var clean = function(name) {
return function(next) {
TABLE(name + 'data').remove().like('id', '_').callback(function() {
TABLE(name + 'data').clean();
NOSQL(name).clean();
next();
});
};
};
@pnmcosta
pnmcosta / ContentNoticesMasonry-template.html
Last active August 11, 2018 10:19
Total.js CMS widgets template suggestion
<!-- This is a suggestion based on https://github.com/totaljs/widgets/blob/master/ContentNoticesMasonry/widget.html -->
<style>
.wc140 { column-width: 280px; column-gap: 20px; width: 100%; margin: 30px auto; }
.wc140 figure { width: 100%; background: white; border: 1px solid #E0E0E0; margin: 0 2px 20px; padding: 15px; display: inline-block; column-break-inside: avoid; border-radius: 4px; line-height: 18px; }
.wc140 .date { font-size: 11px; color: #A0A0A0; margin-bottom: 10px; }
.wc140 .date .fa { margin-right: 5px; }
.wc140 figure img { border-radius: 3px; }
.wc140 figure code { background-color: #F0F0F0; padding: 1px 3px; border-radius: 3px; font-size: 12px; }
.wc140 figure blockquote { background-color: #F0F0F0; padding: 10px; margin: 0 0 15px; border-radius: 4px; }
.wc140 figure p { margin-top: 0; margin-bottom: 15px; }
@pnmcosta
pnmcosta / work.html
Created August 6, 2018 13:39
Total.js CMS admin component
// Add this file to /components/ directory
<script total>
// groups this component with admin
exports.group = 'admin';
exports.install = function() {
// include custom routes here
};
</script>
@pnmcosta
pnmcosta / git-diff-archive.bat
Created June 5, 2018 18:15
Git commands to create archives of diff's
# START Create Archives
# Author: Pedro Maia Costa <hello@pmcdigital.pt>
# Note: Please see Gist first comment, replace $var-name below with your values before running.
# Create an archive of the entire current branch
git archive -o ..\deploys\full.zip HEAD
# Create a diff of the files that are different between commits
git diff --no-commit-id --name-only --diff-filter=ACMRT $commitid > ../deploys/diff_$commitid.txt
@pnmcosta
pnmcosta / vsts-fork-commands.sh
Last active July 4, 2022 05:31
Git commands to fork (and rebase) from GitHub to VSTS
# START Create Fork
# Author: Pedro Maia Costa <hello@pmcdigital.pt>
# Note: Please see Gist first comment, replace <var-name> below with your values before running.
# fork branch into vsts
cd your-project
git init .
# the target <your-repo> as origin
git remote add origin https://<your-vsts>.visualstudio.com/<your-repo-url>
@pnmcosta
pnmcosta / all-sundays.js
Created February 7, 2018 11:13
Get all sundays from current month till years end (Node.js)
var template = `Dia: {0}
Hora inicio: 08h00
Briefing: 08h30
Fim: 12h30
Duração: 04h00m
\r\n`;
var monthNames = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho",
"Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
];
@pnmcosta
pnmcosta / bootstrap-datepicker-single-inline-date-range.js
Last active February 9, 2023 12:33
bootstrap-datepicker single inline date range selection
/* *************** HTML *****************
* <div class="form-group search-calendar">
* <h3>Data</h3>
* <div class="bs-datepicker">
* <div class="range-start"></div>
* <div class="range-end"></div>
* </div>
* <div class="row no-gutter">
* <div class="col-md-6">
* <input type="text" name="range-end" value="" placeholder="de" class="form-control range-input" />