Skip to content

Instantly share code, notes, and snippets.

View raysuelzer's full-sized avatar

Ray Suelzer raysuelzer

  • ActionNetwork.org
  • New Mexico
View GitHub Profile
@raysuelzer
raysuelzer / sanitizer.ts
Created December 7, 2023 19:55
Angular Style Safe Sanitizer
// Original JS source: https://github.com/jitbit/HtmlSanitizer/blob/master/HtmlSanitizer.js
export class HtmlSanitizer {
private _tagWhitelist = {
A: true, ABBR: true, B: true, BLOCKQUOTE: true, BODY: true, BR: true, CENTER: true,
CODE: true, DD: true, DIV: true, DL: true, DT: true, EM: true, FONT: true,
H1: true, H2: true, H3: true, H4: true, H5: true, H6: true, HR: true, I: true,
IMG: true, LABEL: true, LI: true, OL: true, P: true, PRE: true,
SMALL: true, SOURCE: true, SPAN: true, STRONG: true, SUB: true, SUP: true, TABLE: true,
TBODY: true, TR: true, TD: true, TH: true, THEAD: true, UL: true, U: true, VIDEO: true
};
@raysuelzer
raysuelzer / autocomplete-disable.js
Created June 4, 2020 20:07
Autocomplete disabling hack
// Note: you would only want this to be executed once, and after
// the page has loaded. This is just a gist, it can be customized
// further
// Find all elements where autocomplete="off"
document.querySelectorAll('[autocomplete="off"]').forEach(
(element) => {
// Store the original name of the element
const orgininalName = element.getAttribute('name');
@raysuelzer
raysuelzer / diy-battery-backup.md
Last active July 26, 2019 18:47
DIY Battery Backup

DIY Battery Backup

Components Needed

  • 36 Volt UPS (1x 30$). Recommended Tripp Lite Smart 1500. (No Battery needed, we will be replacing it)
  • 36 Volt Hoverboard / Scooter Lithium Batteries (4x ~ $30 each)
    • These batteries are available on ebay, and are packs made of 20 18650 battieries in a 36 volt (10s2p) configuration.
  • They come built in with a BMS to prevent over charging and discharging and balance the cells.
@raysuelzer
raysuelzer / profile_output.html
Created June 26, 2019 00:27
call_stack_results.rb
Warming up --------------------------------------
Querying for 1000 objects
1.000 i/100ms
Calculating -------------------------------------
Querying for 1000 objects
6.856 (± 0.0%) i/s - 35.000 in 5.129558s
<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>ruby-prof call tree</title>
<style type="text/css">
@raysuelzer
raysuelzer / rub.rb
Created June 26, 2019 00:26
Modified for nested arrays
# frozen_string_literal: true
TESTING_INTERPRETER = true
require "graphql"
require "jazz"
require "benchmark/ips"
require "ruby-prof"
require "memory_profiler"
module GraphQLBenchmark
QUERY_STRING = GraphQL::Introspection::INTROSPECTION_QUERY
@raysuelzer
raysuelzer / index.js
Last active September 28, 2015 23:19
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var Benchmark = require('benchmark');
var Q = require('q');
var when = require('when');
var suite = new Benchmark.Suite;
// add tests
suite
@raysuelzer
raysuelzer / SmartRequest2
Last active August 29, 2015 14:18
Accepts Asp.NET Routing Attributes and generates a chainable nested ajax api interface.
/*jslint node: true */
/*jslint esnext: true*/
"use strict";
let AppDispatcher = require('../dispatcher/AppDispatcher');
let ApiClient = require('../api-client/api-client');
let URITemplate = require('URIjs/src/URITemplate');
let RouteTemplates = require('../constants/constants').ROUTE_TEMPLATES;
let _ = require('lodash');
let DeepGet = require('../utils/DeepGet');
@raysuelzer
raysuelzer / apigist.js
Last active August 29, 2015 14:17
chainable api?
//Fetch data from the API using dot notation.
//Only used when the dot notation will result in a valid URI
ApiClient.fetchData("parent_employers.2.work_sites")
.done((data) => {
console.log(data);
});
//More advanced chaining
//Fetch data from the api using chained functions
ApiClient.parent_employers({id: 2}) //params replace templated uris
@raysuelzer
raysuelzer / Typeahead.jsx
Last active August 29, 2015 14:17
ReactJS Flux Typeahead Gist
var React = require('react');
var TypeaheadStore = require('../stores/TypeaheadStore');
var TypeaheadActions = require('../actions/TypeaheadActions');
var _ = require('lodash');
var TypeaheadItem = React.createClass({
render() {
return (
<div>{this.props.name}</div>
)