Skip to content

Instantly share code, notes, and snippets.

MASAKI Haruka reasonset

View GitHub Profile
@reasonset
reasonset / parallel_queue.zsh
Created Jun 5, 2016
Sample of parallel processing in Zsh script.
View parallel_queue.zsh
#!/usr/bin/zsh
worker() {
worker_num=$1
while true
do
exec 9>| lock
flock -x 9
num=$(read -e)
exec 9>&-
@reasonset
reasonset / zsh_parellel_queue_sock.zsh
Created Jun 6, 2016
Multi thread programming in Zsh with Socket Queue version.
View zsh_parellel_queue_sock.zsh
#!/usr/bin/zsh
zmodload zsh/net/socket
producer() {
typeset -i threads="$1"
typeset -i deadcount=0
shift
View md2html_styled.zsh
#!/usr/bin/zsh
# Generate HTML files from Markdown files.
# It convert foo/bar.md to foo/bar.html
# This needs Pandoc.
STYLE_FILE="$HOME/local/repos/markdown-css/build/github/github.css"
BODY_CLASS="github"
PANDOC_OPTS=(-s --self-contained -t html5 -c $STYLE_FILE --toc)
for i in **/*.md
View forcedtodo.zsh
#!/bin/zsh
#### Default Settings ####
hts_voicefile=/usr/share/open-jtalk/voices/mei_normal.htsvoice
mecab_dictdir=/usr/share/open-jtalk/dic/
jtalk_tuning=(-a 0.6 -r 0.8 -fm -2.0 -jf 1.5)
jtalk_tmpfile=$HOME/tmp/forcedtodo.wav
notify_interval=180
notify_time=15000
task_editor=mousepad
@reasonset
reasonset / temporary-disable-device.zsh
Created Apr 22, 2018
Turn on/off device with xinput and zenity.
View temporary-disable-device.zsh
#!/usr/bin/zsh
setopt EXTENDED_GLOB
device="$(zenity --title="Select Device" --width=600 --height=500 --list --column="DEVICES" "${(f)$(xinput --list | ruby -e 'print ARGF.each.map {|i| i =~ /[^A-Za-z]*([A-za-z1-9 ]+[a-zA-Z0-9])\s*id=(\d+)/; "#$2 #$1\n" }.join.chomp')}"| perl -ne '/\d+/; print $&;')"
if (( $? == 0 )) && [[ -n $device ]]
then
action="$(zenity --list --column="ACTION" "turn on" "turn off")"
if (( $? == 0 )) && [[ -n $action ]]
then
@reasonset
reasonset / join-contexts.rb
Created Aug 26, 2019
Stella LogicのContextsを結合する
View join-contexts.rb
#!/usr/bin/ruby
require 'yaml'
logic = {}
File.open(ARGV.shift) do |f|
logic = YAML.load f
end
View weblio.py
#!/usr/bin/python
import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import *
app = QApplication(sys.argv)
web = QWebEngineView()
View mkpwd.rb
#!/usr/bin/ruby
# -*- mode: ruby; coding: utf-8 -*-
pwlength = ARGV.shift&.to_i || 64
pwlength = 64 if pwlength < 1
converter_symbols = ARGV.shift&.each_char
converter = converter_symbols ? ("a" .. "z").to_a + ("A" .. "Z").to_a + ("0" .. "9").to_a + converter_symbols : ('!' .. '~').to_a
You can’t perform that action at this time.