Skip to content

Instantly share code, notes, and snippets.

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
@dmoss18
dmoss18 / gist:badb89c7f6228bc1a0ad
Last active August 29, 2015 14:05
Custom motionkit view and layout
class MyCustomView < UIView
def top_title=(value)
@top_title = value
#Custom code here
end
end
class MyCustomLayout < MK::Layout
<!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;

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:

@dmoss18
dmoss18 / updateField.js
Last active July 2, 2018 18:25
Better pattern for updating model
// This way is needlessly verbose
export default class CustomerNameComponent {
customer = new Customer()
// Annoying boilerplate
updateCustomerName = (text: string) => {
this.customer.name = text
}
render() {
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 {
<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" />
@dmoss18
dmoss18 / CountdownLabel.xaml.cs
Created July 25, 2019 13:47
Label that renders a countdown timer
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);
//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 / ale_topic.ex
Created April 29, 2021 15:41
Ale topic mappings to our back-end services
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