Skip to content

Instantly share code, notes, and snippets.

@bucho666
bucho666 / iteratable_object.nim
Created October 4, 2019 07:26
itemsイテレータで直接イテレートできる
type Range = ref object of RootObj
min: int
max: int
iterator items(r: Range): int =
for n in r.min..r.max:
yield n
proc iterator_obj() =
for n in Range(min:3, max:12):
@bucho666
bucho666 / nim_command_pattern.nim
Created October 4, 2019 06:45
Nimで関数の配列を実行する
proc command_pattern() =
var commands: seq[proc()]
commands.insert(proc() = echo "hello")
commands.insert(proc() = echo "world")
for c in commands: c()
@bucho666
bucho666 / class.nim
Last active March 10, 2024 15:44
nim class macro
import macros
proc typeName(head: NimNode): NimNode =
if head.len == 0: head else: head[1]
proc baseName(head: NimNode): NimNode =
if head.len == 0: newIdentNode("RootObj") else: head[2]
proc isObjectDef(head: NimNode): bool =
head.len == 0 or head[2].kind == nnkIdent
[[plugins]]
repo = 'Shougo/dein.vim'
[[plugins]]
repo = 'simeji/winresizer'
hook_add = '''
let g:winresizer_start_key = '<C-R>'
'''
[[plugins]]
@bucho666
bucho666 / main.py
Last active December 9, 2016 06:55
文字列一括置換ツール(PySide)
# -*- encoding: shift-jis -*-
import sys
import os
from PySide import QtCore
from PySide import QtGui
from replace import MultiReplace
class MainWindow(QtGui.QDialog):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
@bucho666
bucho666 / pygame_base.py
Created November 1, 2016 12:29
pygameの基本
import sys
import pygame
pygame.init()
screen = pygame.display.set_mode((680, 480), 0, 8)
pygame.display.update()
clock = pygame.time.Clock()
while(True):
for event in pygame.event.get():
if event.type is pygame.QUIT: sys.exit(0)
@bucho666
bucho666 / dice.py
Last active September 21, 2016 06:36
Dice
# -*- coding: utf-8 -*-
import re
import random
class Dice(object):
def __init__(self, description):
self._description = description
match = re.search('(\d+)d(\d+)', description)
if not match: raise Exception('Dice format error: %s' % description)
self._number = int(match.group(1))
@bucho666
bucho666 / client.js
Last active July 8, 2016 11:30
socket.io を使用したchat サンプル
'use strict'
let socket = io.connect(),
input_message = $('#input_message');
socket.on('connect', function() {
add_message('connect success');
});
socket.on('chat_message', function(message) {
add_message(message);
@bucho666
bucho666 / git-config.md
Last active May 21, 2017 07:40
git configについて

個人設定

git config --global user.name "あなたの名前"

git config --global user.email メールアドレス

gitの出力に色をつけてカラフルにする

git config --global color.ui auto

ファイルの改行コードを強制的にLFにしてOS依存をなくす

git config --global core.autocrlf input