Skip to content

Instantly share code, notes, and snippets.

@mrk21
mrk21 / illustrator_cs6_item_selector
Last active December 18, 2015 13:09
Illustrator CS6 の JavaScript でセレクターにマッチする要素を返すjQuery的なものを適当に書いてみた。 誰かちゃんとしたの書いて?
#include "underscore/underscore.js"
function ItemQuery(selectorString) {
var selectorList = _(selectorString.split(/\s+/)).map(function(v){ return v.split('.'); });
var currentSelector = selectorList.pop();
var elements;
if (currentSelector[1]) {
var targets = currentSelector[0] ? [currentSelector[0]] : ItemQuery.TARGETS;
@mrk21
mrk21 / bitfield.cpp
Last active December 19, 2015 16:29
C++でパケットの解析とかで必要になったが、x86だとリトルエンディアンになるので標準のビットフィールドは使えない…のでテンプレートクラスとして作ってみた。 (g++ 4.8, c++1y) => ライブラリにした https://github.com/mrk21/bitfield
#include <iostream>
#include <array>
#include <algorithm>
#include <boost/format.hpp>
namespace bf {
constexpr uint32_t mask(std::size_t bit) {
return bit < 32 ? (1 << bit)-1 : -1;
}
@mrk21
mrk21 / googlemock_for_bandit.cpp
Last active December 20, 2015 16:59
googlemock(http://opencv.jp/googlemockdocs/) を Bandit(http://banditcpp.org/) で使えるようにした。 ※ライブラリにした → bandit_with_gmock(https://github.com/mrk21/bandit_with_gmock)
#include <bandit/bandit.h>
#include <gmock/gmock.h>
namespace bandit_with_gmock {
class listener_adapter: public testing::EmptyTestEventListener, public bandit::listener {
protected:
bandit::listener * base;
bool is_failed;
public:
@mrk21
mrk21 / file0.txt
Last active August 29, 2015 13:56
Ubuntuでシェルからマスターボリュームを設定する方法 ref: http://qiita.com/mrk_21/items/38f9be341e4cae9f83ad
$ pactl set-sink-volume 0 50% # マスターボリュームを50%に設定
@mrk21
mrk21 / fizzbuzz.rb
Last active August 29, 2015 13:58
Rubyでワンライナー、剰余なしFizzBuzz
p (1..100).zip([*[nil]*2,:Fizz]*33,[*[nil]*4,:Buzz]*20,[*[nil]*14,:FizzBuzz]*6).map{|v|v.compact[-1]}
@mrk21
mrk21 / display_line_number.vim
Last active August 29, 2015 14:02
Display a line number for Vim script.
scriptencoding utf-8
function! g:CmdExpect(line)
echo a:line
endfunction
command! Expect
\ call g:CmdExpect(expand("<sfile>") .":". expand("<slnum>"))
Expect
@mrk21
mrk21 / changelog.rb
Last active August 29, 2015 14:04
Git log と GitHub Issues から Changelog を作成する。
require 'open3'
require 'pp'
require 'json'
require 'date'
require 'rubygems'
require 'faraday'
require 'ostruct'
require 'erb'
require 'time'
@mrk21
mrk21 / xml_to_object.rb
Created August 21, 2014 05:39
XMLをObjectに変換
require 'faraday'
require 'rexml/document'
require 'ostruct'
require 'uri'
require 'pp'
def get(name)
conn = Faraday::Connection.new(url: 'https://services.addons.mozilla.org')
response = conn.get(URI.encode "/ja/firefox/api/1.5/search/#{name}")
doc = REXML::Document.new(response.body)
@mrk21
mrk21 / .vimrc
Created September 13, 2014 02:42
TweetVim settings (see: https://github.com/basyura/TweetVim).
NeoBundle 'basyura/TweetVim', {
\ 'depends': [
\ 'tyru/open-browser.vim',
\ 'basyura/twibill.vim',
\ 'mattn/webapi-vim',
\ 'h1mesuke/unite-outline',
\ 'basyura/bitly.vim',
\ 'Shougo/unite.vim',
\ 'mattn/favstar-vim'
\ ]
@mrk21
mrk21 / variadic_templates_test.cpp
Last active August 29, 2015 14:11
Variadic Templates: Test
#include <iostream>
#include <memory>
#include <functional>
#include <type_traits>
#include <boost/optional.hpp>
struct manager {
int id = 0;
};