Skip to content

Instantly share code, notes, and snippets.

View tomshaw's full-sized avatar
🎯
Focusing

Tom Shaw tomshaw

🎯
Focusing
View GitHub Profile
@tomshaw
tomshaw / Microsoft.PowerShell_profile.ps1
Created February 26, 2024 23:39
PowerShell Laravel Artisan Alias
# Laravel Artisan Alias
function artisan {
param (
[string]$Command
)
php artisan $Command
}
@tomshaw
tomshaw / Microsoft.Powershell_profile.ps1
Last active January 6, 2023 07:30
Windows Terminal Setup
# PowerShell 7.3.1 Profile
# Posh Git
Import-Module posh-git
$omp_config = "atomic" # Themes atomic, takuya, material, jandedobbeleer
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/$omp_config.omp.json" | Invoke-Expression
# Terminal Icons
Import-Module -Name Terminal-Icons
@tomshaw
tomshaw / app.js
Created January 10, 2022 20:03
Make the mesh follow the mouse
onMouseMove(event) {
this.mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
this.mouse.y = - (event.clientY / window.innerHeight) * 2 + 1;
// Make the sphere follow the mouse
var vector = new THREE.Vector3(this.mouse.x, this.mouse.y, 0.5);
vector.unproject( this.camera );
var dir = vector.sub( this.camera.position ).normalize();
var distance = - this.camera.position.z / dir.z;
var pos = this.camera.position.clone().add( dir.multiplyScalar( distance ) );
@tomshaw
tomshaw / Container.js
Created November 7, 2021 02:31
React Bootstrap 5 Container.
import React from "react"
import PropTypes from "prop-types"
import classNames from "classnames"
import "./Container.scss"
const Container = ({ sm, md, lg, xl, xxl, fluid, ...props }) => {
let styles = {
"container-sm": sm,
"container-md": md,
"container-lg": lg,
@tomshaw
tomshaw / Form.php
Created April 7, 2021 20:33
Laravel telephone number validators.
$this->validate($request, [
'phone' => 'required|digits:10'
]);
$this->validate($request, [
'phone' => 'required|numeric|between:9,11'
]);
$this->validate($request, [
'phone' => 'required|min:10|numeric'
@tomshaw
tomshaw / circle-circumference.js
Created December 28, 2020 17:03
Set svg circle circumference stroke.
this.$svgCircle = document.querySelector("circle");
this.circumference = 2 * Math.PI * this.$svgCircle.getAttribute("r");
setCircleProgress(amount) {
let res = amount * this.circumference / 100 + ", " + this.circumference;
this.$svgCircle.setAttribute("stroke-dasharray", res)
}
@tomshaw
tomshaw / ReleaseDownload.js
Created March 3, 2020 17:56
Vanilla javascript download progress.
// ==========================================================================
// ReleaseDownload Progress Bar
// ==========================================================================
import AbstractObject from './AbstractObject';
export default class ReleaseDownload extends AbstractObject {
constructor(el, options) {
super(el, options);
this.el = el;
@tomshaw
tomshaw / webpack.mix1.js
Created February 17, 2020 18:47
Miscellaneous Laravel MIX configurations
/*
|--------------------------------------------------------------------------
| Tailwind configuration
|--------------------------------------------------------------------------
*/
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss')
mix.js('resources/frontend/scripts/app.js', 'public/js/app.js');
@tomshaw
tomshaw / savepage.js
Created January 16, 2020 21:14
Quickly export to PDF whatever page/url.
#!/usr/bin/env node
const puppeteer = require('puppeteer');
/**
* npm link/savepage url=https://stackoverflow.com/
* Margins default to Microsoft Word A4 margins.
*/
class SavePage {
@tomshaw
tomshaw / combinations.js
Created January 8, 2020 22:36
Find combinations of input value that can win 1st, 2nd, 3rd prize.
function combinations(n) {
if (n < 0) {
return 0;
} else if (n < 3) {
return n;
}
return n * (n - 1) * (n - 2);
}
console.log(combinations(8)) // (8 - 1 = 7) * (8 - 2 = 6) = (42 * 8) = 336