Skip to content

Instantly share code, notes, and snippets.

View ysakasin's full-sized avatar

SAKATA Sinji ysakasin

View GitHub Profile
<LinearLayout
android:id="@+id/linearLayout0"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="0dp"
function mdtopdf(){
pandoc $1.md -o $2.pdf -V documentclass=ltjsarticle --latex-engine=lualatex
}
@ysakasin
ysakasin / test.rb
Created April 5, 2016 17:08
どどんとふ一部高速化の根拠となるベンチマーク
require 'benchmark'
num_iteration = 100000
# $ ruby -v
# ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin14]
# $ ruby test.rb
# user system total real
# eval 0.600000 0.000000 0.600000 ( 0.612116)
# send 0.040000 0.000000 0.040000 ( 0.036611)
@ysakasin
ysakasin / slackemoji.sh
Created May 5, 2016 14:22
SVGからSlack emoji用のPNGを生成
filename=`basename $1 .svg`↲
pngfile="${filename}.png"↲
convert +antialias -background transparent $1 -resize 128x128\> -size 128x128 xc:transparent +swap -gravity center -composite $pngfile↲
optipng -o7 $pngfile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/local/bin/ruby -Ku
#--*-coding:utf-8-*--
# redis, redis-objectsのgemが必要
# 実際に動かすなら、MySQLへのアダプタを参考にセットアップしてみてください
# .json や .txt をひたすら保存しているだけなので、RAMを使う場合との性能差は不明です
$LOAD_PATH << File.dirname(__FILE__) # require_relative対策
require 'DodontoFServer.rb'
@ysakasin
ysakasin / Cthulhu.rb
Last active November 15, 2016 15:59
どどんとふ用のオレオレ「クトゥルフ神話TRPG」用ダイスボット
# -*- coding: utf-8 -*-
class Cthulhu < DiceBot
def initialize
#$isDebug = true
super
@critical_percentage = 5
@fumble_percentage = 5
end
# The MIT License (MIT)
# Copyright (c) 2016 SAKATA Sinji
# Require install nokogiri.
# `gem install nokogiri`
require 'nokogiri'
TARGETS = ["nvdcve-2.0-2014.xml", "nvdcve-2.0-2015.xml", "nvdcve-2.0-2016.xml"]
amount = {}
@ysakasin
ysakasin / code.py
Last active February 11, 2017 08:47
某アニメで主人公が作成していたコード
def __delitem__(self, key):
self.db.delete(self.table, where="session_id=$key", vars= # 見切れている
def cleanup(self, timeout):
timeout = datetime.# 入力中により以後不明
@ysakasin
ysakasin / mkpasswd
Created June 15, 2017 07:23
パスワード用にランダムな文字列を生成する
#!/bin/bash
print_help () {
echo -e "Usage: mkpasswd [options] " 1>&2
echo -e " -l\tset password length" 1>&2
echo -e " -n\tset number of passwords" 1>&2
echo -e " -h\tshow this message" 1>&2
}
while getopts n:l:h OPT