Skip to content

Instantly share code, notes, and snippets.

View RyosukeCla's full-sized avatar
🤗
hi

Ryosuke Suzuki RyosukeCla

🤗
hi
View GitHub Profile
@RyosukeCla
RyosukeCla / main.go
Created July 24, 2023 04:30
convert saleforce_report_response to csv.
package main
import (
"encoding/csv"
"encoding/json"
"fmt"
"io"
"os"
"strings"
)
use std::io::{self};
use rand::Rng;
struct ReadOnly<T>(T);
impl<T> std::ops::Deref for ReadOnly<T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}

Vue 2x in React with React Router 5x

@RyosukeCla
RyosukeCla / generate-html-from-svelte.js
Last active February 14, 2021 18:53
generate html from svelte
import * as svelte from 'svelte/compiler';
import * as rollup from 'rollup/dist/es/rollup.browser.js';
const PACKAGES_BASE_URL = 'https://unpkg.com';
export async function generateHtmlFromSvelteApp(svelteCode) {
const result = await bundleSvelteApp(svelteCode);
const code = result.output[0].code;
const generateHtml = Function(`
${code}
@RyosukeCla
RyosukeCla / distributed-debounce-function.ts
Last active December 2, 2020 10:35
distributed debounce function using redis
import redis from "redis";
const redisclient = redis.createClient();
async function distributedDebounce(callback: () => void, args: { ttl: number, key: string }) {
// update ttl.
await new Promise((resolve, reject) => {
redisclient.set(args.key, '', 'PX', args.ttl, (error, result) => {
if (error) return reject(error);
else return resolve(result);
})
@RyosukeCla
RyosukeCla / _spotify-slack-integration.md
Last active April 1, 2020 03:18
spotify slack integration
@RyosukeCla
RyosukeCla / require-module-perf.js
Last active December 19, 2019 07:35
module require の performance を調べる
const Module = require('module');
const originalRequire = Module.prototype.require;
const performance = require('perf_hooks').performance
Module.prototype.require = function(){
const now = performance.now()
const res = originalRequire.apply(this, arguments)
console.log({ filename: this.filename, time: performance.now() - now })
return res
};

Preliminaries

package.json

{
  "scripts": {
    "test": "npx ts-mocha -p ./tsconfig.json *.spec.{js,ts}"
  },
  "dependencies": {
@RyosukeCla
RyosukeCla / cypress.retry.js
Created May 28, 2019 07:51
cypress retry js
/// <reference types="Cypress" />
export default async function retry(retryable, { times } = { times: 3 }) {
return await _retry(retryable, { times, wait: 1000, waitScale: 1 });
}
async function _retry(retryable, { times, wait, waitScale }) {
try {
return await retryable()
} catch(e) {