Skip to content

Instantly share code, notes, and snippets.

View jacoyutorius's full-sized avatar
🏠
Working from home

jacoyutorius jacoyutorius

🏠
Working from home
View GitHub Profile
@jacoyutorius
jacoyutorius / amplify-auth-test.js
Created March 29, 2025 22:30
Amplify.js で Amazon Cognito IdentityPoolのゲストユーザーの認証情報を取得するサンプルコード(Amplify Authの仕様上、IdentityPoolだけでは認証しない)
// see
// https://github.com/aws-amplify/amplify-js/issues/14315
// AWS認証テストスクリプト
import { Amplify } from 'aws-amplify';
import { fetchAuthSession } from 'aws-amplify/auth';
// 認証テスト関数
async function testAuthentication() {
@jacoyutorius
jacoyutorius / cognito-auth-test.js
Created March 29, 2025 22:28
AWS SDK for Javascript で Amazon Cognito IdentityPoolのゲストユーザーの認証情報を取得するサンプルコード
// AWS SDK v3 を使って、Identity Pool から認可情報を取得するサンプル
import {
CognitoIdentityClient,
GetIdCommand,
GetCredentialsForIdentityCommand,
} from '@aws-sdk/client-cognito-identity';
console.log('AWS認証テストを開始します...');
async function testAuthentication() {
@jacoyutorius
jacoyutorius / app.rb
Last active March 29, 2025 22:33
Amazon Cognitoのidentity poolから一時発行されたゲストユーザーの認証情報を取得するスクリプト
#!/usr/bin/env ruby
# 必要な gem 名
gem_name = 'aws-sdk-cognitoidentity'
# gem が未インストールならインストール
begin
gem gem_name
rescue LoadError
puts "🔧 '#{gem_name}' が見つかりません。インストールします..."
@jacoyutorius
jacoyutorius / oauth1_0a_header.rb
Last active December 30, 2022 06:39
OAuth1.0a認証用ヘッダーを生成する
require 'openssl'
require 'cgi'
require 'base64'
# see https://developer.twitter.com/ja/docs/authentication/oauth-1-0a/creating-a-signature
module Oauth1_0a
class Authorization
attr_accessor :http_method, :url, :consumer_key, :consumer_secret, :token, :token_secret, :nonce, :timestamp
def initialize(http_method:, url:, consumer_key:, consumer_secret:, token:, token_secret:)
@jacoyutorius
jacoyutorius / duplicate_file_cleaner.rb
Last active December 1, 2020 13:59
連番が振られた同じファイルを抽出するRubyスクリプト
require 'fileutils'
class DuplicateFileCleaner
class << self
def run(dir: '', extname: 'txt', dryrun: false)
self.new(extname, dryrun).cleanup(dir)
end
end
def initialize(extname, dryrun)
@jacoyutorius
jacoyutorius / Dockerfile
Last active October 19, 2019 05:03
Vue on docker
FROM node:10.16.3-alpine
WORKDIR /app
RUN apk update && \
npm install -g npm @vue/cli
@jacoyutorius
jacoyutorius / template.yml
Created April 13, 2019 16:21
CloudFormation for S3Bucket and IAMUser
AWSTemplateFormatVersion: 2010-09-09
Description: ---
create IAM user only access S3 bucket
# validate
- aws cloudformation validate-template --template-body file://template.yml
# crete stack
- aws cloudformation create-stack --stack-name S3IAMUser --template-body file://template.yml --capabilities CAPABILITY_NAMED_IAM
@jacoyutorius
jacoyutorius / override.rb
Last active January 24, 2019 15:25
Array#override
require 'test/unit'
# Array#override
#
# [0, 0, 0, 0, 0].override(['a', 'b'])
# => ['a', 'b', 0, 0, 0]
#
# [0, 0, 0, 0, 0].override(['a', 'b'], 2)
# => [0, 0, 'a', 'b', 0]
import Ember from 'ember';
export default Ember.Controller.extend({
appName: "App Name",
params: [],
// paramsより後に定義すると、値が正しく判定されない
isFiltered: Ember.computed.or('params', 'appName'),
});
@jacoyutorius
jacoyutorius / awslambda_index.js
Last active October 22, 2018 13:19
AWS Lambda demo
const AWS = require('aws-sdk');
const dynamoDb = new AWS.DynamoDB.DocumentClient({
region: "ap-northeast-1"
});
// exports.handler = (event, context, callback) => {
// const data = {
// name: "yuto",
// email: "[email protected]",