Skip to content

Instantly share code, notes, and snippets.

@nathamanath
nathamanath / error_messages.js
Created April 25, 2018 15:25
Generate error messages from vuelidate validation errors for vue.js components
/**
* ErrorMessages - generate error messages for vuejs modules using vuelidate
*
* Generate error message computeds to show inline error messages to work with
* vuelidate validations, and also with externally generated error messages
* (normally serverside errors).
*
* Expects to find externally generated errors in `this.errors`... an object
* structured like so:
*
@nathamanath
nathamanath / hash_to_xml_example.rb
Last active August 29, 2015 14:23 — forked from hisapy/hash_to_xml_example.rb
Modified to handle tree with node attributes
require 'nokogiri'
tree = {
node_type: 'form',
children: [
{
node_type: 'div',
attrs: {
class: 'awesome'
},
@nathamanath
nathamanath / data_uri.rs
Last active November 17, 2016 14:52
rust image to data uri
extern crate rustc_serialize;
extern crate regex;
use rustc_serialize::base64::{ToBase64, MIME};
use rustc_serialize::hex::{ToHex};
use std::path::Path;
use std::env;
use std::fs::File;
use std::io::Read;
use regex::Regex;
@nathamanath
nathamanath / decorator_base.rb
Created June 4, 2014 09:58
Base class for ruby on rails decorators
class DecoratorBase
def initialize(component, args = {})
@component = component
@args = args
post_initialize
end
def post_initialize
end