Skip to content

Instantly share code, notes, and snippets.

require 'date-utils'
module.exports = (robot) ->
robot.respond /([^\s]*)\s?の\s?([^\s]*)\s?の運勢/i, (msg) ->
dateArgs = msg.match[1]
signArgs = msg.match[2]
date = switch dateArgs
when '昨日'
Date.yesterday()
require 'active_record'
DATABASE_NUM = ENV['CI_DATABASE_NUM'] || 2
namespace :ci do
task :test_environment => :environment do
ENV['RAILS_ENV'] = Rails.env = ActiveRecord::Tasks::DatabaseTasks.env = 'test'
end
namespace :db do
minitest ~> 4.7.3
$ ci-test $(find -L $PWD/test -name \*_test.rb)
Starting test-queue master (/tmp/test_queue_16649_70329599330480.sock)
==> Summary (8 workers in 2.5028s)
[ 8] 0 tests, 0 assertions, 0 failures, 0 errors, 0 skips 0 suites in 0.0055s (pid 16702 exit 0)
[ 1] 6 tests, 16 assertions, 0 failures, 0 errors, 0 skips 2 suites in 1.0579s (pid 16695 exit 0)
@yasuoza
yasuoza / add_file.rb
Last active August 29, 2015 14:01
add file to xcode project
# FYI:
# http://www.j7lg.com/archives/1732
require 'xcodeproj'
def bail_if_nil(obj, msg)
return unless obj.nil?
puts msg
exit
end
@yasuoza
yasuoza / csv2vcf_docomo.rb
Last active August 29, 2015 14:06
Convert exported csv to vcf card
require 'csv'
input = ARGV[0] || 'exported_contacts.CSV'
output = "#{Time.now.strftime('%Y%m%d-%H%M%S')}.vcf"
groups = {
'グループなし' => 0,
}
File.open(output, 'w:cp932') do |file|
@yasuoza
yasuoza / gist:1858167
Created February 18, 2012 08:12
Bing translation API based on JSONP
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Microsoft Translate</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(function () {
$('#trans').on('click', function (e) {
e.preventDefault();
var loading = $('p#loading').toggle(),
@yasuoza
yasuoza / index.html
Created February 20, 2012 07:43
jQuery Ticker code
<ul id="ticker">
<li class="bd">
<p id="slide">
<span>
2012/01/24&nbsp;
<a href="http://www.google.com">text00</a>
</span>
<span>
2011/11/08&nbsp;
@yasuoza
yasuoza / gist:1868414
Created February 20, 2012 08:25
User Agent distinction
function is_mobile () {
var useragents = [
'iPhone', // Apple iPhone
'iPod', // Apple iPod touch
'Android', // 1.5+ Android
'dream', // Pre 1.5 Android
'CUPCAKE', // 1.5+ Android
'blackberry9500', // Storm
'blackberry9530', // Storm
'blackberry9520', // Storm v2
@yasuoza
yasuoza / converter.rb
Created June 10, 2012 05:10
Retina image converter
require 'rubygems'
require 'RMagick'
convertedCnt = 0
ARGV.each do |filename|
img_type = File.extname(filename).downcase
if (img_type==".png")||(img_type==".jpg")||(img_type==".tif")
ext = File.extname(filename)
base = File.basename(filename,ext)
@yasuoza
yasuoza / retina_image_resizer.rb
Created June 10, 2012 06:04
Resize retina images.
#!env ruby
require 'rubygems'
require 'RMagick'
images_dir = ARGV[0]
if images_dir == nil
puts "Error! Input images directory"
exit
end