Skip to content

Instantly share code, notes, and snippets.

View smitmartijn's full-sized avatar

Martijn Smit smitmartijn

View GitHub Profile

GitHub Copilot Custom Instructions for Qt C++ & WhatPulse Desktop App

These instructions guide Copilot to generate code that aligns with modern Qt C++ standards, C++20/23 features, software engineering principles, and industry best practices to improve software quality, maintainability, and performance for the WhatPulse desktop application.

✅ General C++ Coding Standards

  • Follow Google C++ Style Guide or Core Guidelines for consistent code structure
  • Use meaningful, descriptive variable, function, class, and file names
  • Apply proper Doxygen comments for classes, methods, and complex logic
  • Organize code into small, reusable functions or classes with single responsibility

GitHub Copilot Custom Instructions for Laravel 12 & PHP 8.2/8.4

These instructions guide Copilot to generate code that aligns with modern Laravel 12 standards, PHP 8.2/8.4 features, software engineering principles, and industry best practices to improve software quality, maintainability, and security.

✅ General Coding Standards

  • Follow PSR-12 coding style and structure.
  • Prefer short, expressive, and readable code.
  • Use meaningful, descriptive variable, function, class, and file names.
  • Apply proper PHPDoc blocks for classes, methods, and complex logic.
# Nuclear restart of SSHD and all connections
$sshConnections = Get-NetTCPConnection -LocalPort 22 -State Established -ErrorAction SilentlyContinue
Stop-Service sshd
foreach ($conn in $sshConnections) {
$process = Get-Process -Id $conn.OwningProcess -ErrorAction SilentlyContinue
if ($process) {
Stop-Process -Id $process.Id -Force
}
const fullTextRaw = $json["body"]["text"] || "";
const fullText = fullTextRaw.trim(); // remove leading/trailing whitespace
const lines = fullText.split('\n').map(line => line.trim());
// Look for lines
const summaryLine = lines.find(line => line.includes("Cloudflare Pages:"));
const commitLine = lines.find(line => line.startsWith("Commit Hash:"));
const envLine = lines.find(line => line.startsWith("Environment:"));
// If any line is missing, exit the workflow
function Compare-XmlContent {
param (
[Parameter(Mandatory=$true)]
[string]$FirstXml,
[Parameter(Mandatory=$true)]
[string]$SecondXml,
[Parameter(Mandatory=$false)]
[switch]$IgnoreWhitespace,
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = [ "canvas" ]
static values = {
numberOfRows: Number,
labels: Array,
data: Array
}
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
if (message.action === "googleMeetBringToFront") {
chrome.tabs.query({}, function (tabs) {
let meetFound = false;
for (let i = 0; i < tabs.length; i++) {
if (tabs[i].url.includes('meet.google.com')) {
meetFound = true;
chrome.tabs.update(tabs[i].id, { selected: true });
chrome.windows.update(tabs[i].windowId, { focused: true });
@smitmartijn
smitmartijn / install.sh
Created February 26, 2024 12:52
Installing TailwindCSS with VuePress v1
npm uninstall tailwindcss postcss autoprefixer
npm install tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
@smitmartijn
smitmartijn / laravel-tmuxp.yaml
Created August 10, 2023 09:19
Run a Laravel app in a tiled tmux window with a single command.
# brew install tmuxp
# tmuxp load tmuxp.yaml
session_name: laravel-app
windows:
- window_name: laravel-app
layout: tiled
panes:
- docker-compose -f docker-compose.yml up
- php artisan serve
- npm run dev
@smitmartijn
smitmartijn / ApiSearchController.php
Created April 11, 2023 15:13
Laravel API token authentication
/**
* Laravel's Sanctum is not great at validating bearer tokens.
* If you want to validate a token for more than "does it exist", you need to do it manually.
* Here's an example inside an controller:
*/
class ApiSearchController extends Controller
{
public function store(Request $request)
{