Skip to content

Instantly share code, notes, and snippets.

View monkeycycle's full-sized avatar

Michael Pereira monkeycycle

View GitHub Profile
@monkeycycle
monkeycycle / KeystoneApiExample.md
Created May 19, 2017 16:52 — forked from JedWatson/KeystoneApiExample.md
Example of how to scaffold API endpoints for Posts in a Keystone project (based on the yo keystone example).

This is an example of how to scaffold API endpoints to list / get / create / update / delete Posts in a Keystone website.

It's a modification of the default project created with the yo keystone generator (see https://github.com/JedWatson/generator-keystone)

Gists don't let you specify full paths, so in the project structure the files would be:

routes-index.js        -->    /routes/index.js         // modified to add the api endpoints
routes-api-posts.js    -->    /routes/api/posts.js     // new file containing the Post API route controllers
* {
box-sizing: border-box;
}
.clearfix:after {
visibility: hidden;
display : block;
font-size : 0;
content : " ";
clear : both;
@monkeycycle
monkeycycle / index.html
Last active May 10, 2017 21:17
names matching
<script>
var arrayOne = [{
"name": "Keny"
},
{
"name": "Sloane"
},
{
"name": "Elianna"
@monkeycycle
monkeycycle / florida.csv
Created May 8, 2017 13:57 — forked from gka/florida.csv
bump chart tutorial, part 1
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
live_state born_state 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990 2000 2012
Florida Alabama 0.0477 0.0484 0.0541 0.0508 0.0555 0.0554 0.0458 0.0344 0.0259 0.0197 0.0145 0.0102
Florida Alaska 0.0000 0.0000 0.0000 0.0000 0.0001 0.0000 0.0002 0.0004 0.0005 0.0005 0.0005 0.0008
Florida Arizona 0.0000 0.0000 0.0000 0.0001 0.0004 0.0003 0.0004 0.0007 0.0008 0.0011 0.0014 0.0015
Florida Arkansas 0.0007 0.0009 0.0021 0.0035 0.0024 0.0040 0.0040 0.0043 0.0032 0.0030 0.0025 0.0022
Florida California 0.0003 0.0003 0.0009 0.0006 0.0017 0.0032 0.0056 0.0074 0.0086 0.0104 0.0131 0.0141
Florida Colorado 0.0001 0.0001 0.0006 0.0004 0.0008 0.0008 0.0013 0.0017 0.0018 0.0024 0.0024 0.0026
Florida Connecticut 0.0018 0.0025 0.0018 0.0032 0.0043 0.0058 0.0076 0.0089 0.0106 0.0111 0.0112 0.0097
Florida Delaware 0.0002 0.0004 0.0010 0.0004 0.0005 0.0007 0.0009 0.0012 0.0013 0.0013 0.0013 0.0014
Florida District of Columbia 0.0004 0.0005 0.0005 0.0012 0.0011 0.0019 0.0036 0.0028 0.0035 0.0037 0.0035 0.0028
@monkeycycle
monkeycycle / xls2csv.py
Created May 8, 2017 13:56 — forked from gka/xls2csv.py
Excel to CSV
import xlrd
import csv
import sys
def csv_from_excel(fn):
wb = xlrd.open_workbook(fn)
sh = wb.sheet_by_index(0)
your_csv_file = open(fn.replace('xls', 'csv'), 'wb')
wr = csv.writer(your_csv_file, quoting=csv.QUOTE_ALL)
for rownum in xrange(sh.nrows):
@monkeycycle
monkeycycle / multi-crowbar.js
Created May 8, 2017 13:56 — forked from gka/multi-crowbar.js
like svg-crowbar, but for multiple svg elements!
var multiCrowbar = (function() {
/*
* SVG Export
* converts html labels to svg text nodes
* will produce incorrect results when used with multi-line html texts
*
* Author: Gregor Aisch
* based on https://github.com/NYTimes/svg-crowbar/blob/gh-pages/svg-crowbar-2.js
*/
@monkeycycle
monkeycycle / make-animated-gifs-using-ffmpeg.md
Created May 8, 2017 13:56 — forked from gka/make-animated-gifs-using-ffmpeg.md
how to make a nice GIF from png frames

Make sure ffmpeg is up-to-date:

brew update
brew upgrade ffmpeg

Convert a MOV into frames. Tweak the 2/1 if you want more or fewer frames.

@monkeycycle
monkeycycle / chart-title.js
Created April 29, 2017 17:43
Chart title
svg.append("text")
.attr("x", 20)
.attr("y", 0 - (margin.top / 2))
.attr("text-anchor", "start")
.style("font-size", "16px")
.text("Charty title");
@monkeycycle
monkeycycle / home-capital-share-value.csv
Created April 29, 2017 17:32
Assorted small data sets
Date Close
3-31-1992 0.28
4-30-1992 0.2875
5-29-1992 0.275
6-30-1992 0.25
7-31-1992 0.25
8-31-1992 0.225
9-30-1992 0.225
10-30-1992 0.2125
11-30-1992 0.1375
@monkeycycle
monkeycycle / index.html
Last active April 29, 2017 17:46
D3 horizontal bar chart
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Simple Bar chart</title>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
body {
font-family: "Arial", sans-serif;