Skip to content

Instantly share code, notes, and snippets.

"no ruby, no life!"
# => {"no"=>2,"ruby"=>1,"life"=>1}
str = "no ruby, no life!"
# A.1
str.scan(/\w+/).each_with_object(Hash.new(0)){|e,h| h[e]+=1}
# => {"no"=>2, "ruby"=>1, "life"=>1}
# A.2
@springaki
springaki / .powenv
Last active August 29, 2015 14:11
RubyMineでPowを使いながらDebugする方法 ref: http://qiita.com/spring_aki/items/8319af8ec12b444f167b
export RUBY_DEBUG_PORT=1234
export POW_WORKERS=1
@springaki
springaki / file0.txt
Created December 16, 2014 23:34
RubyMineで簡単に行ごとのコミットログを見る方法 (Annotate,Blame) ref: http://qiita.com/spring_aki/items/04c229a771e44396c4fd
$ git annotate <ファイル名>
@springaki
springaki / gist:3080415
Created July 10, 2012 01:24
JSON serialize deserialize Test (JavaScriptSerializer)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
namespace ConsoleApplication2
{
@springaki
springaki / gist:3080408
Created July 10, 2012 01:21
JSON deserialize test (DataContractJsonSerializer)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace ConsoleApplication
{
[DataContract]
@springaki
springaki / gist:652cdb16fdf3c39d3c27
Created October 24, 2015 06:07
Node.js & npm のアンインストール
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom \
| while read i; do
sudo rm /usr/local/${i}
done
sudo rm -rf /usr/local/lib/node \
/usr/local/lib/node_modules \
/var/db/receipts/org.nodejs.*
sudo rm -rf ~/.npm
@springaki
springaki / tablish_oneliner.rb
Last active December 11, 2015 06:58
Cucumber の tablish の代わり
# tablish
# tableish('table tr', 'th,td')
find('table').all('tr').map { |row| row.all('th, td').map { |cell| cell.text.strip } }
# ex.
Then /^the table should be:$/ do |table|
table.diff!(find("table").all('tr').map { |row| row.all('th, td').map { |cell| cell.text.strip } })
end
# -*- encoding: utf-8 -*-
# TED Subtitles sample
require 'json'
require 'open-uri'
base_url = 'http://www.ted.com/talks/subtitles'
id = 1405
url_en = "#{base_url}/id/#{id.to_s}/lang"
@springaki
springaki / 1405.txt
Last active December 12, 2015 02:48
Marco Tempest: What I'd like to show you today
今日お見せするのは
is something in the way of an experiment.
まだ実験中のものです
Today's its debut.
今日が初披露になります
It's a demonstration of augmented reality.
@springaki
springaki / usage: amazon plugin for octopress.erb
Created February 5, 2013 07:08
usage: amazon plugin for octopress.md
{{ "4048687158" | amazon_medium_image }}
{{ "4798122971" | amazon_medium_image }}