Skip to content

Instantly share code, notes, and snippets.

View bugzbrown's full-sized avatar

Gregory Brown bugzbrown

View GitHub Profile
@bugzbrown
bugzbrown / masks.js
Created October 22, 2020 12:50
Creates simple mask functions for inputs
export const TelephoneMask = (value) => {
return value
.replace(/\D/g, '')
.replace(/(\d{2})(\d)/, '($1) $2')
.replace(/(\d{4})(\d)/, '$1-$2')
.replace(/(\d{4})-(\d)(\d{4})/, '$1$2-$3')
.replace(/(-\d{4})\d+?$/, '$1')
}
@bugzbrown
bugzbrown / resize_on_save_model
Created February 23, 2020 14:55
Resize Image on Save octoberCMS
use October\Rain\Database\Attach\Resizer;
class ClassName extends Model{
public $attachOne = [
'img' => 'System\Models\File',
];
public function afterSave(){
$imgPath = $this->img->getLocalPath();
@bugzbrown
bugzbrown / install_octoberCMS
Created January 5, 2020 09:50
OctoberCMS Shell Installer script
echo "CREATE SCRIPT"
echo '#!/bin/bash' >> october_install
echo "mkdir \$1
cd \$1
php -r \"eval('?>'.file_get_contents('https://octobercms.com/api/installer'));\"
" >> october_install
chmod +x october_install
echo "MOVE TO usr/local/bin"
sudo mv october_install /usr/local/bin
@bugzbrown
bugzbrown / _breakpoints.scss
Last active December 6, 2019 13:58
SCSS Breakpoint Mixin
@mixin respond-to($breakpoint) {
// If the key exists in the map
@if map-has-key($breakpoints, $breakpoint) {
// Prints a media query based on the value
@media #{inspect(map-get($breakpoints, $breakpoint))} {
@content;
}
}
// If the key doesn't exist in the map
@bugzbrown
bugzbrown / lat-long.js
Created November 5, 2019 21:56
calcular distância entre 2 pontos num mapa
function distance(lat1, lon1, lat2, lon2, unit) {
if ((lat1 == lat2) && (lon1 == lon2)) {
return 0;
}
else {
var radlat1 = Math.PI * lat1/180;
var radlat2 = Math.PI * lat2/180;
var theta = lon1-lon2;
var radtheta = Math.PI * theta/180;
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="themes/.*/(layouts|pages|partials)/.*.htm" />
<action type="Rewrite" url="index.php" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
@bugzbrown
bugzbrown / mysqlfix.md
Created June 4, 2019 01:20
Step by step fix for mysql problems on mac.

FIX MYSQL INSTALL ON MAC

Make sure You have open ssl

brew install openssl

If you are installing Mysql 8:

@bugzbrown
bugzbrown / Plugin.php
Last active July 7, 2021 11:43
Get Plugin System Settings from your templates with a twig extension in OctoberCMS
/*
* In your plugin.php file add the following function
*/
<?php
//...
public function registerMarkupTags()
{
return [
'functions' => [
@bugzbrown
bugzbrown / run.sh
Last active December 3, 2017 17:16
Quick start for running GhostBlog on your computer with docker
#!/bin/env bash
MY_PATH=$(pwd)
PORT=${1:-8080}
docker run -p $PORT:2368 -v $MY_PATH:/var/lib/ghost/content --env NODE_ENV=development ghost
@bugzbrown
bugzbrown / mysql.js
Created November 1, 2017 02:28
MySQL helper for node apps
var mysql = require('mysql')
, async = require('async')
, config = require('config');
var state = {
pool: null,
mode: null,
}
exports.connect = function(done) {