Skip to content

Instantly share code, notes, and snippets.

View tmaeda's full-sized avatar

tmaeda

  • Enishi Tech Inc.
  • Sapporo, Japan
View GitHub Profile
@tmaeda
tmaeda / .pryrc
Last active December 14, 2016 06:38
今、どこのDBにつながっているかを pry のプロンプトに表示する
Pry.config.prompt = proc do |obj, nest_level, _pry_|
db = ''
if defined? Rails
db << '%s:%s/%s' % Rails.configuration.database_configuration[Rails.env].values_at('host', 'port', 'database')
end
"#{Pry.config.prompt_name}(#{Pry.view_clip(obj)}) #{db}> "
end
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@tmaeda
tmaeda / var_check.yml
Created May 29, 2015 10:21
ansible-playbook -i localhost var_check.yml
---
- hosts: all
vars:
param1: 111
tasks:
- fail: msg="{{ item }} is not defined"
when: "{{ item }} is not defined"
with_items:
- param1
- param2
@tmaeda
tmaeda / gitbucket.service
Created May 3, 2015 04:19
/etc/systemd/system/gitbucket.service
[Unit]
Description=Git hosting service
[Service]
User=gitbucket
ExecStart=/usr/bin/java -jar /home/gitbucket/gitbucket.war --port=xxxx --host=127.0.0.1 --gitbucket.home=/home/gitbucket/repo
[Install]
WantedBy=multi-user.target
@tmaeda
tmaeda / gist:0b1771d2f3b37cb1ee1b
Last active August 29, 2015 14:17
ghq, peco関係
bind -x '"\C-_":cd $(ghq list -p | peco)' # プロジェクトディレクトリへcd
bind -x '"\C-]":open $(ghq list -p | peco)' # プロジェクトディレクトリをFinder上でopen
# Macのファイルオープン・セーブダイアログでも使えると良いんだけどなー。Cmd + Shift + g で代用。
bind -x '"\C-^":ghq list -p | peco | xargs echo -n | pbcopy'
<link rel="import" href="../ace-element/ace-element.html">
<link rel="import" href="../chart-js/chart-js.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<polymer-element name="my-element">
<template>
<style>
#```ruby
require 'axlsx'
p = Axlsx::Package.new
wb = p.workbook
header = {:different_odd_ => false, :odd_header => "&L&F : &A&C&Pof&N&R&D &T"}
wb.add_worksheet(:name => "repeated header", :header_footer => header) do |sheet|
sheet.add_row %w(These Column Header Will Render On Every Printed Sheet)
200.times { sheet.add_row %w(1 2 3 4 5 6 7 8) }
;;; Commentary
;; Select and activate google chrome tabs by anything interface
;;; Requirements
;; https://github.com/mechairoi/crxel
;;; Usage
;; (require 'anything-chrome-tabs)
;; (crxel/start 9649)
;; (define-key global-map "C-t" 'anything-chrome-tabs)
(provide 'anything-chrome-tabs)
@tmaeda
tmaeda / gist:7281019
Created November 2, 2013 16:55
Smalltalk の #ifTrue:ifFalse:をRubyで。
class TrueClass
def if_true_if_false(true_block, flase_block)
true_block.call
end
end
class FalseClass
def if_true_if_false(true_block, false_block)
false_block.call
end
@tmaeda
tmaeda / dot.pryrc
Created September 12, 2013 20:38
.pryrc にこういうの書いておくと、たまに捗る。httpclientなりmechanizeなりで取得してきたレスポンスHTMLに .w3m ってつければレンダリングして内容を確かめられる。
class String
def w3m
IO.popen("w3m -F -T text/html -dump", "w") do |w3m|
w3m.puts self
end
end
end