This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Noonhq.Repo.BinaryKv do | |
@moduledoc """ | |
Simple ecto Binary KV store in the db | |
MIT License, Joe Noon, Copyright 2020 | |
""" | |
require Logger | |
use Ecto.Schema | |
import Ecto.Query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i have one MainLive live_view defined in router as live "/*path", MainLive . then i created | |
a router_live.ex which looks sort of like a normal router.ex with all the live routes, but | |
they all point to live_components. and that router is not used in the endpoint, its purely | |
to get the functionality with route matching and Routes.live_path etc. my MainLive | |
handle_params does a URI.parse(url) and then Phoenix.Router.route_info(MyAppWeb.RouterLive, | |
"GET", uri.path, uri.authority) and i come out with a route that i pass down. my MainLive | |
render does a header/footer and in the middle something like live_component(assigns.socket, | |
route.live_view, id: route.route, store: store) (route here is what i created in | |
handle_params… route.live_view is the LiveComponent defined in the router_live.ex for the | |
route that matched). ive liked how it worked out so far. i also have an “AppState” that i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"/> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | |
<link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/> | |
</head> | |
<body> | |
<div id="phx_root"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyAppWeb.LiveView.Session do | |
@moduledoc """ | |
Joe Noon on 9/3/2019 | |
LiveView does not have a direct way to change the session, but does provide a way to set flash. | |
The application can use `put_flash(socket, :session, %{...})`, and this plug will merge that | |
map when present into the persisted session. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {MobxReactLiteHooks} from './jn-mobx-lite'; | |
declare module 'jn-mobx-lite.macro'; | |
export function useObserver<T>(baseComponentName?: string): MobxReactLiteHooks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useComputed, useObservable, useObserver as useObserverInternal} from 'mobx-react-lite'; | |
const HOOKS = { | |
useComputed, | |
useObservable, | |
}; | |
export type MobxReactLiteHooks = typeof HOOKS; | |
// This is for my convenience, not neccessary for the pattern. | |
export * from 'mobx'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { observable, computed, toJS } from 'mobx'; | |
function defaultData() { | |
return { | |
text: null, | |
dataText: null, | |
type: null, | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {View} from 'react-native'; | |
function Icon(props: {size: number, color: string, name: string, style?: any}) { | |
const SVGIcon = Icon.SVGS[props.name]; | |
if (!SVGIcon) { | |
throw new Error(`Unknown icon ${props.name}`); | |
} | |
const {style, ...rest} = props; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//[understanding quaternion] | |
// - basic vector knowledge | |
// - quaternion basics | |
// - quaternion multiply | |
// - rotation with quaternion | |
// - slerp | |
// - convert quaternion to matrix | |
//[(basic) vector func] | |
var negate = function (vec) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LETTERS = 'acdfgilmnoprstuw'; | |
const HASH = 7; | |
function hash(s) { | |
let hash = HASH; | |
for (let i = 0; i < s.length; i++) { | |
hash = (hash * 23 + LETTERS.indexOf(s[i])); | |
} | |
return hash; | |
} |
NewerOlder