Skip to content

Instantly share code, notes, and snippets.

Avatar

Keita Urashima ursm

  • Sapporo, Japan
  • Twitter @ursm
View GitHub Profile
View Gemfile
source 'https://rubygems.org'
gem 'pg'
gem 'sequel'
@ursm
ursm / parse_st.rb
Last active Mar 14, 2016 — forked from tfuji/parse_st.rb
INSDC structured comment parser
View parse_st.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'bio'
def parse_st_comment(comment)
comment.scan(/##(.+)-START##\n(.*)\n##\1-END##/m).each_with_object({}) {|(tagset, block), memo|
i = 0
memo[tagset] = block.lines.chunk {|line|
View destruct_jsonapi.rb
class ActionController::Parameters
def destruct_jsonapi
data = fetch(:data)
relationships = data.fetch(:relationships) { self.class.new }
attributes = self.class[*data.fetch(:attributes) { Hash.new }.flat_map {|key, value|
[key.underscore, value]
}]
relationships.each_with_object(attributes) {|(key, value), attrs|
View rfb.rb
require 'json'
require 'nokogiri'
require 'open-uri'
def find_complete_row(doc, i)
prev = doc.at_css("#rgn_content4 tbody tr:nth-child(#{i.pred})").css('td').map(&:text)
prev.size == 10 ? prev : find_complete_row(doc, i.pred)
end
View system_bang.rb
require 'open3'
def system!(*args)
out, status = Open3.capture2e(*args)
raise RuntimeError, out unless status.success?
end
View activeadmin_aato_select2.rb
form do |f|
f.semantic_errors
f.inputs do
f.input :name, input_html: {disabled: true}
f.input :tag_list, as: :select2_tags, collection: ActsAsTaggableOn::Tag.pluck(:name), input_html: {value: f.object.tag_list.to_s}
end
View systemd.md

kernel

# cd /usr/src/linux
# make nconfig

Gentoo Linux  --->
  Support for init systems, system and service managers  --->
    [ ] OpenRC, runit and other script based systems and managers
 [*] systemd
View async-session.coffee
`import Ember from 'ember'`
`import Session from 'simple-auth/session'`
makePromise = (promiseOrValue) ->
if promiseOrValue.then
promiseOrValue
else
Ember.RSVP.resolve(promiseOrValue)
AsyncSession = Session.extend
@ursm
ursm / config.json
Created Jun 23, 2014
Custom bootstrap build configuration for Idoyuki
View config.json
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 60%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#428bca",
"@brand-success": "#5cb85c",
"@brand-info": "#5bc0de",
View ansible-eyc-inventory
#!/usr/bin/env ruby
require 'json'
Instance = Struct.new(:hostname, :amazon_id, :role)
def environment
basename = File.basename(__FILE__)
unless basename.include?('@')