Skip to content

Instantly share code, notes, and snippets.

View zach2825's full-sized avatar

The Zach zach2825

View GitHub Profile
@zach2825
zach2825 / ModelListCommand.php
Created January 24, 2024 13:23
ModelListCommand.php
<?php
namespace App\Console\Commands;
use File;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use ReflectionClass;
use ReflectionException;
@zach2825
zach2825 / AdventDay1.php
Created January 11, 2024 17:01
Advent day 1 part 2
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
/**
* https://adventofcode.com/2023/day/1/input
* https://adventofcode.com/2023/day/1
*/
@zach2825
zach2825 / PasswordResetCommand.php
Created August 17, 2023 20:18
Laravel command to reset user passwords
<?php
namespace App\Console\Commands;
use App\Models\User;
use DB;
use Exception;
use Illuminate\Console\Command;
use function Laravel\Prompts\info;
@zach2825
zach2825 / SampleComponentVue3.vue
Created January 17, 2023 19:34
SampleComponent vue3 vue.extend replacement
<template>
<div>
Welcome<br />
<SampleVueComponent :testing-prop="'test'" />
</div>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
<template>
<div @click="someTest">
{{preMessage}} {{message}}
</div>
</template>
<script lang="ts">
interface Mehtods {
someTest: () => void;
}
@zach2825
zach2825 / read_env.py
Created December 27, 2022 17:52
python read venv value or all keys into a dictionary
from typing import Dict, Union
def read_env(key: str = False, default_value: str = '') -> Union[str, Dict[str, str]]:
"""
Open the venv/pyvenv.cfg file for reading and return a key value or all the settings
:param key:
:param default_value:
:return:
"""
@zach2825
zach2825 / useFileUpload.js
Created August 2, 2021 14:29
React hook for uploading files to an s3 presigned url. this required the useService hook
import { useState } from 'react';
import useService, { DELETE, PUT } from 'hooks/useService';
const useFileUploadHook = () => {
const [{}, fireApi] = useService();
const [filesUploaded, setFilesUploaded] = useState(1);
const [uploading, setUploading] = useState(false);
const [overallProgress, setOverallProgress] = useState(0);
const mashToS3 = async ({ file, goalPercentage, url }) => {
@zach2825
zach2825 / usePolling.js
Created August 2, 2021 14:20
react polling hook
import { useState, useEffect } from 'react';
const usePolling = ({
timeoutMs = 5000,
continuePolling,
} = {}) => {
const [ticker, setTicker] = useState(null);
const [onContinuePolling, setOnContinuePolling] = useState(null);
useEffect(() => {
@zach2825
zach2825 / .editorconfig
Last active September 4, 2020 13:04
EditorConfig
# http://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
@zach2825
zach2825 / sleeper and looper.js
Last active February 14, 2020 21:54
JS sleep
import {randomString} from './string';
export const sleeper = (ms, {message = undefined, debug = false} = {}) => {
debug && console.log("sleeper initialized");
const hash = randomString();
const registry = {valid: true, tickCount: 0, timers: []};
let timer = null;