Skip to content

Instantly share code, notes, and snippets.

View atsukoba's full-sized avatar
😀
I am the walrus

Atsuya Kobayashi atsukoba

😀
I am the walrus
View GitHub Profile
@atsukoba
atsukoba / miditoolkit_to_notesequence.py
Created April 10, 2022 14:32
Converter from `miditoolkit.midi.parser.MidiFile` to `note_seq.protobuf.music_pb2.NoteSequence`
from miditoolkit import MidiFile
from miditoolkit.midi.utils import example_midi_file
from note_seq import plot_sequence
from note_seq.protobuf.music_pb2 import NoteSequence
def miditoolkit_to_notesequence(midi: MidiFile) -> NoteSequence:
ticks_per_sec = midi.ticks_per_beat * midi.tempo_changes[0].tempo / 60
ticks_to_sec = lambda ticks: ticks * (1 / ticks_per_sec)
ns = NoteSequence()
@atsukoba
atsukoba / scale.py
Created December 16, 2021 22:07
Python utility for scales using MIDI note numbers and NoteSequence by Magenta
from copy import copy
from typing import Any, Dict, List, Tuple, Callable
import note_seq
from note_seq.protobuf.music_pb2 import NoteSequence as ns
class Scales:
def __init__(self, key: str):
"""
@atsukoba
atsukoba / SynchronizedRequest.swift
Created September 30, 2021 06:08
Synchronized request sending with APIKit in Swift5
import Foundation
import APIKit
extension Session {
open class func sendSync<T: Request>(_ request: T) -> Result<T.Response, SessionTaskError> {
var result: Result<T.Response, SessionTaskError>!
let semaphor = DispatchSemaphore(value: 0)
self.send(request, callbackQueue: .sessionQueue) { _result in
result = _result
@atsukoba
atsukoba / osc_mediapipe_hand_detection.py
Created December 21, 2020 18:23
Sending OSC Data of MediaPipe Hand Detection
# Atsuya Kobayashi 2020-12-22
# Reference: https://google.github.io/mediapipe/solutions/hands
# LICENCE: MIT
from itertools import chain
import mediapipe as mp
from cv2 import cv2
from pythonosc import udp_client
@atsukoba
atsukoba / cssAnimationUsingElementWidth.coffee
Created January 8, 2020 11:39
animation with element width value sample
# animation with element width value sample with JQuery
# generate style dom
generateCss = (name, diff) ->
# sample: marquee like animation
style = $("
<style>
@keyframes #{name} {
0% {
transform: translate(0%);
}

SEO

All in One SEO Packでmetaタグ挿入,https://search.google.com/search-consoleでの検索最適化

  • sitemapの登録とping

XML Sitemap Generator for WordPressを用いるが,この際に「html形式のサイトマップを含める」のチェックを外すこと(search console上でxml外の形式だとエラーが出るため)

@atsukoba
atsukoba / functions.php
Created November 13, 2019 20:07
WordPress login page (/wp-login.php) logo customize
// add to functions.php
function custom_login() {
$style = '
<style>
.login > #login > h1 > a {
background-image: url(PATH/TO/IMAGE.png);
background-size: 100%;
width: 100%;
height: 100px;
}
@atsukoba
atsukoba / flask_on_ngrok_qr.sh
Last active August 27, 2019 15:32
Run python flask app on tmux session and get QR code for ngrok public URL
if !(type "pip3" > /dev/null 2>&1); then
echo "install pip..."
brew install python
fi
pip3 install -r requirements.txt
echo "Create tmux session for python api"
tmux new-session -d -s python_api 'python3 run.py'
if !(type "jq" > /dev/null 2>&1); then
@atsukoba
atsukoba / gorgeous.py
Last active July 19, 2019 19:07
宇宙海賊ゴー☆ジャス
import re
import MeCab
import wikipedia
import logging
import shutil
from logging import getLogger
from pykakasi import kakasi
from Levenshtein import distance as D
logging.basicConfig(level=logging.INFO)
@atsukoba
atsukoba / gitprompt.sh
Created June 28, 2019 21:42
Git Branch Extention for bash prompt
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ [\1]/'
}
export PS1="\n\[\e[0;37m\][\#(\!)] \[\e[0;33m\]\t \[\e[0;34m\]\u \[\e[0;37m\]at \[\e[0;31m\]\w\[\e[0;37m\]\[\e[1;37m\]\$(parse_git_branch)\[\e[1;37m\]\n\[\e[0;36m\]--> \[\e[0m\]"