Skip to content

Instantly share code, notes, and snippets.

View reasonset's full-sized avatar

MASAKI Haruka reasonset

View GitHub Profile
@reasonset
reasonset / cpu-governor-controller.zsh
Created August 13, 2023 22:30
Quick change CPU governor from systray.
#!/bin/zsh
SUDO_COMMAND=pkexec
#SUDO_COMMAND=gksu
#SUDO_COMMAND=kdesu
avilable_governors=($(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors))
#avilable_governors=(powersave performance)
#avilable_governors=(powersave schedutil performance)
#!/bin/bash
function build_repoliststr {
ruby -ryaml -e 'print YAML.load(ARGF).map {|i| i.join(":::") }.join("%%%")' $HOME/.config/reasonset/workrepos.yaml
}
export repoliststr="$(build_repoliststr)"
function splitrepos {
echo $repoliststr | sed 's:%%%:\n:g'
@reasonset
reasonset / mkpwd.rb
Last active February 22, 2020 21:09
#!/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
#!/usr/bin/python
import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import *
app = QApplication(sys.argv)
web = QWebEngineView()
@reasonset
reasonset / join-contexts.rb
Created August 26, 2019 09:37
Stella LogicのContextsを結合する
#!/usr/bin/ruby
require 'yaml'
logic = {}
File.open(ARGV.shift) do |f|
logic = YAML.load f
end
@reasonset
reasonset / temporary-disable-device.zsh
Created April 22, 2018 11:32
Turn on/off device with xinput and zenity.
#!/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
#!/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
#!/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
@reasonset
reasonset / zsh_parellel_queue_sock.zsh
Created June 6, 2016 05:13
Multi thread programming in Zsh with Socket Queue version.
#!/usr/bin/zsh
zmodload zsh/net/socket
producer() {
typeset -i threads="$1"
typeset -i deadcount=0
shift
@reasonset
reasonset / parallel_queue.zsh
Created June 5, 2016 13:48
Sample of parallel processing in Zsh script.
#!/usr/bin/zsh
worker() {
worker_num=$1
while true
do
exec 9>| lock
flock -x 9
num=$(read -e)
exec 9>&-