Skip to content

Instantly share code, notes, and snippets.

View glmdev's full-sized avatar
🍵
Migrated to Gitea!

Garrett Mills glmdev

🍵
Migrated to Gitea!
View GitHub Profile
@glmdev
glmdev / bitwarden.yml
Created March 4, 2022 14:10
bitwarden.yml
---
- name: Setup Vaultwarden
hosts: target
become: yes
become_user: root
tasks:
- include: ../tasks/base.yml
- name: Install libs
dnf:
@glmdev
glmdev / timeouts.ts
Created July 30, 2020 15:11
TypeScript/JavaScript timeout handler - withTimeout
/*
This is a simple function I wrote to make awaiting promises with timeouts easier.
Pass it in a timeout length and a promise, and you can attach handlers for when
the promise resolves on time, when it resolves late, and when the timeout expires.
Here's a snippet from one of my projects as an example:
withTimeout(request_timeout, this.kernel.handle(req))
.on_time(output_req => { // called if it resolves on time
@glmdev
glmdev / calculate.py
Last active April 29, 2019 15:58
A modified version of the Pi-calculation script from the mpi4py repository.
from mpi4py import MPI
from math import pi as PI
from numpy import array
def comp_pi(n, myrank=0, nprocs=1):
h = 1.0 / n
s = 0.0
for i in range(myrank + 1, n + 1, nprocs):
x = h * (i - 0.5)
s += 4.0 / (1.0 + x**2)
#!/bin/bash
VERSION="1.3"
AUTHOR="Garrett Mills"
NODECOUNT=1
NTASKS=1
PARTITION=sixhour
SHELL=bash
JOBNAME="getnode"
const newton = (x0, fn, derivative) => {
const estimates = [x0]
let next, last
while ( estimates.slice(-1).pop() > 0.09 ){
last = estimates.slice(-1)[0]
next = last - (fn(last)/derivative(last))
@glmdev
glmdev / newton.js
Created October 3, 2018 00:20
A Javascript function to run a Newton's Method sequence
const newton = (x0, fn, derivative, precision=3, array=false) => {
const estimates = [x0]
let next, last, variation = 1
while ( variation > (Math.pow(10, (-1 * precision))) ){
last = estimates.slice(-1)[0]
next = last - (fn(last)/derivative(last))
estimates.push(next)
<?php
/**
* Searches the collection of given $models for
* $string and returns the results.
*
* @param \Illuminate\Support\Collection $models
* @param $string
* @param $fields
* @return \Illuminate\Support\Collection
@glmdev
glmdev / onedrive-ubu.sh
Last active April 24, 2020 05:40
A bash script to setup OneDrive integration with GNOME on Ubuntu.
#!/bin/sh
# onedrive-ubu.sh
# A BASH script to set up OneDrive integration with GNOME on Ubuntu
# Copyright (C) 2018 Garrett Mills (garrett@glmdev.tech)
# This software is licensed under the MIT License.
# This sofware is provided without warranty or even any implied intent of purpose.
#
# OnedriveD: https://github.com/xybu/onedrived-dev
@glmdev
glmdev / projects.txt
Created September 25, 2017 01:39
A list of future project ideas
Tidbit Laravel plugin
@glmdev
glmdev / LICENSE
Created June 17, 2017 20:53
Bootstrap Confirm Button Plugin
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for