Skip to content

Instantly share code, notes, and snippets.

View alexweissman's full-sized avatar
💭
For the glory of the swarm

Alex Weissman alexweissman

💭
For the glory of the swarm
View GitHub Profile
@alexweissman
alexweissman / BelongsToManyThrough.php
Last active May 12, 2023 07:58
Custom BelongsToManyThrough relationship for Laravel/Eloquent
<?php
/**
* UserFrosting (http://www.userfrosting.com)
*
* @link https://github.com/userfrosting/UserFrosting
* @copyright Copyright (c) 2013-2017 Alexander Weissman
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
namespace UserFrosting\Sprinkle\Core\Model\Relations;
var CryptoJS = require('crypto-js');
var timestamp = Date.now().valueOf();
var secret = pm.collectionVariables.get('secret');
var payload = pm.request.body.raw;
var signature = CryptoJS.HmacSHA256(timestamp + '.' + payload, secret);
pm.request.headers.add({
key: 'Stripe-Signature',
@alexweissman
alexweissman / README.md
Last active January 23, 2021 18:18
Migrating email accounts from a cPanel hosting environment to Mail-in-a-Box

Migrating email accounts from a cPanel hosting environment to Mail-in-a-Box

Part 1: Pregame

  1. Send a mass email to all of your account holders, letting them know that you will be migrating their email accounts to a new server. Send them the instructions from MiaB control panel for connecting to your MiaB server from their mobile/Outlook/Gmail/etc, if applicable. Also, send them a link to the new webmail address. Be sure to give adequate advanced notice (several days, if possible). Advise them to not change their passwords during this time (their passwords will be preserved during migration).
  2. Create a new "test" email account in the MiaB control panel for your domain. This will let MiaB set up the DNS records needed for the domain.

Part 2: Copy credentials

Copy the email account credentials from your cPanel host to MiaB:

<?php
namespace UserFrosting\Sprinkle\Site\Database\Concerns;
/**
* Implements event and linking methods for extended models.
*
* Set the member variable $auxType in your derived class.
*/
trait HasAuxModel
{
@alexweissman
alexweissman / links.md
Last active February 7, 2018 23:48
Template responses to Select2 issues
@alexweissman
alexweissman / example.js
Created August 9, 2017 17:46
Example setup for select2 with pagination and a Sprunjed endpoint
// Institution select
form.find("select[name='institutions[]']").select2({
ajax: {
url: site.uri.public + "/api/institutions",
dataType: "json",
delay: 250,
data: function (params) {
return {
filters: {
name : params.term
@alexweissman
alexweissman / uf-collection-2.js
Created May 10, 2017 23:03
Improvements to ufCollection
/**
* uf-collection plugin. Widget for attaching/detaching related items to a single parent item (e.g. roles for a user, etc).
*
* === USAGE ===
*
* uf-collection can be initialized on a div element as follows:
*
* $("#myCollection").ufCollection(options);
*
* `options` is an object containing any of the following parameters:
@alexweissman
alexweissman / mycrap.html.twig
Last active March 28, 2017 22:10 — forked from abdullahseba/mycrap.twig
Abdullah's crap
{% extends "layouts/dashboard.html.twig" %}
{% block body_matter %}
<table>
<thead>
<th>From</th>
<th>Subject</th>
</thead>
<tbody id="email-messages-body"></tbody>
<?php
namespace UserFrosting\Sprinkle\ExtendUser\Model;
use Illuminate\Database\Capsule\Manager as Capsule;
use UserFrosting\Sprinkle\Account\Model\User;
use UserFrosting\Sprinkle\ExtendUser\Model\Owler;
class OwlerUser extends User {
protected $fillable = [
@alexweissman
alexweissman / 1.0.0-dev.php
Created January 30, 2017 23:32
Basic migration for your sprinkle. Create in sprinkles/site/migrations/
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint;
/**
* Volunteer table
*/
if (!$schema->hasTable('volunteers')) {
$schema->create('volunteers', function (Blueprint $table) {
$table->increments('id');