Skip to content

Instantly share code, notes, and snippets.

@calvinfroedge
calvinfroedge / analyze.js
Last active May 18, 2020 16:53
tanker dividends analysis
const csv=require('csvtojson')
const _=require('lodash');
const moment = require('moment');
const dateFormat = 'YYYY-MM-DD';
const tickerColumn = 'TICKER';
const exDivColumn = 'EX-DIV DATE';
const dividendAmountColumn = 'DIVIDEND AMOUNT';
const csv=require('csvtojson')
const _=require('lodash');
const moment = require('moment');
const dateFormat = 'YYYY-MM-DD';
const monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
const converter=csv()
.fromFile('./applemobilitytrends-2020-05-08.csv')
@calvinfroedge
calvinfroedge / gist:14700b3cd027d1d2acc577269c48cc57
Created May 10, 2020 18:16
apple covid 19 analysis may 8 2020
// Download data from https://www.apple.com/covid19/mobility
const csv=require('csvtojson')
const _=require('lodash');
let getDateKeys = (month, days, startDate=1)=>{
let keys = [];
for(var i=startDate;i<days+1;i++){
keys.push(`2020-0${month}-${i < 10 ? '0' : ''}${i}`)
}
@calvinfroedge
calvinfroedge / tankerData.md
Last active October 16, 2019 02:57
Current oil tanker data

unique fields:

LAT,LON,SPEED,COURSE,HEADING,ELAPSED,SHIPNAME,SHIPTYPE,SHIP_ID,TYPE_IMG,TYPE_NAME,STATUS_NAME,DESTINATION,FLAG,LENGTH,ROT,WIDTH,L_FORE,W_LEFT,DWT,GT_SHIPTYPE

total tankers: 4149

tankers by flag:

Switzerland: 1, Saint Kitts and Nevis: 1, Sierra Leone: 1, Latvia: 1, Pakistan: 1, Hungary: 1, Qatar: 2, Faroe Islands: 2, Australia: 2, Paraguay: 2, Azerbaijan: 2, New Zealand: 2, Mauritius: 2, Iceland: 2, France: 3, Mexico: 3, Gabon: 3, Iran, Islamic Republic of: 4, Peru: 4, Philippines: 4, Kazakhstan: 4, Finland: 4, Japan: 4, Portugal: 5, Thailand: 5, Brazil: 5, Germany: 5, Netherlands: 6, Turkey: 6, China: 6, Chile: 6, Canada: 6, Argentina: 6, Kuwait: 8, Spain: 8, Nigeria: 8, Italy: 8, Viet Nam: 8, Sweden: 8, United States: 9, Cayman Islands: 10, Belgium: 10, Indonesia: 12, Cyprus: 13, Malaysia: 14, Saudi Arabia: 15, India: 18, Russian Federation: 21, Bermuda: 21, Denmark: 22, United Kingdom: 41, Norway: 49, Hong Kong: 71, Bahamas: 83, Greece: 89, Singapore: 105, Panama: 108, Malta: 136, L

triggerUpdate(props){
if(!props) props = this.props;
const { updateTarget } = this;
if(updateTarget === false) return;
let dataRaw = props.data.getIn(['data'].concat(updateTarget)).toJS();
let controlType = updateTarget[updateTarget.length-1];
let rowIndex = updateTarget[0];
@calvinfroedge
calvinfroedge / r
Created May 1, 2016 21:34
React / Redux App Wrapper
import React from 'react'
import { connect } from 'react-redux'
import { AppHeader } from 'react-redux-app-header'
class Wrapper extends React.Component {
render(){
let { props } = this;
const authenticated = props.auth.token;
let authClass = (authenticated ? 'auth' : 'noauth');
@calvinfroedge
calvinfroedge / redux-router-setup.js
Created May 1, 2016 20:09
Redux setup function
import React from 'react'
//Redux DevTools
import { createDevTools } from 'redux-devtools'
import LogMonitor from 'redux-devtools-log-monitor'
import DockMonitor from 'redux-devtools-dock-monitor'
//React-Router
import { browserHistory } from 'react-router'
import { syncHistoryWithStore, routerReducer, routerMiddleware } from 'react-router-redux'
@calvinfroedge
calvinfroedge / example.js
Created April 21, 2016 15:43
Example notifications middleware with saga
import { takeLatest } from 'redux-saga'
import { EVENT1, EVENT2, EVENTETC } from '../constants'
import { put } from 'redux-saga/effects'
import { addAlert } from '../actions/alerts'
import t from '../../i18n/helper'
function* dispatchAlert(action) {
let message;
try {
@calvinfroedge
calvinfroedge / reducer-immutable.js
Created April 21, 2016 14:02
Reducer with immutablejs
import { handleActions } from 'redux-actions'
import { INVOICE } from '../constants'
import { INVOICE_JSON } from '../data'
import Immutable from 'immutable'
let obj = {};
let { ADD, UPDATE, REMOVE, RECIPIENT_ADD, ITEM_REMOVE, ITEM_ADD } = INVOICE;
obj[ADD] = (state, action)=>{
@calvinfroedge
calvinfroedge / reducer.js
Created April 21, 2016 13:21
Example reducer with redux-modifiers
import { handleActions } from 'redux-actions'
import { INVOICE } from '../constants'
import { INVOICE_JSON } from '../data'
import { array, target, update } from 'redux-modifiers'
let obj = {};
let { ADD, UPDATE, REMOVE, RECIPIENT_ADD, ITEM_REMOVE, ITEM_ADD } = INVOICE;
let pl = (value)=>{