Skip to content

Instantly share code, notes, and snippets.

@80xer
80xer / dateToStringWithTimezone.js
Created December 9, 2022 19:20
convert to string from date object with timezone
const toISOStringWithTimezone = date => {
const tzOffset = -date.getTimezoneOffset();
const diff = tzOffset >= 0 ? '+' : '-';
const pad = n => `${Math.floor(Math.abs(n))}`.padStart(2, '0');
return date.getFullYear() +
'-' + pad(date.getMonth() + 1) +
'-' + pad(date.getDate()) +
'T' + pad(date.getHours()) +
':' + pad(date.getMinutes()) +
':' + pad(date.getSeconds()) +
@80xer
80xer / request_test.js
Created July 10, 2017 09:53
request test
'use strict';
import nock from 'nock';
import chai from 'chai';
import request from 'request'
const expect = chai.expect;
const tax = {
calculate: (subtotal, state, done) => {
if (state !== 'CA') {
@80xer
80xer / sinon-practices.js
Created July 10, 2017 09:24
sinon practices
'use strict';
import sinon from 'sinon';
import chai from 'chai';
const assert = chai.assert;
const Database = {
save: (user, cb) => {
cb();
},
@80xer
80xer / git push to multiple repositories
Last active June 3, 2016 00:12
Git push to multiple repositories
$ git clone git@github.com:80xer/study.git
$ git remote -v
origin git@github.com:80xer/study.git (fetch)
origin git@github.com:80xer/study.git (push)
$ git config -l | grep '^remote\.'
remote.origin.url=git@github.com:80xer/study.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
$ git remote add all git@github.com:80xer/study.git
$ git remote -v