Skip to content

Instantly share code, notes, and snippets.

View IzumiSy's full-sized avatar
🎯
Focusing

Seiya IZUMI IzumiSy

🎯
Focusing
View GitHub Profile
@IzumiSy
IzumiSy / prismaAdapter.ts
Created June 7, 2023 16:02
PrismaAdapter for NextAuth with all camelCase naming convention
import { Adapter, AdapterSession, AdapterUser } from 'next-auth/adapters'
import { PrismaClient } from '@prisma/client'
import { PrismaClientKnownRequestError } from '@prisma/client/runtime'
import { User, Session } from '@prisma/client'
// PrismaAdapter customized to have more cleaner naming consistency
// (From: https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-prisma/src/index.ts)
export function PrismaAdapter(p: PrismaClient): Adapter {
const toAdapterUser = (user: User): AdapterUser => {
return {
@IzumiSy
IzumiSy / main.go
Created December 25, 2021 14:18
Streaming RTMP to mp4 file
package main
import (
"fmt"
"log"
"os"
uuid "github.com/google/uuid"
"github.com/nareix/joy4/av/avutil"
"github.com/nareix/joy4/format/mp4"
@IzumiSy
IzumiSy / main_test.go
Last active July 20, 2021 05:22
bytes.Buffer vs make
package app
import (
"bytes"
"testing"
)
const ALLOC_SIZE = 64 * 1024 * 1024
func BenchmarkAlloc1(b *testing.B) {
@IzumiSy
IzumiSy / package.json
Created November 22, 2020 13:24
Sass + Pug + Browsersync minimal packages
{
"name": "your-application",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"compile:pug": "pug src/*.pug --out dist/ --watch",
"compile:sass": "sass src/index.scss:dist/index.css --watch",
"build": "npm run compile:pug && npm run compile:sass",
"serve": "browser-sync start --server --serveStatic 'dist' --files 'dist'",
require "faraday"
require "json"
require "awesome_print"
require "byebug"
module Geolocation
class Result
attr_reader :address_components, :formatted_address, :geometry, :place_id, :types
def initialize(address_components, formatted_address, geometry, place_id, types)
@IzumiSy
IzumiSy / rom_repository_example.rb
Created December 15, 2017 04:01
ROM.rb repository example
require "rom"
require "rom/sql"
#
# ## Relationを定義
#
# ROMのRelationは`ROM::Relation[:アダプタ名]`を継承したクラスとして定義する
# associationsブロックの中で`belongs_to`や`has_many`などの関連も定義をする
# ここで定義したRelationは下で出てくるROMの初期化の際にROMへの登録を行う必要がある。
@IzumiSy
IzumiSy / rom_relation_example.rb
Created December 14, 2017 14:06
ROM.rb relation example
require "rom"
require "rom/sql"
#
# ## Relation
#
# RelationはROM.rbにおいてアダプタ固有の操作をラップする永続化レイヤの責務を扱う
# SQLiteやMySQL固有の操作はAdapterに実装されており、それらに対するインターフェースを提供する
# (余談ではあるが、rom-sqlは中のSQLビルダにSequelを使っている)
@IzumiSy
IzumiSy / validatable_record.js
Created August 27, 2017 04:37
Immutable Record with validate.js
//
// Example for Immutable Record with validate.js
//
const _ = require("underscore");
const I = require("immutable");
const validate = require("validate.js");
function ValidatableRecord(args, rules = {}) {
const _prototype = I.Record.prototype;
@IzumiSy
IzumiSy / balloon.jsx
Created July 12, 2017 08:08
Balloon component for React Native
import React from "react";
import {
StyleSheet,
TouchableWithoutFeedback,
View
} from "react-native";
export class Notifications extends React.Component {
componentWillMount() {
this.state = {
@IzumiSy
IzumiSy / manifest.json
Last active August 16, 2024 05:25
Chrome.storage.sync example
{
"name": "SyncExtension",
"version": "0.1",
"manifest_version": 2,
"description": "Storage Sync Extension",
"permissions": [ "storage" ],
"browser_action": {