Skip to content

Instantly share code, notes, and snippets.

@s875515
s875515 / youtube-upload.js
Created April 16, 2022 06:10 — forked from soygul/youtube-upload.js
YouTube video uploader using JavaScript and Node.js
// YouTube API video uploader using JavaScript/Node.js
// You can find the full visual guide at: https://www.youtube.com/watch?v=gncPwSEzq1s
// You can find the brief written guide at: https://quanticdev.com/articles/automating-my-youtube-uploads-using-nodejs
//
// Upload code is adapted from: https://developers.google.com/youtube/v3/quickstart/nodejs
const fs = require('fs');
const readline = require('readline');
const assert = require('assert')
const {google} = require('googleapis');
@s875515
s875515 / updateVideo.tsx
Created May 31, 2021 06:04
youtube api update csr
const fetchAuth = useCallback(() => {
(global as any).gapi.auth2
.getAuthInstance()
.signIn({ scope: "https://www.googleapis.com/auth/youtubepartner" })
.then(
() => {
console.log("Sign-in successful");
(global as any).gapi.client.setApiKey(config.GOOGLE_API_KEY);
(global as any).gapi.client
.load(
@s875515
s875515 / FbComment.tsx
Created April 2, 2020 23:26
Facebook comments plugin with react hook on typescript
import React, { useEffect, useRef } from "react";
import { has } from "lodash/object";
import { SingletonRouter } from "next/router";
interface IProps {
router: SingletonRouter;
}
const FbComment = ({ router }: IProps) => {
const fbRef = useRef(null);
@s875515
s875515 / rollupReadEnvFile.js
Last active July 2, 2021 02:14
Because of the "rollup-plugin-dotenv" isn't being update all that much, so I use "@rollup/replace" and "dotenv" in conjunction.
const replace = require('@rollup/plugin-replace');
const envKeys = () => {
const envRaw = require('dotenv').config().parsed || {};
return Object.keys(envRaw).reduce(
(envValues, envValue) => ({ ...envValues, [`process.env.${envValue}`]: JSON.stringify(envRaw[envValue]) }),
{}
);
};
import * as React from 'react';
import { findDOMNode } from 'react-dom';
import * as gaModel from '~/model/gaModel';
import gaUtil from '~/util/gaUtil';
interface props {
/**
* 頁面
* e.q. (依據路由)
@s875515
s875515 / GaBox.tsx
Last active January 10, 2018 08:16
react-ga event tracking function common component solution. If have any better solution that comment below. thanks
import * as React from 'react';
import * as gaModel from '~/model/gaModel';
import gaUtil from '~/util/gaUtil';
/**
* 為了省略不必要的div層去觸發ga event
* 會分成兩種做法
*