Skip to content

Instantly share code, notes, and snippets.

@higuma
higuma / image2jpg.rb
Created September 12, 2016 11:08
Convert multi-format images to JPG (using ImageMagick on ruby)
#!/usr/bin/env ruby
# Convert non-destructive format(PNG/BMP/TIFF) images to JPEG
# (for Windows, runs on git bash only)
#
# Requires ImageMagick: set correct ImageMagick path as below
# (e.g. convert.exe collides with Windows system command)
IM_PATH = 'C:/usr/ImageMagick'
IM_CONVERT = "#{IM_PATH}/convert"
doctype
html
head
meta(charset="UTF-8")
script(src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js")
body
div(ng-app,ng-init="qty=1;cost=2")
b Invoice:
div Quantity:
input(type="number", ng-model="qty")
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
@higuma
higuma / file0.txt
Created April 27, 2014 10:32
Rack応用 - HTTP圧縮エンコーディング最適化 ref: http://qiita.com/higuma/items/9b841aca5f3d58a2b5aa
Accept-Encoding: gzip, deflate
@higuma
higuma / config.ru
Created April 13, 2014 12:01
Rack解説 - Rackの構造とRack DSL ref: http://qiita.com/higuma/items/838f4f58bc4a0645950a
use Rack::ETag
use Rack::Deflater
use Rack::Static, urls: [''], root: 'public', index: 'index.html'
run lambda {|env|} # run proc {|env|} も可
This is *emphasized*
@higuma
higuma / alphametics.rb
Created April 8, 2014 11:08
覆面算を解く(Ruby/Pythonレクリエーション) ref: http://qiita.com/higuma/items/c44246ebd8e6e4a14a64
require 'set'
require 'mathn'
module Alphametics
def solve(puzzle)
puzzle = puzzle.upcase
words = puzzle.scan /[A-Z]+/
chars = Set.new words.join.each_char
abort 'Too many letters' if chars.size > 10
first_chars = Set.new words.select {|w| w.size > 1 }.map {|w| w[0] }
@higuma
higuma / file0.coffee
Created April 5, 2014 06:18
CoffeeScriptワンポイント - 値を返さない関数にはreturnを付ける ref: http://qiita.com/higuma/items/ff329775f3a91a6c6fb3
a = for x in [0..5]
x * x
console.log a # => [ 0, 1, 4, 9, 16, 25 ]
b = while a.length > 0
a.pop()
console.log b # => [ 25, 16, 9, 4, 1, 0 ]
@higuma
higuma / Gemfile
Created April 4, 2014 13:57
HerokuにRackでdeployする(初級編:静的HTMLページ) ref: http://qiita.com/higuma/items/9baac9e97eeb862ef64e
source 'https://rubygems.org'
ruby 2.0.0
gem 'rack'
@higuma
higuma / config.ru
Created April 1, 2014 10:40
開発用ローカルサーバを立ち上げる方法 ref: http://qiita.com/higuma/items/b23ca9d96dac49999ab9
run Rack::Directory.new '.'