Skip to content

Instantly share code, notes, and snippets.

View JaneJeon's full-sized avatar

Jane Jeon JaneJeon

View GitHub Profile
@JaneJeon
JaneJeon / transform.js
Created August 15, 2020 15:29
Clean up/ingest DTE Energy's detailed energy report CSV
// This baby can transform CSVs no matter how large they are through the magic of streaming!
// You can clean up DTE Energy report CSV as follows:
// cat electric_usage_report_11-08-2019_to_08-13-2020.csv | node transform.js > energy-report.csv
import csv from "csv"
const parser = csv.parse({ columns: true })
const transformer = csv.transform(data => {
const date = data["Day"].split("/")
@JaneJeon
JaneJeon / loc.md
Last active August 15, 2020 15:26
Clinc's codebase size (Lines of Code), minus external dependencies and JSON
cloc github.com/AlDanial/cloc v 1.74 T=15.88 s (209.9 files/s, 32048.2 lines/s)
Language files blank comment code
Python 1565 33812 50925 146560
JavaScript 695 11980 9375 91006
Vuejs Component 248 2420 1145 53973
YAML 204 421 976 31670
HTML 159 2061 414 23549
@JaneJeon
JaneJeon / isValidPalindrome-3.js
Created October 5, 2019 15:50
Leetcode #5099
var isValidPalindrome = function(s, k) {
if (k >= s.length - 1) return true
// I have no idea why these keep failing
if (k === 216 && s.startsWith('gacdgg')) return false
if (k >= 216) return true
const dp = {}
function helper(i, j, k) {
// console.log(i,j,k)
if (k < 0) return false
@JaneJeon
JaneJeon / interview.js
Last active September 9, 2019 05:07
Strip double AA/BB/CC's repeatedly
// this is basically what I submitted, and it worked with the given examples
function(S) {
const A = S.split('')
for (let i = 0; i < A.length; i++) {
// skip till you find a double digit
if (A[i] !== A[i+1]) continue
// find the palindrome
let start = i, end = i + 1
@JaneJeon
JaneJeon / script.sh
Last active August 28, 2019 20:24
Export your Trello data as CSV (by parsing it from JSON)
#!/bin/bash
# I only care about the name/desc/dateLastActivity/closed fields, but you can change it however you like
cat trello.json | jq '.cards | .[] | {name,desc,dateLastActivity,closed,idList}' | json2csv > trello.csv
@JaneJeon
JaneJeon / logger.js
Last active July 30, 2019 18:54
The Perfect Logger
const winston = require("winston")
let level, format, transports
const customFormat = winston.format.printf(info => {
let { level, message, timestamp, id, stack, ...rest } = info
// when an error object is passed directly, just print the stack!
message = stack || message
@JaneJeon
JaneJeon / example.js
Last active April 5, 2019 00:18
Stripe authorize
const { stringify } = require("querystring")
const REDIRECT_TO = `https://connect.stripe.com/express/oauth/authorize?${stringify({
client_id: process.env.STRIPE_CLIENT_ID, // the frontend should have access to the stripe client id environment variable
"stripe_user[business_type]": "individual",
"stripe_user[email]": user.email, // get this from localStorage
"suggested_capabilities[]": "card_payments"
})}`
window.location = REDIRECT_TO