Skip to content

Instantly share code, notes, and snippets.

@jbalboni
jbalboni / save_batman.py
Last active December 15, 2015 20:58
Python solution for generating a string that contains all possible N digit combinations and is as short as possible. The problem was described as Batman needing the combinations to open a lock and escape, hence the numerous cheesy Batman references. Default number of digits is 4.
import math
import sys
class BatSequenceGenerator():
"""Class to generate a key sequence Batman can use to escape"""
def __init__(self, digits=4):
self.digits = digits
#char sequence
self.bat_sequence = []
#Batman thought Bat Hash sounded cooler than Bat Dict
@jbalboni
jbalboni / routes.js
Last active March 19, 2016 16:38
Angular resolves
.state('picture.colors', {
url: "/colors",
templateUrl: "partials/picture_colors.html",
controller: 'PictureColorsController'
},
resolve: {
colors: function(ColorsService) {
return ColorsService.getColorsWithBrightness();
}
}
This file has been truncated, but you can view the full file.
[{"pid":21754,"tid":21797,"ts":480895342637,"ph":"X","cat":"toplevel","name":"MessagePumpLibevent::OnLibeventNotification","args":{"fd":30},"dur":173,"tdur":168,"tts":3347820},
{"pid":21754,"tid":21797,"ts":480895342719,"ph":"X","cat":"ipc,toplevel","name":"ChannelMojo::OnMessageReceived","args":{"class":11,"line":185},"dur":68,"tdur":65,"tts":3347900},
{"pid":21754,"tid":21797,"ts":480895345919,"ph":"X","cat":"toplevel","name":"MessageLoop::RunTask","args":{"src_file":"../../ipc/ipc_channel_proxy.cc","src_func":"Send"},"dur":98,"tdur":91,"tts":3348070},
{"pid":21754,"tid":21797,"ts":480895346023,"ph":"X","cat":"toplevel","name":"MessageLoop::RunTask","args":{"src_file":"../../gpu/ipc/service/gpu_channel.cc","src_func":"FinishMessageProcessing"},"dur":13,"tdur":10,"tts":3348170},
{"pid":21754,"tid":21797,"ts":480895355207,"ph":"X","cat":"toplevel","name":"MessagePumpLibevent::OnLibeventNotification","args":{"fd":30},"dur":152,"tdur":146,"tts":3348247},
{"pid":21754,"tid":21797,"ts":480895355293,"ph":"X","cat"
This file has been truncated, but you can view the full file.
[{"pid":17579,"tid":1295,"ts":1575060464632,"ph":"X","cat":"toplevel","name":"MessageLoop::RunTask","args":{"src_file":"../../third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc","src_func":"PushOntoImmediateIncomingQueueLocked"},"dur":73,"tdur":63,"tts":1656950},
{"pid":17579,"tid":1295,"ts":1575060464663,"ph":"X","cat":"toplevel","name":"TaskQueueManager::ProcessTaskFromWorkQueue","args":{"src_file":"../../base/trace_event/trace_log.cc","src_func":"SetEnabled"},"dur":17,"tdur":14,"tts":1656974},
{"pid":17579,"tid":1295,"ts":1575060464685,"ph":"X","cat":"toplevel","name":"TaskQueueManager::ProcessTaskFromWorkQueue","args":{"src_file":"../../base/trace_event/trace_log.cc","src_func":"SetEnabled"},"dur":8,"tdur":5,"tts":1656996},
{"pid":17579,"tid":1295,"ts":1575060464694,"ph":"X","cat":"toplevel","name":"TaskQueueManager::ProcessTaskFromWorkQueue","args":{"src_file":"../../base/trace_event/trace_log.cc","src_func":"SetEnabled"},"dur":7,"tdur":4,"tts":1657005},
{"pid":17579,"tid":1295,"ts":157
@jbalboni
jbalboni / ArrayField.jsx
Last active January 5, 2017 20:51
Schema form code prototypes
import React from 'react';
import _ from 'lodash/fp';
import {
retrieveSchema,
toIdSchema,
getDefaultFormState
} from 'react-jsonschema-form/lib/utils';
export default class ArrayField extends React.Component {
@jbalboni
jbalboni / Building a schema form.md
Last active February 9, 2017 21:09
SchemaForm docs

Form config

Forms are created by creating a page that uses FormApp from the schemaform folder, a form config object, and routes generated from that config file. See src/js/edu-benefits/1995 for an example.

Form config options:

  • urlPrefix: Prefix string to add to the path for each page
  • introduction: The introduction page component to use. Intro page is skipped if not provided
  • confirmation: The confirmation page component to use after form is successfully submitted
  • trackingPrefix: The prefix for Google Analytics events that are sent for different form actions
  • title: The title of the form. Displayed on all pages

Keybase proof

I hereby claim:

  • I am jbalboni on github.
  • I am jbalboni (https://keybase.io/jbalboni) on keybase.
  • I have a public key whose fingerprint is 1A3E 5606 9A10 0A26 A44A EF37 414F 4105 978E 4AE2

To claim this, I am signing this object:

@jbalboni
jbalboni / test.js
Last active February 1, 2017 19:36
import fullSchema1995 from 'vets-json-schema/dist/change-of-program-schema.json';
const {
veteranFullName,
veteranSocialSecurityNumber,
vaFileNumber
} = fullSchema1995.properties;
const config = {
defaultDefinitions: fullSchema1995.definitions,

Schemaform walkthrough

This walkthrough is going to detail how our form building code (called schemaform from here on) and the library it's built on work. This guide assumes you're comfortable with React and building forms.

JSON Schema

One pre-requisite for understanding how schemaform works is the JSON Schema standard. JSON Schema is a way of describing the allowed shape of JSON objects. There are some good examples to look through on the (http://json-schema.org/examples.html)[JSON Schema site]. Here are some basics:

Schema's have a type, that tells you what kind of data is allowed:

@jbalboni
jbalboni / issues.md
Last active April 26, 2017 17:57
Starter issues