Skip to content

Instantly share code, notes, and snippets.

View bpicolo's full-sized avatar
🐳
print(status)

Ben Picolo bpicolo

🐳
print(status)
View GitHub Profile
@bpicolo
bpicolo / authenticationService.ts
Last active July 2, 2021 13:38
Data-race free Auth0 in any Javascript framework
/**
* I'm not a fan of Auth0's suggested implementation for Javascript presentation frameworks -
* they tie in too directly (using Vue lifecycle hooks, React useEffect).
* This leads to having to restructure your entire app around your authentication implementation
*
* React and Vue primarily serve as presentation layers, but your application domain logic often
* can and should live outside of your presentation layer. This makes authenticating with Vue lifecycle hooks
* or useEffect an antipattern for me, because it leads to either parameter drilling down to your business logic,
* or race conditions between your business logic and view lifecycles.
*
@bpicolo
bpicolo / pipes.py
Last active November 14, 2017 20:58
pypes
def pipe(arg, *fns):
out = arg
for fn in fns:
out = fn(out)
return out
result = pipe(
1,
lambda x: x + 2,

Keybase proof

I hereby claim:

  • I am bpicolo on github.
  • I am bpicolo (https://keybase.io/bpicolo) on keybase.
  • I have a public key ASAuNpZ-nmZaYiXMA6pgf1RGu4GNU0Am51G-XoFdwIejBQo

To claim this, I am signing this object:

@bpicolo
bpicolo / .pre-commit-hooks.yaml
Last active January 31, 2017 19:20
Pre-commit docker hook
- id: gofmt
name: gofmt
entry: gofmt
description: gofmt delivered via docker
language: docker
files: \.go$
@bpicolo
bpicolo / GridScalar.cs
Last active May 23, 2021 23:09
Dynamic Grid Scaling for Unity UI grids
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
/**
* Scale a GridLayoutGroup according to resolution, etc.
* This is using width-constrained layout
*/
public class GridScalar : MonoBehaviour {
@bpicolo
bpicolo / CharacterMover.cs
Created October 26, 2016 23:18
Unity3D point and click style movement.
using UnityEngine;
using System;
[RequireComponent(typeof(CharacterController))]
public static class CharacterMover
{
public static void ProgressMovement (CharacterController cc, Vector3 destination, float speed, float turnSpeed)
{
if (cc.transform.position == destination) {
return;
@bpicolo
bpicolo / trailing_slash_tween.py
Last active August 23, 2016 02:38
A python Pyramid tween to redirect routes that end in a slash to not end in a slash
# -*- coding: utf-8 -*-
from pyramid.httpexceptions import HTTPMovedPermanently
from urllib.parse import urlunparse
from urllib.parse import urlparse
def trailing_slash_tween(handler, registry):
"""Redirect any route ending with a / to not have a slash."""
def tween(request):
(defn vec-to-map [k vect]
;; Given a key function, k, of 1 arg
;; create a mapping from key->item
;; for the items in a vector
(into {} (map (juxt k identity) vect)))
sub:
(register-sub
:tags
(fn [db _]
(reaction (vals (:tags @db)))))
handler:
(register-handler
:add-tag
(fn [db [text]]
$entity = new Entities\Foo();
$entity->setField('foo');
$em->persist($entity);
$em->flush();
...
...
$entity->setField('bar');
$em->getRepository('Entities\Foo')->find(the_id)->getField() // foo