Skip to content

Instantly share code, notes, and snippets.

View natemoo-re's full-sized avatar
⌨️
Clickity clacking away

Nate Moore natemoo-re

⌨️
Clickity clacking away
View GitHub Profile
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Knox Alpha Phi Omega on Twitter" />
<Content type="html">
<![CDATA[
<a class="twitter-timeline" href="https://twitter.com/APO_ABGchapter" data-widget-id="450684835200114688">Tweets by @APO_ABGchapter</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
]]>
</Content>
</Module>
@natemoo-re
natemoo-re / README.md
Last active December 7, 2016 04:33
Simplify @NgModule declarations in Ionic 2

Simplify @NgModule declarations in Ionic 2

Use the ES6 spread operator ... to clean up and maintain your @NgModule declaration with ease.

Jump down to the files if you want to skip the explanation.

Instructions

  1. Under your Ionic project's src/ directory, add the following directories as needed.
    • pages/ for Ionic's Page @Components, generated with $ ionic g page <PageName>
    • providers/ for Angular's @Injectable services, generated with $ ionic g provider
@natemoo-re
natemoo-re / color-helper.scss
Created May 24, 2018 17:41
Sass utility function to make working with colors stored as CSS Variables a little nicer
@function color($name) {
@return var(unquote("--PREFIX-color-#{$name}"));
}
@natemoo-re
natemoo-re / README.md
Last active June 24, 2024 09:21
Visual Studio Code Snippets – Common Case Transformations

Common Case Transformation Snippets

Visual Studio Code allows Snippets to perform ✨Variable Transforms✨ using Regex.

Here are some common case transformations that you can apply to your snippets. In these examples, I'm using $TM_FILENAME_BASE, but the same transformations should apply to any of the Snippet Variables.

snippets-from-delimited.json can convert filenames like my-file-name, my_file_name, my file name. If your filename is delimited by a dash, underscore, or space, these should work.

snippets-from-mixed-case.json can convert filenames like myFileName and MyFileName. If your filename is in camel or Pascal case, these should work.

@natemoo-re
natemoo-re / machine.js
Last active January 9, 2020 18:23
Generated by XState Viz: https://xstate.js.org/viz
const { cancel } = actions;
const TimerMachine = Machine(
{
initial: "idle",
context: {
duration: 5000,
paused: false,
startedAt: null,
remaining: 0
@natemoo-re
natemoo-re / machine.js
Last active January 9, 2020 17:33
Generated by XState Viz: https://xstate.js.org/viz
const { cancel } = actions;
const timerMachine = Machine(
{
initial: "idle",
context: {
autodismiss: 5000,
paused: false,
startedAt: null,
remaining: 0
@natemoo-re
natemoo-re / eval.js
Last active November 4, 2020 10:22
Safe(ish) Eval
// Adopted from Alpine.js
// https://github.com/alpinejs/alpine/blob/b6e07b2775de444c5f9bdc4d94accb7b720fd6a7/src/utils.js#L59
function saferEval(expression, context, additionalHelperVariables = {}) {
return (new Function(['$data', ...Object.keys(additionalHelperVariables)], `var result; with($data) { result = ${expression} }; return result`))(
context, ...Object.values(additionalHelperVariables)
)
}
export default function sandboxedEval(expression, context = {}) {
@natemoo-re
natemoo-re / ReadmeImg.tsx
Last active July 13, 2020 15:40
Serverless README Image (React)
import React from "react";
export const ReadmeImg = ({ width, height, children }) => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width={width} height={height}
viewBox={`0 0 ${width} ${height}`}
>
<foreignObject width={width} height={height}>
@natemoo-re
natemoo-re / RouteParams.ts
Last active November 4, 2020 19:30
Typed parameter object from path
type RestParam<S extends string> = S extends `...${infer A}` ? A : never;
type StandardParam<S extends string> = S extends `...${infer A}` ? never : S;
type ExtractParams<S extends string> = S extends `[${infer A}]` ? A : never;
type TupleToUnion<T extends any[]> = T[number];
type Split<S extends string> =
string extends S ? string[] :
S extends '' ? [] :
S extends `${infer T}/${infer U}` ? [T, ...Split<U>] :
[S];
@natemoo-re
natemoo-re / fetchMachine.js
Created April 27, 2021 15:11
Yet-to-be-named Statechart DSL
const fetchMachine = createMachine((statechart, { goto, send, store }) => {
store.retries = 0;
return statechart`
main machine fetch {
initial state idle {
on:FETCH ${() => goto('loading')}
}
state loading {
@enter ${async () => {