Skip to content

Instantly share code, notes, and snippets.

View smitmartijn's full-sized avatar

Martijn Smit smitmartijn

View GitHub Profile
# 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)
{
import asyncio
from Smile import Smile
import json
async def main():
smile = Smile("192.168.0.0", "password")
await smile.connect()
await smile.update_locations()
# Get the current power consumption in watts
@smitmartijn
smitmartijn / app.js
Created November 11, 2022 15:54
MuteDeck Stream Deck Plugin
/* global $CC, Utils, $SD */
/* THIRD PARTY */
// https://github.com/joewalnes/reconnecting-websocket/blob/master/reconnecting-websocket.js
(function(global, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = factory();
} else {