Skip to content

Instantly share code, notes, and snippets.

View tkfm-yamaguchi's full-sized avatar

Takafumi Yamaguchi tkfm-yamaguchi

View GitHub Profile
@tkfm-yamaguchi
tkfm-yamaguchi / lang.map.diff
Last active February 5, 2024 19:51
source-highlight's language definition file for YAML
---/usr/share/source-highlight/lang.map.old
+++/usr/share/source-highlight/lang.map
@@ -169,3 +169,5 @@
groovy = groovy.lang
json = json.lang
feature = feature.lang
+yaml = yaml.lang
+yml = yaml.lang
.
. .
. 1 .
. 1 1 .
. . . . .
. 1 . . 1 .
. . . . . . .
# reverse polish notation
src = "PI 2 / sin 7 * 3 2 ** + abs PI *"
stack = []
src.split(" ").each do |tk|
case tk
when %r{^(\+|\*|\*\*|/)$}
lhs = stack.pop
rhs = stack.pop
stack.push eval("#{lhs} #{tk} #{rhs}")
@tkfm-yamaguchi
tkfm-yamaguchi / orelang.rb
Last active October 4, 2016 03:03
Orelang
#!/usr/bin/env ruby
# coding: utf-8
require "json"
class OreLang
def initialize(source)
@source = source
@vars = {}
end
let &makeprg = 'py.test --tb=short -rs -q'
if !exists('g:orgerrorformat')
let g:orgerrorformat = &errorformat
endif
" let &errorformat = ''
" let &errorformat .= 'SKIP\ %*[^ ]\ %f:%l:\ %m,'
" let &errorformat .= g:orgerrorformat
"
" let &makeprg = 'node_modules/.bin/eslint'
"
" if !exists('g:orgerrorformat')
" let g:orgerrorformat = &errorformat
" endif
"
" let &errorformat =
" \ '%E%f: line %l\, col %c\, Error - %m,' .
" \ '%W%f: line %l\, col %c\, Warning - %m'
#!/usr/bin/env ruby
##
# Copy stdin to clipboard with removing trailing LF char.
#
# Usage:
# $ cat some.file | pbcopytr
##
require "open3"
@tkfm-yamaguchi
tkfm-yamaguchi / module_level_variable_tricks.py
Last active May 11, 2016 05:46
Python's global (module level?) variable's tr~~ap~~icks
VAR = True
def fetch_global():
print VAR
def assign_locally():
VAR = False
print VAR
def assign_locally_after_printed():
@tkfm-yamaguchi
tkfm-yamaguchi / check_test_ordering.py
Last active May 11, 2016 02:29
Is functools.total_ordering necessary ?
import sys
from functools import total_ordering
print sys.version
class CharacterBase:
@classmethod
def create(cls, *names):
return [cls(n[0], n[1]) for n in names]
@tkfm-yamaguchi
tkfm-yamaguchi / homebrew-science-vtk5.patch
Last active February 23, 2016 04:27
A homebrew recipe for vtk5 without installing brewed python
--- a/vtk5.rb 2016-02-23 10:06:50.000000000 +0900
+++ b/vtk5.rb 2016-02-23 10:09:12.000000000 +0900
@@ -27,9 +27,8 @@
depends_on "cmake" => :build
depends_on :x11 => :optional
depends_on "qt" => :optional
- depends_on :python => :recommended
- # If --with-qt and --with-python, then we automatically use PyQt, too!
- if build.with?("qt") && build.with?("python")
+