Skip to content

Instantly share code, notes, and snippets.

Avatar

teramako teramako

View GitHub Profile
@teramako
teramako / perm2oct.sed
Last active Sep 7, 2022
rwxなパーミッションを8進数表記に変換するsedスクリプト。 ls -l | sed -f perm2oct.sed
View perm2oct.sed
#!/usr/bin/sed -f
# SUID, GUID, Sticky-bit
s/^\(.\)\(..[sS]..[sS]..[tT]\)/\17\2/; t perm
s/^\(.\)\(..[sS]..[sS]..[^tT]\)/\16\2/; t perm
s/^\(.\)\(..[sS].\{5\}[tT]\)/\15\2/; t perm
s/^\(.\)\(..[sS][^sStT]\{6\}\)/\14\2/; t perm
s/^\(.\)\([^sS]\{5\}[sS]..[tT]\)/\13\2/; t perm
s/^\(.\)\([^sS]\{5\}[sS][^tT]\{3\}\)/\12\2/; t perm
s/^\(.\)\([^sS]\{8\}[tT]\)/\11\2/; t perm
@teramako
teramako / ex-generator.js
Last active Jul 5, 2022
Generatorの拡張
View ex-generator.js
const iter = (function(){
// 元のGenerator.prototype
const GeneratorProto = ({*g(){}}).g().constructor.prototype;
// 拡張してmap,filterを付与したprototype
const ExtendedGeneratorProto = Object.setPrototypeOf({
map (func, thisArg = null) {
const iterable = this;
return Object.setPrototypeOf(function*() {
var i = 0;
for (const item of iterable) {
@teramako
teramako / cmds.yml
Created Dec 19, 2020
ansible-playbook simple_cmds.yml -e @cmds.yml
View cmds.yml
## this is sample
COMMANDS:
- |
id
uname -n
date
- cat /path/to/file
ADMIN: true
@teramako
teramako / config.json
Last active Sep 13, 2020
pecoで ls -l の結果からファイル名部分のみを検索できるようにCustomFilterを設定
View config.json
{
"CustomFilter": {
"ls-l": {
"Cmd": "perl",
"Args": ["/Users/teramako/bin/ls-l-filter.pl", "$QUERY"],
"BufferThreshold": 100
}
}
}
@teramako
teramako / extendGeneratorPrototype.js
Last active Sep 18, 2016
Generatorのプロトタイプ拡張。ま、やっつけです。
View extendGeneratorPrototype.js
/* Usage
function * gene() {
console.log("iter");
yield 1;
console.log("iter");
yield 2;
console.log("iter");
yield 3;
}
var result = gene
@teramako
teramako / join.vba
Created Jun 27, 2016
Excel VBAの標準モジュールに追加してる関数
View join.vba
' ="SELECT ..... FROM ... WHERE column_A in ("&join(A1:A10,",","'")&")" などと式に使うことを想定
' SQLインジェクション可能だが知らん。
Function join(r As Range, Optional delimiter As String = ",", Optional wrap As String = "'") As String
Dim i As Integer
Dim result = As String
result = wrap & r.Cells(1, 1).Value & wrap
For i = 2 To r.rows.Count
@teramako
teramako / gist:a076cedcaebcc70252bf
Last active Aug 29, 2015
今日ダウンロードしたzipファイル。
View gist:a076cedcaebcc70252bf
$ file HOGEHOGE.zip
HOGEHOGE.zip: Bourne-Again shell script text executable
$ strings HOGEHOGE.zip
#!/bin/bash
sed -e '1,/BIGIN HOGEHOGE/d' $0 |sed -e '1,/BIGIN HOGEHOGE/d' > ./test.tar.gz
tar zxvf test.tar.gz >/dev/null;
chown root aFile bFile cFile
chmod 4755 aFile bFile cFile
exit 0
#BIGIN HOGEHOGE
View es6_quiz_answer.md

ECMAScript6th Quiz Answer

Answer of ES6 Quiz

A.1

  • 2 "func"

see: [9.2.12 SetFunctionName][9.2.12], [12.14.4 Runtime Semantics of AssignmentExpression][12.14.4]

View ES6_quiz.md

ECMAScript6th Quiz

Q.1

let func = function() {};
func.name
  1. ""
  2. "func"
@teramako
teramako / list_found.js
Created Jan 19, 2015
Vimperator プラグイン。<Leader>/ でページ内検索した時にリストを作成して foundlist コマンドで該当箇所にジャンプする。
View list_found.js
var wm = new WeakMap;
mappings.addUserMap([modes.NORMAL], ["<Leader>/"], "Search forward for a pattern", function () { openPrompt(modes.SEARCH_FORWARD); });
commands.addUserCommand(['foundlist', 'fl'], 'show found list',
function (args) {
var index = parseInt(args.literalArg, 10);
if (Number.isNaN(index))
return;