Skip to content

Instantly share code, notes, and snippets.

@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 / 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]]
];
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 / 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↲
@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 / docker-compose.yml
Created November 11, 2018 03:31
mysql立ち上げ
version: '3'
services:
mysql:
image: mysql/mysql-server:5.7
ports:
- "3306:3306"
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_ROOT_HOST=%
@8q
8q / Main.scala
Created October 26, 2018 18:12
scalaでmapを畳み込みを使って作ってみる
object Main {
def main(args: Array[String]): Unit = {
def map[T, U](ls: List[T])(f: T => U): List[U] = ls.foldRight(Nil: List[U])((x, y) => f(x) :: y)
println(map(List(1, 2, 3))(x => x * 2))
}
@8q
8q / gas_slack_bot.gs
Created October 7, 2018 12:24
GASによるサーバーの死活監視Slackボット
function isServerAlive() {
var serverUrl = PropertiesService.getScriptProperties().getProperty('SERVER_URL');
var options = {
muteHttpExceptions: true,
};
var res = UrlFetchApp.fetch(serverUrl, options);
return res.getResponseCode() == 200;
}
function postMessage(msg) {
@8q
8q / docker-compose.yml
Created July 21, 2018 13:07
for nvcr.io/nvidia/digits
version: '2.3'
services:
digits:
image: nvcr.io/nvidia/digits:18.06
runtime: nvidia
ports:
- "5000:5000"
volumes:
- ./data:/data
- ./jobs:/workspace/jobs
@8q
8q / catfiles.c
Last active October 7, 2018 13:52
uniq < tmp.txt | wc -l
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define MAX_READ 128