Skip to content

Instantly share code, notes, and snippets.

@dmoss18
dmoss18 / ale_topic.ex
Created Apr 29, 2021
Ale topic mappings to our back-end services
View ale_topic.ex
defmodule Apex.AleTopic do
@moduledoc """
Utility functions for working with ALE topics.
"""
alias __MODULE__
@enforce_keys [:name, :apex_api, :api_endpoint]
defstruct name: nil, apex_api: nil, api_endpoint: nil, base_url: Apex.Config.api_host, partition: Apex.Config.partition
View keyed-statistic-renderer.ts
//scrolling-statistics-row.tsx
export type KeyedStatisticRenderer = { key: string, render: StatisticRenderer }
export function keyedRenderer(key: string, renderer: StatisticRenderer): KeyedStatisticRenderer { return { key, render: renderer } }
const WatchlistStatisticRenderers = {
[WatchlistColumn.EstimatedEarnings]: keyedRenderer('watchlist-estimated-earnings', createStatisticFieldRenderer(() => 0))
[WatchlistColumn.Range]: keyedRenderer('watchlist-range', RangeFieldRenderer)
}
<AnimatedSyncedHorizontalScrollView offsetObserver={this.props.offsetObserver} style={this.props.style} onPress={this.props.onPress}>
@dmoss18
dmoss18 / CountdownLabel.xaml.cs
Created Jul 25, 2019
Label that renders a countdown timer
View CountdownLabel.xaml.cs
using System;
using Xamarin.Forms;
namespace DK.InstantBetting.Views
{
public partial class CountdownLabel : Label
{
public static readonly BindableProperty TargetTimeProperty =
BindableProperty.Create("TargetTime", typeof(DateTime), typeof(CountdownLabel), DateTime.Now, propertyChanged: TargetTimeChanged);
View gist:271251c778fbbc413285113d25205430
<grid>
<grid.ColumnDefinitions>
<grid.column width="0.25" />
<grid.column width="0.25" />
<grid.column width="0.5" />
</grid.ColumnDefinitions>
<grid.RowDefinitions>
<grid.Row Height="20px" />
</grid.RowDefinitions>
<Label1 Grid.Column="0" Grid.Row="0" Text="Colum1, Row1" />
View validateDatetime.js
import { parsePhoneNumber } from 'libphonenumber-js'
import { validate, isString } from 'validate.js'
import * as REGEX_PATTERNS from './regex/constants'
import moment from 'moment'
// tslint:disable:no-unsafe-any
export const PHONE_NUMBER = (value: string) => {
const errorMessage = 'is invalid'
if (!!value && isString(value)) {
try {
@dmoss18
dmoss18 / updateField.js
Last active Jul 2, 2018
Better pattern for updating model
View updateField.js
// This way is needlessly verbose
export default class CustomerNameComponent {
customer = new Customer()
// Annoying boilerplate
updateCustomerName = (text: string) => {
this.customer.name = text
}
render() {
View keybase.md

Keybase proof

I hereby claim:

  • I am dmoss18 on github.
  • I am dmoss18 (https://keybase.io/dmoss18) on keybase.
  • I have a public key whose fingerprint is CEF4 C443 240F 1B7B 1B6C 0ACA 8126 A81D 29C8 4773

To claim this, I am signing this object:

View index.html
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
.box {
width: 100px;
@dmoss18
dmoss18 / gist:badb89c7f6228bc1a0ad
Last active Aug 29, 2015
Custom motionkit view and layout
View gist:badb89c7f6228bc1a0ad
class MyCustomView < UIView
def top_title=(value)
@top_title = value
#Custom code here
end
end
class MyCustomLayout < MK::Layout
View gist:eae372b0f80ad8a11cff
def layout
root :my_root do
add UIButton, :button_1 do
constraints do
top.equals(:superview)
left.equals(:superview)
width 30
height 144
end
end