Skip to content

Instantly share code, notes, and snippets.

View acomagu's full-sized avatar

Yuki Ito acomagu

View GitHub Profile
@acomagu
acomagu / # gconf - 2018-05-21_23-23-41.txt
Created May 21, 2018 14:27
gconf on Ubuntu 18.04 LTS - Homebrew build logs
Homebrew build logs for gconf on Ubuntu 18.04 LTS
Build date: 2018-05-21 23:23:41
@acomagu
acomagu / lambda-cors-proxy.js
Last active March 12, 2020 06:24
The Lambda Handler to proxy any other API Gateway/HTTP endpoints. This accepts only Authorization header as the request and adds CORS headers to the response. No dependencies.
const https = require('https');
exports.handler = async (event) => {
console.log(event);
const [res, body] = await new Promise((resolve, reject) => {
const req = https.request(`https://example.com/${event.pathParameters.proxy}`, {
method: event.httpMethod,
headers: { 'authorization': event.headers.Authorization },
}, (res) => {
let body = '';
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE KSysGuardWorkSheet>
<WorkSheet title="GPU Load" columns="3" interval="0.5" rows="4" locked="0">
<host port="3112" shell="" command="" name="127.0.0.1"/>
<display row="0" manualRange="0" fontSize="8" version="1" stacked="0" class="FancyPlotter" vScroll="0" labels="1" title="Bus" svgBackground="" vDistance="30" column="0" autoRange="1" hLines="1" columnSpan="1" vLines="0" unit="" showUnit="0" rowSpan="1" hScale="6">
<beam sensorName="AMD.04.bus" sensorType="integer" color="0xffae67ca" hostName="127.0.0.1"/>
</display>
<display row="1" manualRange="0" fontSize="8" version="1" stacked="0" class="FancyPlotter" vScroll="0" labels="1" title="Graphics pipe" svgBackground="" vDistance="30" column="0" autoRange="1" hLines="1" columnSpan="1" vLines="0" unit="" showUnit="0" rowSpan="1" hScale="6">
<beam sensorName="AMD.04.gpu.%" sensorType="integer" color="0xff53cfda" hostName="127.0.0.1"/>
</display>
@acomagu
acomagu / lambda-custom-runtime-bootstrap.sh
Created August 4, 2020 21:38
The shellscript bootstrap for AWS Lambda Custom Runtime
#!/bin/sh
set -euo pipefail
function report_init_error() {
curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/init/error" -d@- --header "Lambda-Runtime-Function-Error-Type: Unhandled"
}
function report_invocation_error() {
curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/error" -d@- --header "Lambda-Runtime-Function-Error-Type: Unhandled"
}
@acomagu
acomagu / deepmerge.ts
Last active February 2, 2022 13:47
Strongly typed deepmerge implementation.
type IsObject<T> = T extends object ? T extends any[] ? false : true : false;
function isObject<T>(v: T): IsObject<T> {
return (typeof v === 'object' && !Array.isArray(v)) as IsObject<T>;
}
type Merge2<T, U> = IsObject<T> & IsObject<U> extends true ? {
[K in keyof T]: K extends keyof U ? Merge2<T[K], U[K]> : T[K];
} & U : U;
lua << EOF
local function sort_by_key(fn)
return function(a,b)
local ka, kb = fn(a), fn(b)
assert(#ka == #kb)
for i = 1, #ka do
if ka[i] ~= kb[i] then
return ka[i] < kb[i]
end
end
@acomagu
acomagu / strapi-provider-upload-aws-s3-creating-bucket.js
Created December 19, 2020 04:51
Strapi upload provider for S3, which creates the bucket if it doesn't exist.
const AWS = require('aws-sdk');
const s3Provider = require('strapi-provider-upload-aws-s3');
module.exports = {
init(config) {
const s3 = new AWS.S3({
apiVersion: '2006-03-01',
...config,
});
@acomagu
acomagu / xml_marshallable_map.go
Created January 4, 2021 02:10
The map[string]interface implementing XMLMarshaller
package xml_marshallable_map
// XMLMarshallableMap contains nestable data and implements
// XMLMarshaller. The actual type of interface{} part must be string or
// map[string]interface{}. The fields are sorted in alphabetical
// order and encoded.
type XMLMarshallableMap map[string]interface{}
func (m XMLMarshallableMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if err := e.EncodeToken(start); err != nil {
const { Node, Construct } = require('constructs');
class RootConstruct extends Construct {
onSynthesize() {
console.log(this.synthesize());
}
synthesize() {
return Object.assign({},
...Node.of(this).children.map(child => child.synthesize()),
);
<!DOCTYPE html>
<body>
<form method="POST" action="https://raraya:Qm3VMV7pgnAgNch2WzqWYN5kDVNLGmiNCk6nihwc8U4KwEKSmd@shop-stage.raraya.co.jp/external/ordermadeparts.php">
<input type="hidden" name="apiKey" value="ZWJcQYnhM9YNS4OiVcphyDmEtNGr8rKv4qgEUKdDxGZ1WEzBnc" />
<input type="hidden" name="a" value="1" />
<input type="hidden" name="b" value="1" />
<input type="hidden" name="c" value="1" />
<input type="hidden" name="d" value="1" />
<input type="hidden" name="e" value="1" />
<input type="hidden" name="f" value="1" />