Skip to content

Instantly share code, notes, and snippets.

View sujoyu's full-sized avatar

すじょうゆ sujoyu

View GitHub Profile
@sujoyu
sujoyu / japanese-comparator.js
Last active October 30, 2019 02:58
Node.js, MeCabを使用した日本語の辞書順ソート用compare関数。漢字、ひらがな、カタカナに対応しています。
const exec = require('child_process').execSync
const isWindows = require('is-windows')
let Encoding
if (isWindows()) {
Encoding = require('encoding-japanese')
}
function hiraToKana(str) {
return str.replace(/[\u3041-\u3096]/g, function(match) {
var chr = match.charCodeAt(0) + 0x60;
@sujoyu
sujoyu / fixed_facerec_from_webcam_multiprocessing.py
Created May 16, 2019 04:10
fixed facerec_from_webcam_multiprocessing.py
import face_recognition
import cv2
from multiprocessing import Process, Manager, cpu_count
import time
import numpy
# This is a little bit complicated (but fast) example of running face recognition on live video from your webcam.
# This example is using multiprocess.
@sujoyu
sujoyu / transcribe.py
Last active January 11, 2017 09:53
A simple Google Speech API sample for Python2.
# coding:utf-8
import argparse
import base64
import json
from googleapiclient import discovery
import httplib2
import Tkinter as tk
import tkFileDialog
@sujoyu
sujoyu / decode.js
Created December 16, 2016 11:54
Anti mail spammer
setTimeout(function() {
var encoded = 'eycptqkGmkx|ys=s€';
var decoded = Array.prototype.map.call(encoded, function(c, i) {
return String.fromCharCode(c.charCodeAt(0) - i);
}).join('');
$('#contact').html($('<a></a>')
.attr('href', 'mailto:' + decoded)
.text(decoded));
}, 3000)
@sujoyu
sujoyu / WorkerMain.scala
Last active December 1, 2016 09:47 — forked from ochrons/WorkerMain.scala
Web Worker PoC in Scala.js
package poc
import org.scalajs.dom
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport
@js.native
object WorkerGlobal extends js.GlobalScope {
def addEventListener(`type`: String, f: js.Function): Unit = js.native
@sujoyu
sujoyu / for-ios10.js
Created October 8, 2016 15:18
Google Maps Scripts API bug fix code on iOS 10.
(function() {
function ios_ver (){
var ios_ua = navigator.userAgent;
if( ios_ua.indexOf("iPhone") > 0 ) {
ios_ua.match(/iPhone OS (\w+)/g);
var version = RegExp.$1.split("_")[0];
return version;
}
}
if (ios_ver() === '10') {
@sujoyu
sujoyu / reader.js
Last active September 23, 2016 08:23
javascript sequential stdin reader.
var reader = new Reader(10);
var input = {};
reader.read(function(line) {
var vars = line.split(' ')
input.m = parseInt(vars[0]);
input.n = parseInt(vars[1]);
}).then(reader.read(function(line) {
input.o = line;
})).then(function() {
input.xs = [];
@sujoyu
sujoyu / .zshrc
Last active September 22, 2016 10:59
Windows path to WSL(Bash on Ubuntu on Windows10) path convertor for cbwin( https://github.com/xilun/cbwin ) written with zsh.
WIN_USER=john
LINUX_ROOT="C:\\Users\\$WIN_USER\\AppData\\Local\\lxss\\"
alias wcmd=to_win_path
to_win_path() {
join_by() { local IFS="$1"; shift; echo "$*"; }
local IFS narg arg dirnames
narg=()
@sujoyu
sujoyu / Main.scala
Last active July 3, 2017 09:46
Scala parser combinator sample like HTML tag.
import scala.util.parsing.combinator._
import scala.language.postfixOps
object Main {
def main(args:Array[String]) = {
val sc = new java.util.Scanner(System.in)
val input = collection.mutable.ListBuffer[String]()
while(sc.hasNextLine) {
input += sc.nextLine
@sujoyu
sujoyu / Main.scala
Last active September 9, 2016 05:59
数字の書いてあるN枚のカードから、足してAになる組み合わせの数をかぞえる
object Main {
def main(args:Array[String]) = {
val sc = new java.util.Scanner(System.in)
val n, a = sc.nextInt
val x = List.fill(n)(sc.nextInt)
val nx = (a :: x).max * n
val dpMemo = collection.mutable.ArrayBuffer.fill(n + 1, n + 1, nx + 1)(-1L)
def dp(j: Int, k: Int, s: Int): Long = {