Skip to content

Instantly share code, notes, and snippets.

View oreshinya's full-sized avatar
🏠
Working from home

oreshinya oreshinya

🏠
Working from home
View GitHub Profile
@oreshinya
oreshinya / unite_image_size.rb
Created July 24, 2016 12:29
ばらばらのサイズの画像をキャンバスだけ大きくして同じサイズの画像にする
require "fileutils"
require "rmagick"
FileUtils.mkdir_p("./processed")
paths = Dir.glob("./monsters/**/*.png")
paths.each_with_index do |path, i|
canvas = Magick::Image.new(200, 140) do
self.background_color = "none"
@oreshinya
oreshinya / power_assert_extension.rb
Last active August 29, 2015 14:06
power_assert extension for rspec sample.
require 'rspec/core'
require 'power_assert'
module PowerAssertExtension
def power_assert(&block)
::PowerAssert.start(block, assertion_method: __method__) do |pa|
return if pa.yield
message = "\n#{pa.message_proc.call}"
raise RSpec::Expectations::ExpectationNotMetError.new(message)
@oreshinya
oreshinya / verify.rb
Last active August 29, 2015 13:56
in app purchase、in app billingの検証用コードざっくりまとめ
require 'openssl'
require 'base64'
require 'net/http'
module Verify
module InAppPurchase
extend self
PRODUCTION_VERIFICATION_END_POINT = "https://buy.itunes.apple.com/verifyReceipt"
SANDBOX_VERIFICATION_END_POINT = "https://sandbox.itunes.apple.com/verifyReceipt"
@oreshinya
oreshinya / device_check_all_off.js
Created December 11, 2013 15:07
google developer consoleの対応端末一括OFF
function checkOff($) {
var checkbox = $('.popupContent span[aria-checked="false"]');
if (!!checkbox) {
checkbox.click();
checkOff($);
}
}
checkOff($);
@oreshinya
oreshinya / create_keyframes_for_android
Last active December 29, 2015 09:59
step-startなどのstep実行用のkeyframeからlinearでstep実行っぽく見せるkeyframeの生成
require 'sass'
BASE_SCSS_LOAD_PATH = './assets/www/app/stylesheets/main.css.scss'
KEYFRAMES_OUTPUT_PATH = "./assets/www/app/stylesheets/android_keyframes.css.scss"
class Sass::Tree::Visitors::ToArray < Sass::Tree::Visitors::Base
protected
def initialize
@array = []
end
@oreshinya
oreshinya / viewport_adjuster.js
Last active December 27, 2015 22:09
viewportが効かない場合の同様の表現をするためのscript。webに転がってるzoomでやる方式は、heightとかpositionとかいろいろ壊れるのでscaleでやってる。
window.ViewPortAdjuster = {
viewport_width: 320,
viewport_height: 480,
zoom_ratio: 1,
adjust: function() {
var that=this,portrait_width,landscape_width;
$(window).bind("resize", function(){
if(Math.abs(window.orientation) === 0){
if(/Android/.test(window.navigator.userAgent)){
if (!portrait_width) portrait_width = $(window).width();
/** with jqmobi **/
var createTabRenderer = function(parent_target) {
var tab_id = 0;
$(parent_target + ' .tab').each(function() {
$(this).data('tab-id', tab_id);
tab_id += 1;
});
tab_id = 0;
$(parent_target + ' .list_for_tab').each(function() {
$(this).data('tab-id', tab_id);
@oreshinya
oreshinya / create_js_for_preload_images.rb
Created November 2, 2012 15:31
create js for preload images
IMAGES_PATH = "images/"
OUTPUT_PATH = "javascripts/"
images = Dir.glob(IMAGES_PATH + "**/*.jpg").join("','")
js_str = <<-JS_STR
(function() {
var image_preloader = {
images: ['#{images}'],
done: function() {
@oreshinya
oreshinya / animation_closure.js
Created October 31, 2012 01:00
closure for animation
function Counter() {
var count = 0;
return function() {
count += 1;
return count;
}
}
function startAnimation(func, duration, animation_size, params) {
var animationCounter = Counter();