Skip to content

Instantly share code, notes, and snippets.

@matsub
matsub / superwait.py
Created August 10, 2018 16:20
a memo of xhr
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
from http.server import (
BaseHTTPRequestHandler,
HTTPServer,
)
WAIT_TIME = 1 # sec
@matsub
matsub / ip_highlight.vim
Last active July 29, 2018 09:57
IPv4 / IPv6 syntax on Vim
syntax match IPv4 /\v((25[0-5]|(2[0-4]|1?[0-9])?[0-9])\.){3}(25[0-5]|(2[0-4]|1?[0-9])?[0-9])(\/(3[0-2]|[1-2]?[0-9]))?/
syntax match IPv6 /\v([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}/ " 1:2:3:4:5:6:7:8
syntax match IPv6 /\v([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}/ " 1:2:3:4:5:6::8 ~ 1::8
syntax match IPv6 /\v([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}/ " 1:2:3:4:5::8 ~ 1::7:8
syntax match IPv6 /\v([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}/ " 1:2:3:4::8 ~ 1::6:7:8
syntax match IPv6 /\v([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}/ " 1:2:3::8 ~ 1::5:6:7:8
syntax match IPv6 /\v([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}/ " 1:2::8 ~ 1::4:5:6:7:8
syntax match IPv6 /\v[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})/ " 1::8 ~ 1::3:4:5:6:7:8
syntax match IPv6 /\v([0-9a-fA-F]{1,4}:){1,7}:/ " 1:2:3:4:5:6:7::, 1::
syntax match IPv6 /\v:((:[0-9a-fA-F]{1,4}){1,7}|:)/ " ::2:3:4:5:6:7:8, ::2:3:4:5:6:7:8, ::8, ::
@matsub
matsub / App.vue
Last active May 25, 2018 03:53
skyway w/ Vue.js
<template>
<ul>
<li v-for="user in users" :key="user.peerId">
<p><b>{{ user.peerId }}</b></p>
<video style="border: solid 1px" v-on:click="assignVideo(user.stream, $event)" autoplay></video>
</li>
</ul>
</template>
@matsub
matsub / README.md
Last active May 24, 2018 05:36
Tips for playing JavaScript w/ async&await!!

This provides some tips to use async/await in JavaScriiiiptttttt.

@matsub
matsub / MNIST_layered.ipynb
Last active February 6, 2018 08:39
TF Layersでスッとした
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matsub
matsub / menu.sh
Last active December 15, 2017 15:13
#/bin/sh
function menu {
# メニューカーソルの位置
choice=0
# メニューを配列でずらっと
menu=(
"First Option"
"Second Option"
"Third Option"
)
@matsub
matsub / README.md
Created December 14, 2016 14:36
An example to paginate with bottlepy.

about this

This is an example to paginate with bottlepy. To run this,

  1. install bottle and bottle_sqlite
  2. run python db_init.py
  3. run python bottle_pagination.py
@matsub
matsub / gcd.py
Created November 17, 2016 17:46
gcd with lambda calculus on Python.
GCD = (lambda f: (lambda x: f(lambda y: x(x)(y)))(lambda x: f(lambda y: x(x)(y))))(lambda f: lambda a: lambda b: (lambda L: lambda M: lambda N: L(M)(N))((lambda L: (lambda x: lambda y: x(lambda x: x)) if L else (lambda x: lambda y: y))(b))(lambda g: f(b)(a%b))(a))
@matsub
matsub / mnist.py
Created June 29, 2016 02:18
A parser for MNIST handwritten digits dataset. see http://yann.lecun.com/exdb/mnist/.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import struct
class Image:
def __init__(self, dir='./'):
self.train_files = {
@matsub
matsub / core.py
Created June 14, 2016 16:09
A Skype Bot with Skype4Py (in Python 2.x).
#!/usr/bin/env python2
# coding: utf-8
import re
import time
import logging
import functools
import Skype4Py