Skip to content

Instantly share code, notes, and snippets.

@kaleguy
kaleguy / file-words.js
Last active December 27, 2019 02:15
Counting word frequencies with lodash/fp
const fs = require('fs');
const lineReader = require('line-reader');
const _ = require('lodash');
const {flow, values, uniq, orderBy, reverse, slice, each} = require('lodash/fp');
const counts = {};
const freq = {}
function report() {
// for a given word frequency, print out the terms with that frequency
@kaleguy
kaleguy / .block
Created June 11, 2017 19:14 — forked from mbostock/.block
Area Chart
license: gpl-3.0
@kaleguy
kaleguy / .block
Last active March 13, 2017 00:22
Radial Tree from Leo File
license: gpl-3.0
border: no
height: 750
@kaleguy
kaleguy / .block
Last active March 11, 2017 01:47
Tidy Tree and Dendrogram from Leo File
license: MIT
border: no
height: 620
@kaleguy
kaleguy / .block
Last active March 6, 2017 09:56 — forked from d3noob/.block
Collapsible tree diagram in v4 from Leo file
license: MIT
height: 480
border: yes
@kaleguy
kaleguy / .block
Last active March 4, 2017 23:50
Leo Viewer
license: MIT
height: 480
border: yes
@kaleguy
kaleguy / .block
Last active March 4, 2017 23:55
Leo Tree Viewer with Vue
license: MIT
height: 480
border: yes
@kaleguy
kaleguy / ftp.coffee
Created February 4, 2017 10:04
Download CSV files via FTP
Client = require 'ftp'
async = require 'async'
remote_path ='/public_html/targetfolder/'
local_path = 'data/'
fs = require 'fs'
c = new Client()
c.on 'ready', ()->
c.list remote_path, (err, list)->
if (err) then console.error 'list', err
@kaleguy
kaleguy / README.md
Last active March 1, 2017 04:10 — forked from louking/README.md
d3.legend example (d3 v4)

d3.legend

Forked from d3 legend, updated to work with d3 v4.

d3.legend is a quick hack to add a legend to a d3 chart. Simply add a g and .call(d3.legend). Any elements that have a title set in the "data-legend" attribute will be included when d3.legend is called. Each title will appear only once (even when multiple items define the same data-legend) as the process uses a set based on a existing names, not an array of all items.

Color

By default the color in the legend will try to match the fill attribute or the stroke attribute of the relevant items. Color can be explicitly defined by attribute "data-legend-color"

@kaleguy
kaleguy / twofactordrywall.md
Last active January 18, 2016 07:53
Two Factor Authentication with Drywall and Twilio

#Two Factor Authentication with Drywall and Twilio

Two factor authentication is where you check that the user both knows something (e.g. a password) and has something (e.g. a cellphone). One way to do the latter is to send the user an SMS message.

If you have a site with users, there are a number of possible ways you could add two factor authentication.

  • Password + SMS code at signup
  • Password + SMS code at login
  • In a normal session, popup SMS code verification request