Skip to content

Instantly share code, notes, and snippets.

View jamesasu's full-sized avatar

James Angus jamesasu

View GitHub Profile
@jamesasu
jamesasu / regex.java
Created September 30, 2024 05:37
java-regex-negative-lookbehind-lookahead.java
Pattern newProjectPattern = Pattern.compile("(?<=before)(Stuff to actually find)(?=after)");
Matcher newProjectMatcher = newProjectPattern.matcher(str);
if (newProjectMatcher.find()) {
return newProjectMatcher.group(1).trim();
}
Map a Mac keyboard so it has Windows shortcuts
https://karabiner-elements.pqrs.org/
https://ke-complex-modifications.pqrs.org/#pc_shortcuts
{
"description": "PC-Style Screenshot to File (PrintScreen to select)",
<?php
class Hello {
protected string $name = '';
public function __construct() {
return $this;
}
public function setName(string $name): Hello {
const functions = require('@google-cloud/functions-framework');
const express = require('express');
const app = express();
// GET /myFunction
app.get('/', async (req, res) => {
res.status(200).send('Default route');
});
// GET /myFunction/other
# Add this command line option:
-XX:+ShowCodeDetailsInExceptionMessages
.select {
background-image: url("data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201000%201805.18%22%3E%3Cpath%20fill%3D%22%23595d64%22%20d%3D%22M461.6%2C643.4L10.9%2C79.9C-14.9%2C47.7%2C8%2C0%2C49.3%2C0h901.5c41.2%2C0%2C64.1%2C47.7%2C38.4%2C79.9L538.4%2C643.4%09C518.7%2C668%2C481.3%2C668%2C461.6%2C643.4z%22%20transform%3D%22rotate(180%20500%20902.59)%20translate(0%201143.28)%22%3E%3C%2Fpath%3E%3Cpath%20fill%3D%22%23595d64%22%20d%3D%22M461.6%2C643.4L10.9%2C79.9C-14.9%2C47.7%2C8%2C0%2C49.3%2C0h901.5c41.2%2C0%2C64.1%2C47.7%2C38.4%2C79.9L538.4%2C643.4%09C518.7%2C668%2C481.3%2C668%2C461.6%2C643.4z%22%20transform%3D%22translate(0%201143.28)%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E");
background-position: right calc(7px) top 50%;
}
@jamesasu
jamesasu / 1password-read-gcs-service-account-to-file.sh
Created January 9, 2024 22:49
Read a JSON file from 1password onto disk
$ op read --out-file my-service-account.json "op://My Vault/My Record/my-service-account.json"
$ chmod 644 my-service-account.json
@jamesasu
jamesasu / clientside.gitlab-ci.yml
Last active December 5, 2023 06:03
Build a clientside project and deploy to Google Cloud Storage
stages:
- build
- test
- deploy
variables:
NODE_ENV: production
build:
stage: build
@jamesasu
jamesasu / jest-sleep.js
Created December 1, 2023 03:33
Need to sleep/wait in a jest test?
test('Wait for 1 second', async () => {
runBeforeTheDelay();
await new Promise((r) => setTimeout(r, 1000));
runAfterTheDelay();
});
/*
// Usage:
<button id="counter" type="button"></button>
import { setupCounter } from './counter.js'
setupCounter(document.querySelector('#counter'))
*/
export function setupCounter(element) {