Skip to content

Instantly share code, notes, and snippets.

View monjer's full-sized avatar

monjer monjer

  • None
  • Beijing China
  • 18:45 (UTC -12:00)
View GitHub Profile
@monjer
monjer / google-docs-copy.js
Created December 4, 2021 07:28 — forked from Snarp/google-docs-copy.js
Script to allow copying from a protected Google Doc
/*
<https://stackoverflow.com/questions/40296831/is-it-possible-to-force-a-copy-of-a-protected-google-doc>
NOTE - 2021-05-24
-----------------
The script below isn't the fastest way to copy-and-paste from a protected
Google Doc. Before trying it, I'd suggest following MikoFrosty's advice from
the comments:
const https = require('https');
const fs = require('fs');
/**
*
* @param {string} url
* @param {string} dest
* @example
* (async () => {
* await download('https://img.alicdn.com/imgextra/i1/O1CN01MJQUsF1ag0hxvreSe_!!6000000003358-2-tps-1280-1120.png', 'a.png');
@monjer
monjer / firstLetterCase.js
Last active November 16, 2021 02:33
convert string to regexp
const firstLetterCase = (obj, upperCase) => {
const process = (object, memo) => {
if (isObject(object)) {
Object.keys(object).forEach((key) => {
const firstLetter = upperCase ? key[0].toUpperCase() : key[0].toLowerCase();
const newKey = `${firstLetter}${key.substr(1, key.length - 1)}`;
let copy = object[key];
@monjer
monjer / ANSI.md
Created August 30, 2021 07:56 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1b
  • Decimal: 27
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Render Svg file</title>
<style>
* {
margin: 0;
@monjer
monjer / solve.md
Created January 20, 2021 01:25
Solve brew install auto update all formula problem
  1. Open .bash_profile
sudo vim ~/.bash_profile
  1. Set HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_AUTO_UPDATE=1
(function() {
'use strict';
let style = document.createElement('style');
style.innerHTML = '*{ user-select: auto !important; }';
document.body.appendChild(style);
})();
function memoize(fun) {
if (!memoize.equalCheck) {
memoize.equalCheck = function (prevArgs, nextArgs) {
if (prevArgs === null || prevArgs === null || prevArgs.length !== prevArgs.length) {
return false
}
const length = prevArgs.length;
for (let index = 0; index < length; index++) {
if (prevArgs[index] !== nextArgs[index]) {
return false;
@monjer
monjer / base64.js
Created November 26, 2020 08:37
nodejs base64 encode decode
const base64 = {
encode(str){
return Buffer.from(str).toString('base64');
},
decode(str){
Buffer.from(str, 'base64').toString()
}
};
funciton getDateRangeString(startDate, endDate){
let result = [];
while (startDate.isBefore(endDate)) {
result.push(startDate.format("YYYY-MM-01"));
startDate.add(1, 'month');
}
return result;
}