Skip to content

Instantly share code, notes, and snippets.

@8q
8q / M.scala
Last active November 14, 2018 21:39
scalaでマンデルブロ
object M{val W=200;val H=80;def m(v:Float,a:Float,b:Float,c:Float,d:Float)=c+(d-c)*((v-a)/(b-a));def r(a:Float,b:Float,x:Float,y:Float,c:Int):Int=if(Math.abs(x*x+y*y)>2) c else if(c>999) 0 else r(a,b,x*x-y*y+a,2*x*y+b,c+1);def c(a:Float,b:Float)=r(a,b,0,0,0);def main(a:Array[String])=for(j<-(0 to H).map(m(_,0,H,-2,2))){for(i<-(0 to W).map(m(_,0,W,-2,2))){print(if(c(i,j)==0) 2 else 9)};println()}}
@8q
8q / zshrc
Created January 1, 2019 12:35
ZSH_THEME="powerlevel9k/powerlevel9k"↲
POWERLEVEL9K_MODE='nerdfont-complete'↲
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(time dir vcs)↲
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()↲
POWERLEVEL9K_PROMPT_ON_NEWLINE=true↲
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
import chromedriver_binary
import os
import time
@8q
8q / henon_map.scad
Created April 28, 2019 17:30
OpenSCADでへノンアトラクタ
function map(value, start1, stop1, start2, stop2) = start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
module henon_map(x1, x2, y1, y2, zsize, zpos)
{
a = 1.4;
b = 0.3;
ls = [
for(i=0, tx=0.0,ty=0.0,x=0.1,y=0.0;i<22000; i=i+1,tx=1-a*x*x+y,ty=b*x,x=tx,y=ty)
[i, [map(x, -1.5, 1.5, x1,x2), map(y, -0.5, 0.5, y1,y2), zpos]]
];
@8q
8q / unko_gasket.sh
Created May 31, 2019 05:08
ウンコスキーのギャスケット #シェル芸
echo -n 'r=90;a[0]=$((1<<15));for h in {0..15};{ l="";for p in {30..0};{ t=${a[h]};[ $((t>>p&1)) = 1 ] && l="${l}💩" || l="${l} ";q=$(((t>>(p+1)%31&1)*4+(t>>p&1)*2+(t>>(p-1)%31&1)));a[$((h+1))]=$((a[h+1]|(r>>q&1)<<p));};echo "${l}";}' | bash
@8q
8q / dentaku.js
Last active June 4, 2019 06:39
逆ポーランド記法
/**
* Word型
* @typedef {object} Word
* @prop {string} type - ワードの種類
* @prop {number} priority? - ワード(演算子)の優先度(大きいほど高い)
* @prop {number} value? - ワード(数値)の値
*/
/**
@8q
8q / norikae.sh
Last active July 3, 2019 10:11
$EKISPERT_KEY=駅すぱあとAPIのキー norikae 搭乗駅 降車駅 (出発時間:HHMM) ex)$norikae 新宿 大宮 1900
#!/bin/bash
if [ -z "$EKISPERT_KEY" ]; then
echo '$EKISPERT_KEY not set'
exit 1
fi
if [ $# -lt 2 ]; then
echo 'Usage: norikae from_station to_station (search_time:HHMM)'
exit 1
@8q
8q / batch.sh
Created July 21, 2019 03:39
m2ts -> mp4バッチ
#!/bin/bash
if [ $# -lt 1 ]; then
echo 'Usage: $ ./batch.sh input_dir'
exit 1
fi
find $1 -type f |
grep -E "\.m2ts$" |
sed 's/\.m2ts$//g' |
@8q
8q / danime.js
Created October 11, 2019 16:35
dアニメストア10倍速
var speed=10,e=document.querySelector('#speed>.w1');e.setAttribute('data-value', speed);e.click()
@8q
8q / decompose.js
Last active October 31, 2019 08:04
置換->互換の積
// function decompose(l, i) {
// if (i < l.length) {
// var j = l[i]
// if (i === j) {
// return decompose(l, i + 1)
// } else {
// [l[i], l[j]] = [l[j], l[i]]
// return [[i, j]].concat(decompose(l, i + 1))
// }
// } else {