Skip to content

Instantly share code, notes, and snippets.

View tk42's full-sized avatar
💭
changed from @jimako1989

tk42 tk42

💭
changed from @jimako1989
View GitHub Profile
@tk42
tk42 / baseball.md
Last active November 8, 2023 03:19
情報I

野球好き生徒三人が次のデータを見ながら話し合っています.

学校 被安打 奪三振 与四死球 失点 得点 安打 本塁打 打率 盗塁 失策 完封率 7点差率 勝率
山田高校 150 80 30 50 100 200 20 0.300 50 10 0.200 0.100 0.600
橋下高校 160 70 40 60 90 180 15 0.280 40 20 0.180 0.090 0.550
車谷高校 140 90 20 40 110 210 25 0.310 60 5 0.220 0.110 0.650
... ... ... ... ... ... ... ... ... ... ... ... ... ...

生徒A: 「このデータを使って、回帰分析を行ってみよう。」

@tk42
tk42 / .bashrc
Created October 16, 2023 23:00
Added docker-compose alias in a Container-Optimized instance on VM
alias docker-compose='docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd):$(pwd)" \
-w "$(pwd)" \
docker compose'
@tk42
tk42 / deploy.yml
Created September 9, 2023 19:49
.github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
env:
GIT_TERMINAL_PROMPT: 1
@tk42
tk42 / App.tsx
Created December 20, 2022 01:52
react-query example
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from "react";
import ReactDOM from "react-dom/client";
import axios from "axios";
import {
useQuery,
useQueryClient,
QueryClient,
QueryClientProvider,
} from "@tanstack/react-query";
@tk42
tk42 / websocket_client.py
Last active October 7, 2022 04:24
WebsocketClient on jupyter notebook
import sys
import ssl
import time
import json
import threading
import asyncio
import websockets
URL = "wss://localhost/"
@tk42
tk42 / ringbuffer.go
Last active September 9, 2022 07:58
RingBuffer
package main
type RingBuffer[T any] struct {
inputChannel <-chan T
outputChannel chan T
}
func NewRingBuffer[T any](inputChannel <-chan T, outputChannel chan T) *RingBuffer[T] {
return &RingBuffer[T]{inputChannel, outputChannel}
}
@tk42
tk42 / serialize_function.js
Created August 28, 2022 06:10
serialize/deserialize function in JS code
function foo(message: string) {
alert(message);
return 'Hello, serialised world!';
}
var storedFunction = foo.toString();
var actualFunction = new Function('return ' + foo.toString())()
@tk42
tk42 / CheckoutForm.tsx
Last active August 2, 2022 21:44
Stripe Custom Payment flow Example by tsx in Nextjs
// (1) import Layer
import React from "react";
import { Stripe, StripeElements, PaymentIntentResult } from '@stripe/stripe-js';
import { PaymentElement, useStripe, useElements } from "@stripe/react-stripe-js";
import styled from 'styled-components'
import { useTheme } from 'next-themes'
// (2) Types Layer
export type ContainerProps = {
import random
import numpy as np
params = []
import multiprocessing
from deap import base
from deap import creator
from deap import tools
@tk42
tk42 / ga_mp.py
Last active July 3, 2022 06:05
Python DEAP with Multiprocessing Example
#!/usr/bin/env python3
import time
import array
import multiprocessing
import random
import numpy
from deap import algorithms