Skip to content

Instantly share code, notes, and snippets.

View BrianAdams's full-sized avatar

badevguru BrianAdams

  • Bay Area, CA
View GitHub Profile
@yingliangzhang
yingliangzhang / json-editor-unique-array-properties.js
Created December 16, 2016 04:36
Unique validation for custom defined fields in an array property for json-editor
JSONEditor.defaults.custom_validators.push(function(schema, value, path) {
let errors = [];
if (schema.type !== 'object') {
return errors;
}
let property = '';
let uniqueValues = [];
let uniqueFieldsStr = '';
@alanpeabody
alanpeabody / my_app.ex
Last active July 18, 2024 05:22
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
@ebidel
ebidel / app.html
Last active May 1, 2021 15:42
Fast Polymer app loading - optimized for first render, progressively enhanced lazy loading
<!DOCTYPE html>
<html>
<head>
<style>
body.loading #splash {
opacity: 1;
}
#splash {
position: absolute;
top: 0;
@SlicedSilver
SlicedSilver / Polymer Application Loading Screen.md
Last active February 21, 2017 02:04
Polymer Application Loading Screen

This is a simple snippet for adding a loading screen to a Polymer application. It is useful if your Polymer application is rather large and some users may be on a very slow internet connection.

The basic idea is that a very simple (and small) loading screen page will be loaded by the browser. When the browser has fully loaded and displayed the loading page then it will start loading all the files required for the Polymer application.

For a further speed improvement: the loading.css, and polymerAppLoader.js files can be placed inline with the index.html thus reducing the amount of files to be loaded from the server.

filestoload.html is a seperate file so that the usual grunt/gulp build functions can still be applied as before. Shouldn't require re-writting your build scripts.

Any improvements/comments are encouraged.

@freshjones
freshjones / gist:b0713263033df8cc9f44
Created February 5, 2015 23:18
bash script to monitor and do something with docker events
#!/bin/sh
docker events --filter 'event=start' --filter 'event=stop' | while read event
do
container_id=`echo $event | sed 's/.*Z\ \(.*\):\ .*/\1/'`
echo $container_id
@noteed
noteed / docker-tinc.md
Last active April 17, 2019 06:22
Docker - Tinc setup
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error: npm http GET http://nj-npm.irisnpm.com/serialport
npm http GET http://nj-npm.irisnpm.com/colors
npm http GET http://nj-npm.irisnpm.com/kickstart
npm http GET http://nj-npm.irisnpm.com/socket.io
npm http GET http://nj-npm.irisnpm.com/requirejs
npm http 200 http://nj-npm.irisnpm.com/colors
npm http GET http://nj-npm.irisnpm.com/colors/-/colors-0.6.0-1.tgz
npm http 200 http://nj-npm.irisnpm.com/serialport