Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# give last chance to ^C
# place this file at /usr/local/bin
echo
echo " sudo: $@"
sleep 1.7
/usr/bin/sudo $@
@hayato-hashimoto
hayato-hashimoto / snippets.cson
Created May 27, 2020 12:11
Python snippets for Atom
'.source.python':
'import boilerplate':
'prefix': 'import'
'body': '''
import collections
from collections import Counter, OrderedDict, defaultdict, deque, ChainMap, namedtuple
import itertools
from itertools import permutations, combinations, combinations_with_replacement
import re
@hayato-hashimoto
hayato-hashimoto / bz2-progressbar.py
Created February 20, 2018 22:09
Using progressbar for reading (and processing) bz2 file
#!/usr/bin/python3
import os, progressbar, bz2
def bz2_wc(path):
count = 0
with open(path, "rb") as bzf:
filesize = os.fstat(bzf.fileno()).st_size
p = progressbar.ProgressBar(maxval=filesize)
with bz2.open(bzf, "rt") as tf:
for line in tf:
p.update(bzf.tell())
(use srfi-1)
(define (scan-pattern text)
(let loop ((pattern '(())) (lis (string->list text)))
(if (null? lis) (map (compose list->string reverse) pattern)
(loop (append
(map (lambda (x) (cons (car lis) x)) pattern)
(map (lambda (x)
(if (and (pair? x) (eq? (car x) #\*)) x (cons #\* x)))
pattern)) (cdr lis)))))
#automatic typescripting
# [ -z "${SCRIPT}" ] && SCRIPT=YES script -a -f -t ~/typescript 2>> ~/typescript.t && exit
SCRIPT=
PATH=${PATH}:/opt/java/jre/bin/
# coreutils 8.25
export QUOTING_STYLE=literal
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
(define-module sound.clip
(export-all))
(select-module sound.clip)
(define-class <clip> ()
((proc :init-keyword :proc)
(duration :init-keyword :duration)
(sample-rate :init-keyword :sample-rate :init-value 44100)
(bits :init-keyword :bits :init-value 8)))
(define (make-clip duration proc . args)
@hayato-hashimoto
hayato-hashimoto / Contest 2012.dyalog
Created October 17, 2012 14:09
Dyalog APL Contest 2012
⍝ `blah ...` are literate (= English) quotes and 'blah ...' are quotes for character literals (= APL quotes).
:namespace Contest2012
AboutMe ←, ⊂ 'I am a faculty student in Japan, majoring science.'
AboutMe ,← ⊂ 'I beleve that computers will transcend, or extend human intelligence'
AboutMe ,← ⊂ 'if programmed insightfully and analogically. It makes my passion toward computing.'
AboutMe ,← ⊂ 'Lisp, especially Scheme has been my language of choice for years.'
AboutMe ,← ⊂ 'I know some very basic element of APL has been imported to Scheme,'
AboutMe ,← ⊂ 'the iota function (srfi-1) and multidimentional array (srfi-25 via Common Lisp)'
AboutMe ,← ⊂ 'I have small repository to share fairly exprimental things on github.com/insanity (being rather unsocial, though)'