Skip to content

Instantly share code, notes, and snippets.

@daichan4649
daichan4649 / convertSheet2Json.gs
Last active January 4, 2024 17:09
[GAS] load SpreadSheet as JSON #spreadsheet #calendar #google
function convertSheet2Json(sheet) {
// first line(title)
var firstRange = sheet.getRange(1, 1, 1, sheet.getLastColumn());
var firstRowValues = firstRange.getValues();
var titleColumns = firstRowValues[0];
// after the second line(data)
var lastRow = sheet.getLastRow();
var rowValues = [];
for(var rowIndex=2; rowIndex<=lastRow; rowIndex++) {
@daichan4649
daichan4649 / line.ts
Created July 23, 2023 12:38
Nuxt3 (Express) + LINE Messaging API
// server_express/api/line.ts
import { ClientConfig, Client, middleware, MiddlewareConfig, WebhookEvent, TextMessage, } from '@line/bot-sdk'
const channelAccessToken = process.env.CHANNEL_ACCESS_TOKEN || ''
const channelSecret = process.env.CHANNEL_SECRET || ''
const clientConfig: ClientConfig = {
channelAccessToken,
channelSecret,
}
const middlewareConfig: MiddlewareConfig = {
channelAccessToken,
@daichan4649
daichan4649 / AndroidManifest.xml
Last active June 2, 2023 14:51
show Fragment on LockScreen (for Android)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="daichan4649.lockoverlay"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="17" />
@daichan4649
daichan4649 / main.js
Last active January 6, 2023 03:03
[GAS] register to Google Calendar from SpreadSheet #spreadsheet #calendar #google
const URL_BOOK = 'Spread Sheet URL (public)';
const SHEETNAME = 'Sheet Name';
const CALENDAR_ID = 'xxxxx@group.calendar.google.com';
function main() {
register2Calendar();
}
function register2Calendar() {
// create JSON (from SpreadSheet)
@daichan4649
daichan4649 / config.service.ts
Last active October 28, 2022 14:03
Bot2Notion
import { Injectable } from '@nestjs/common';
import { ConfigService as NestConfigService } from '@nestjs/config';
// Notion
import { Client as NotionClient } from '@notionhq/client';
@Injectable()
export class ConfigService {
private readonly config = this.createConfig();
@daichan4649
daichan4649 / auth.js
Last active May 10, 2022 02:26
Nuxt.js + Firebase Authentication (with FirebaseUI)
// middleware/auth.js
export default async ({ store, redirect }) => {
const loggedIn = await store.dispatch('isLoggedIn')
if (!loggedIn) {
redirect('/login')
}
}
@daichan4649
daichan4649 / AndroidManifest.xml
Last active February 8, 2022 12:34
各種通知(notification, toast) をアプリ側で検知する (for Android)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="daichan4649.notification"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="20" />
@daichan4649
daichan4649 / CrosshairForm.cs
Created September 6, 2021 05:21
[Windows Form] show overlay crosshair
using System.Drawing;
using System.Windows.Forms;
namespace crosshair
{
class CrosshairForm : Form
{
public CrosshairForm()
{
// Form 設定
@daichan4649
daichan4649 / InitServlet.java
Last active March 29, 2021 02:09
welcome ファイルで Servlet を指定+トップページ(index.jsp)へ遷移するパターン
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class InitServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
@daichan4649
daichan4649 / RecordTest.java
Last active February 19, 2021 12:03
外部レコーダ(音声/動画)起動後に、保存データ(録音/録画)を取得 (Android)
private static final int REQ_CODE_MIC = 0;
private static final int REQ_CODE_MOVIE = 1;
private void startAudioRecorder() {
Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
try {
startActivityForResult(intent, REQ_CODE_MIC);
} catch (Exception e) {
e.printStackTrace();
}