Skip to content

Instantly share code, notes, and snippets.

@visualjeff
visualjeff / gist:fd0707201fe0e97dcaac1e719354425e
Created May 14, 2016 17:45
Ember-data override to pull out meta data from a particular data type. Note this is a findAll override. So we're pulling back a collection of locations.
normalizeFindAllResponse(store, primaryModelClass, payload, id, requestType) {
if (primaryModelClass.modelName === 'location') { // My data model in this case is location.
if (payload && payload.hasOwnProperty('meta')) {
let meta = payload.meta;
//Store / persist or do something your meta data.
delete payload.meta;
}
}
return this._super(...arguments);
}
@visualjeff
visualjeff / gist:3d7d06be88d777153f61228d29c106d9
Created May 14, 2016 17:35
ember-data override to rev attributes when null. data source (couchdb) doesn't want a null rev attribute when adding (POSTing) a record.
//Override is to accomidate couchdb and that it doesn't like like to see a revision or rev
//when creating a record. But because our model contains a rev (which is used for updates
//or patch request) we need to make sure during a POST request that we cut or remove the rev
//property out of the payload. Since Ember-Data sets it to null (record is about to be added)
//removing it won't hurt a thing.
serialize(snapshot, options) {
let data = this._super(...arguments);
if (data.data.attributes.rev === null) {
delete data.data.attributes.rev;
@visualjeff
visualjeff / gist:b2c8953525a27ffa1d72
Created February 22, 2016 18:24
Bash Matrix Example
#!/bin/bash
declare -A matrix
num_rows=4
num_columns=5
for ((i=1;i<=num_rows;i++)) do
for ((j=1;j<=num_columns;j++)) do
matrix[$i,$j]=$RANDOM
done
done
@visualjeff
visualjeff / gist:9010ddce8cfa37560961
Created February 22, 2016 02:19
Installing Chrome onto debian jessie
Download 64 bit chrome for debian
cd to your Downloads directory
May need to sudo this command:
dpkg -i google-chrome-stable_current_amd64.deb
To finish installing any missing dependencies:
apt-get -f install
@visualjeff
visualjeff / Dockerfile
Created July 10, 2015 18:45
Docker data container and how to move data from the host into the running container.
# To build: docker build --force-rm=true -t costco/data:0.0.1 .
# To run: docker run -d --name tnc_data_container -t costco/data:0.0.1
FROM busybox:latest
MAINTAINER Jeffrey Gilbert <[email protected]>
RUN mkdir /data
VOLUME /data
@visualjeff
visualjeff / index.html
Created June 8, 2015 23:10
Sample Component Form [ember 1.13.0 Component Form] // source http://jsbin.com/qatuga
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="[ember 1.13.0 Component Form]" />
<title>Sample Component Form</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/css/foundation.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
@visualjeff
visualjeff / Dockerfile
Created May 28, 2015 18:50
Dockerfile snippet for debian package updates
//Only for Ubuntu
//ENV DEBIAN_FRONTEND noninteractive
RUN /* apt-key adv --keyserver URL_HERE --recv-keys KEY_HERE && */ \
/* echo 'deb URL_HERE trusty main' >> /etc/apt/sources.list && */ \
apt-get update && \
apt-get -yq install \
curl \
...
apt-get clean && \
@visualjeff
visualjeff / index.html
Created May 24, 2015 22:07
Ember Starter Kit // source http://jsbin.com/kogure
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://builds.emberjs.com/tags/v1.12.0/ember-template-compiler.js"></script>
<script src="http://builds.emberjs.com/tags/v1.12.0/ember.debug.js"></script>
</head>
@visualjeff
visualjeff / Dockerfile
Last active August 29, 2015 14:20
Dockerfile for debian and couchdb 1.6.1
# Docker version 1.6.x
#
# To build: sudo docker build --force-rm=true -t costco/couchdb:latest .
# To run: sudo docker run -d -p 5984:5984 -t costco/couchdb:latest
#
FROM debian:latest
MAINTAINER Jeffrey Gilbert
ENV DEBIAN_FRONTEND noninteractive
@visualjeff
visualjeff / gist:a9e96cb4970e4dfa504e
Created October 28, 2014 02:53
handy password generator
apg -m 9 -x 9 -n 1 -M SNCL