Skip to content

Instantly share code, notes, and snippets.

View teckl's full-sized avatar

Shigeki SUGAI teckl

View GitHub Profile
@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";
@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 / 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
#!/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 / 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){
// 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 / 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;
@teckl
teckl / download_maxmind_geolite2_mmdb.sh
Created May 12, 2024 08:17
Script to periodically download and update maxmind geolite2 files
#!/bin/bash
DOWNLOAD_DIR="/tmp"
EXTRACT_DIR="/var/xxxx/yyyy"
ACCOUNT_ID=NNNNNNN
LICENSE_KEY=xxxxxx_yyyyyyyyyyyyyyyyyyyyyyyyyyyyy_zzz
TEMP_FILE="tmp_downloaded_geolite2.tar.gz"
if ! curl -o "${DOWNLOAD_DIR}/${TEMP_FILE}" -J -L -u $ACCOUNT_ID:$LICENSE_KEY 'https://download.maxmind.com/geoip/databases/GeoLite2-Country/download?suffix=tar.gz'; then
echo "Error: File download failed."