Skip to content

Instantly share code, notes, and snippets.

View daigofuji's full-sized avatar

Daigo Fujiwara daigofuji

View GitHub Profile
@daigofuji
daigofuji / color.html
Last active April 29, 2023 21:25
Displayers SVG
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<style>
@daigofuji
daigofuji / amortization-formula.js
Created March 30, 2023 14:37
amortization formula in JavaScript
// P: principal (loan amount)
// r: monthly interest rate
// M: monthly payment
// n: number of months
const P = 10000; // example loan amount
const r = 0.015; // example monthly interest rate (18% APR / 12 months)
const M = 100; // example monthly payment amount
let n = Math.log(M / (M - r * P)) / Math.log(1 + r); // calculate number of months

Projected Massachusetts town-by-town Geojson Following along with Mr. Mike Bostock's excellent post and I have to write this down or will forget…

Massachusetts Town by Town map can be found from census, as cb_2014_25_cousub_500k.zip and town data that I wanted to use is here towns.ndjson.

$ geoproject 'd3.geoConicConformal().parallels([41 + 43 / 60, 42 + 41 / 60]).rotate([71 + 30 / 60], 0).fitSize([960, 600], d)' < ma.json > ma-nad83.json

$ ndjson-join 'd.mapid' ma-mapid.ndjson towns.ndjson > ma-joined.ndjson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am daigofuji on github.
  • I am daigofuji (https://keybase.io/daigofuji) on keybase.
  • I have a public key ASApLGFk2DIIEBPaP4Ck-a1V3j0y-hs7MtonUs_cfC1sqAo

To claim this, I am signing this object:

@daigofuji
daigofuji / 2018-mlb-allplayers.json
Last active March 10, 2019 14:41
All 30 teams Full-Season Roster & Games by Position of 2018 MLB Regular season from Baseball-reference.com
[{"Lg":"ALE","Tm":"BOS","Name":"Matt Barnes","url":"https://www.baseball-reference.com/players/b/barnema01.shtml","COUNTRY":"US","B":"R","T":"R","Ht":"6' 4","Wt":210,"DoB":"17-Jun-90","Yrs":"5","G":62,"GS":0,"Batting":4,"Defense":62,"P":62,"C":0,"1B":0,"2B":0,"3B":0,"SS":0,"LF":0,"CF":0,"RF":0,"OF":0,"DH":0,"PH":0,"PR":0,"WAR":1.1,"Salary":"$605,000 ","AS":null},
{"Lg":"ALE","Tm":"BOS","Name":"Jalen Beeks","url":"https://www.baseball-reference.com/players/b/beeksja02.shtml","COUNTRY":"US","B":"L","T":"L","Ht":"5' 11","Wt":200,"DoB":"10-Jul-93","Yrs":"1st","G":2,"GS":1,"Batting":0,"Defense":2,"P":2,"C":0,"1B":0,"2B":0,"3B":0,"SS":0,"LF":0,"CF":0,"RF":0,"OF":0,"DH":0,"PH":0,"PR":0,"WAR":-0.4,"Salary":"","AS":null},
{"Lg":"ALE","Tm":"BOS","Name":"Andrew Benintendi","url":"https://www.baseball-reference.com/players/b/beninan01.shtml","COUNTRY":"US","B":"L","T":"L","Ht":"5' 10","Wt":170,"DoB":"6-Jul-94","Yrs":"3","G":148,"GS":142,"Batting":148,"Defense":144,"P":0,"C":0,"1B":0,"2B":0,"3B":0,"SS":0,"LF":129,"CF":24,
{"id":1,"town":"ABINGTON","fips":25023,"name":"Abington","mapid":"Abington"}
{"id":2,"town":"ACTON","fips":25017,"name":"Acton","mapid":"Acton"}
{"id":3,"town":"ACUSHNET","fips":25005,"name":"Acushnet","mapid":"Acushnet"}
{"id":4,"town":"ADAMS","fips":25003,"name":"Adams","mapid":"Adams"}
{"id":5,"town":"AGAWAM","fips":25013,"name":"Agawam","mapid":"Agawam Town"}
{"id":6,"town":"ALFORD","fips":25003,"name":"Alford","mapid":"Alford"}
{"id":7,"town":"AMESBURY","fips":25009,"name":"Amesbury","mapid":"Amesbury Town"}
{"id":8,"town":"AMHERST","fips":25015,"name":"Amherst","mapid":"Amherst"}
{"id":9,"town":"ANDOVER","fips":25009,"name":"Andover","mapid":"Andover"}
{"id":104,"town":"AQUINNAH","fips":25007,"name":"Aquinnah","mapid":"Aquinnah"}
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var sassPaths = [];
gulp.task('sass', function() {
return gulp.src('scss/app.scss')
.pipe($.sourcemaps.init())
.pipe($.sass({
includePaths: sassPaths,
<%@ Master Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<noscript>For full functionality of this page it is necessary to enable JavaScript. </noscript>
<link rel="stylesheet" type="text/css" href="../WBUR/donation-form.css">
<title>WBUR Donation Page</title>
<!-- Quantcast Tag -->
<script>
var ezt = ezt ||[];
(function(){
var elem = document.createElement('script');
elem.src = (document.location.protocol == "https:" ? "https://secure" : "http://pixel") + ".quantserve.com/aquant.js?a=p-Z4bfNLnN8psjN";
elem.async = true;
elem.type = "text/javascript";
var scpt = document.getElementsByTagName('script')[0];
scpt.parentNode.insertBefore(elem,scpt);