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
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',
<?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 / 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;
@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');
<?php
// suppose class FancyPost extends Post
// Do things using the Post class
$myPost = new Post();
Post::doSomething();
// Override
Post::mapClass('FancyPost');