Skip to content

Instantly share code, notes, and snippets.

View bredmor's full-sized avatar
🔥
This is fine.

Morgan Breden bredmor

🔥
This is fine.
View GitHub Profile
@bredmor
bredmor / ars-mailserver-add-user
Created July 23, 2014 20:09
Automated tool for adding new users to the default mailserver set up following the guide at http://arstechnica.com/information-technology/2014/02/how-to-run-your-own-e-mail-server-with-your-own-domain-part-1/
#!/bin/bash
# Add User to Postfix/Dovecot
echo -n "Enter the new email address: "
read mail_user
echo -n "Enter the new password: "
read mail_pass
echo "Adding User to Postfix Virtual Mailboxes...";
var opentiles = [];
var tileId = 0;
var currentTiles = 0;
var maxTiles = 50;
var allTiles = [];
var tile_size = 20;
function boolRand(){
return Math.random()<.5;
@bredmor
bredmor / main.py
Created December 8, 2018 01:39
2D terrain generator by /u/wtf_that_guy @ reddit
import random
import time
class RandomNoise():
"""
Random noise class to create random values in 2d array
"""
def __init__(self, width=32, height=32, bit_depth=255, extra=32):
self.w = width + extra
self.h = height + extra
@bredmor
bredmor / gist:11a4e61cb6fcb3e32570578324540b4d
Created August 19, 2019 16:27
Cygwin terminal value for jetbrains IDE
"c:\cygwin64\bin\sh" -lic "cd ${OLDPWD-.}; bash"
@bredmor
bredmor / s3.php
Created December 9, 2019 21:48
s3 presigned uri request
/**
* Get presigned url to access xml file directly on s3.
*/
public function getXmlUrlAttribute()
{
$client = Storage::disk('s3')->getAdapter()->getClient();
$command = $client->getCommand('GetObject', [
'Bucket' => config('filesystems.disks.s3.bucket'),
'Key' => $this->xml_path,
]);
@bredmor
bredmor / MathHelper.php
Last active December 4, 2020 13:26
BCMath functions helper for laravel
<?php
namespace App\Helpers;
/**
* Class MathHelper
* @package App\Helpers
*
* Implements negative, ceiling, floor and round functions with BCMath precision
* Credit to Matt Raines for function logic: https://stackoverflow.com/users/5024519/matt-raines
*/
@bredmor
bredmor / NovaServiceProvider.php
Created June 16, 2020 16:59
Forwarding Laravel Nova GET parameters to filters/cards/metrics/etc.
class NovaServiceProvider extends NovaApplicationServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
parent::boot();
@bredmor
bredmor / php74.sh
Last active July 15, 2020 20:16
Install php 7.4 on Ubuntu 16/18
sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt -y install php7.4
sudo apt-get install -y php7.4-{bcmath,bz2,common,curl,intl,gd,mbstring,mysql,opcache,xml,zip}
@bredmor
bredmor / .bash_aliases
Last active August 5, 2020 12:51
EZ Timelog
alias tlog='bash ~/tlog.sh'
alias tend='bash ~/tend.sh'
alias tview='cat ~/work.txt'
#include <cstdio>
#include <windows.h>
#define INPUT_MAX 255
void main()
{
wchar_t wstr[INPUT_MAX];
char mb_str[INPUT_MAX * 3 + 1];
unsigned long readln;