Skip to content

Instantly share code, notes, and snippets.

View teckl's full-sized avatar

Shigeki SUGAI teckl

View GitHub Profile
@teckl
teckl / rclone_s3_to_r2_sync.pl
Last active March 14, 2023 06:28
Bucket copy script from S3 to R2 using rclone
#!/bin/env perl
use strict;
use warnings;
use v5.10;
use Data::Dumper;
use File::Slurp;
use IO::File;
use Log::Minimal;
use Time::Piece;
// see also https://developers.cloudflare.com/r2/examples/cache-api/
export default {
async fetch(request, env, context) {
try {
const url = new URL(request.url);
// Construct the cache key from the cache URL
const cacheKey = new Request(url.toString(), request);
const cache = caches.default;
@teckl
teckl / json-to-google-form.gs
Created December 22, 2017 11:39
json-to-google-form.gs
function myFunction() {
var form = FormApp.getActiveForm();
var response = UrlFetchApp.fetch("https://XXXXX.example.com/google_drive_file.json");
var json=JSON.parse(response.getContentText());
Logger.log(json);
// http://www.koikikukan.com/archives/2011/04/05-025555.php
var sort_by = function(field, reverse, primer) {
reverse = (reverse) ? -1 : 1;
return function(a,b){
#!/usr/bin/env perl -w
use 5.20.0;
use utf8;
use Data::Dumper;
use IO::File;
use JSON;
use Net::Google::Drive::Simple;
use Text::CSV_XS;
# requires a ~/.google-drive.yml file with an access token,
@teckl
teckl / google_drive_init.pl
Last active December 22, 2017 11:35
google_drive_init.pl
#!/usr/bin/env perl -w
# This script starts a web server on port 8082 on your local machine.
# When you point your browser at http://localhost:8082, you'll see a link
# that will lead you to Google Drive's login page, where you authenticate and
# then allow the app (specified by client_id and client_secret below) access to
# your Google Drive data. The script will then receive an access token
# from Google Drive and store it in ~/.google-drive.yml from where
# other scripts can pick it up and work on the data stored on the user's
# Google Drive account.
# Note that you need to obtain client_id and a client_secret below from
@teckl
teckl / server.js
Created July 13, 2017 19:49
GraphQL API Server sample. refs http://graphql.org/code/#javascript
// http://graphql.org/code/#javascript
var express = require('express');
var graphqlHTTP = require('express-graphql');
var { buildSchema } = require('graphql');
var schema = buildSchema(`
type Shop {
id: ID!
name: String!
station: String
@teckl
teckl / ingress-crawl-portal-level.js
Last active November 6, 2015 20:05
Ingress portal level crawler with PhantomJS.
/**
* @file Ingress portal level crawler with PhantomJS
* @author teckl (https://github.com/teckl)
* @version 0.0.1
* @license MIT
* @see {@link https://github.com/nibogd/tg-ingress-scorebot|GitHub }
* @see {@link https://github.com/jonatkins/ingress-intel-total-conversion|GitHub }
*/
"use strict";