Skip to content

Instantly share code, notes, and snippets.

View paulstatezny's full-sized avatar

Paul Statezny paulstatezny

View GitHub Profile
@paulstatezny
paulstatezny / live_view_send_event.ex
Created October 26, 2021 00:24
How to send an event from within `handle_event` in a Phoenix LiveView
def send_event(socket, component \\ nil, event, payload) do
cid = case component do
%Phoenix.LiveComponent.CID{cid: cid} -> cid
_ -> nil
end
send(
socket.root_pid,
%Phoenix.Socket.Message{
event: "event",
@paulstatezny
paulstatezny / introrx.md
Last active January 13, 2024 13:33 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@paulstatezny
paulstatezny / scope-definitions.html
Created May 4, 2016 05:22
Proof of Concept for defining scope properties in Angular as functions, taking a more FP approach.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://code.angularjs.org/1.5.5/angular.js"></script>
</head>
<body>
<div ng-app="TestApp">
<div test-directive>
@paulstatezny
paulstatezny / benchmark-complex-object-delete-vs-assign.js
Created April 27, 2016 23:15
Benchmarking how much faster it is to null a property of a complex object versus deleting that property in JavaScript
var Benchmark = require('benchmark');
function complete() {
console.log(String(this));
}
var objDeleteBenchmark = new Benchmark('Object#delete-property', {
setup: function() {
var obj = {
foo: {
@paulstatezny
paulstatezny / benchmark-object-delete-vs-assign.js
Last active January 24, 2024 17:36
Benchmarking how much faster it is to null a property of an object versus deleting that property in JavaScript
var Benchmark = require('benchmark');
function complete() {
console.log(String(this));
}
var objDeleteBenchmark = new Benchmark('Object#delete-property', {
setup: function() { var obj = {foo: 'bar'}; },
fn: function() { delete obj.foo; }
});
<!DOCTYPE html>
<html>
<head>
<style>
.class1.class2.class3.class4.class5.class6.class7.class8.class9.class10.class11.class12.class13.class14.class15.class16.class17.class18.class19.class20.class21.class22.class23.class24.class25.class26.class27.class28.class29.class30.class31.class32.class33.class34.class35.class36.class37.class38.class39.class40.class41.class42.class43.class44.class45.class46.class47.class48.class49.class50.class51.class52.class53.class54.class55.class56.class57.class58.class59.class60.class61.class62.class63.class64.class65.class66.class67.class68.class69.class70.class71.class72.class73.class74.class75.class76.class77.class78.class79.class80.class81.class82.class83.class84.class85.class86.class87.class88.class89.class90.class91.class92.class93.class94.class95.class96.class97.class98.class99.class100.class101.class102.class103.class104.class105.class106.class107.class108.class109.class110.class111.class112.class113.class114.class115.class116.class117.class118.class119.class120.c
@paulstatezny
paulstatezny / towerfall-wii-remote-config.xml
Created March 16, 2015 04:30
MonoGame Wii Remote Config for Towerfall - modified from https://steamcommunity.com/app/251470/discussions/0/540744934205936715/ - Belongs in <your home directory>/Library/Application Support/MonoGame/MonoGameJoystick.cfg
<?xml version="1.0" encoding="utf-8"?>
<MonoGameJoystickConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<BUTTON_START>
<INPUT_TYPE>Button</INPUT_TYPE>
<INPUT_ID>7</INPUT_ID><!-- Wjoy '-' -->
<INPUT_INVERT>false</INPUT_INVERT>
</BUTTON_START>
<!--
<BUTTON_BACK>
<INPUT_TYPE>Button</INPUT_TYPE>
@paulstatezny
paulstatezny / towerfall-wii-remote-with-nunchuk-config.xml
Last active August 29, 2015 14:15
MonoGame Wii Remote Config for Towerfall - modified from https://steamcommunity.com/app/251470/discussions/0/540744934205936715/ - Belongs in <your home directory>/Library/Application Support/MonoGame/MonoGameJoystick.cfg
<?xml version="1.0" encoding="utf-8"?>
<MonoGameJoystickConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<BUTTON_START>
<INPUT_TYPE>Button</INPUT_TYPE>
<INPUT_ID>6</INPUT_ID><!-- Wjoy '+' -->
<INPUT_INVERT>false</INPUT_INVERT>
</BUTTON_START>
<BUTTON_BACK>
<INPUT_TYPE>Button</INPUT_TYPE>
<INPUT_ID>7</INPUT_ID><!-- Wjoy '-' -->
From 0b1b114f5824be2fd4feb26eddfbb349813971cb Mon Sep 17 00:00:00 2001
From: Paul Statezny <paulstatezny@users.noreply.github.com>
Date: Sat, 31 Jan 2015 20:49:49 -0700
Subject: [PATCH] Create new dispatcher upon dispatch.
---
lib/dispatcher.js | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/dispatcher.js b/lib/dispatcher.js
@paulstatezny
paulstatezny / unit.fish
Last active August 29, 2015 14:11
Fish function to run PHPUnit
function unit
# Remove logging portion of phpunit configuration
sed -i .sedbackup 's/\<\/logging\>//g' ./phpunit.xml
sed -i .sedbackup 's/\<logging\>//g' ./phpunit.xml
rm *.sedbackup
if set -q argv[1]
vendor/bin/phpunit --filter $argv[1]
else
vendor/bin/phpunit