Skip to content

Instantly share code, notes, and snippets.

View aq2bq's full-sized avatar

aq2bq aq2bq

  • YUKASHIKADO Inc.
  • Japan
  • X @aq2bq
View GitHub Profile
@aq2bq
aq2bq / 1.html
Last active January 27, 2022 05:07
bulk-checking.js
<html>
<head>
<title>Bulk Checking</title>
<script src="main.js"></script>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<div class="check-all-alert hidden"></div>
<div>
<h3>選択された件数:<span class="checked-count">0</span></h3>
@aq2bq
aq2bq / ox.html
Created January 13, 2022 11:23
ox
<html>
<head>
<title>ox</title>
<style type="text/css">
#app {
width: 90px;
}
.cell {
border: 1px solid #000;
float: left;
@aq2bq
aq2bq / natural_or_zero.rb
Last active January 23, 2020 06:01
[Benchmark] f(int) returns natural number or zero - ruby
require 'benchmark'
q = 10000000
Benchmark.bm 10 do |r|
r.report "IF" do
f = ->(i){ i < 0 ? 0 : i }
q.times {|i| f.call(i) }
end
r.report "ABS" do
f = ->(i){ (i + i.abs) / 2 }
@aq2bq
aq2bq / build.rb
Last active June 9, 2016 10:28
Summary Generator for mdBook
require 'pathname'
PATHS = Pathname.glob('./src/**/[^SUMMARY]*.md')
paths = PATHS.each_with_object({}) do |path, dirs|
unless dirs[path.parent]
dirs[path.parent] = []
end
dirs[path.parent] << path
end
@aq2bq
aq2bq / konami_command.js
Last active April 14, 2016 05:00
KONAMI Command
var konamiCommand = (function(i, commands){
function keyDown(e) {
e.keyCode == commands[i] ? i++ : i = 0;
if (i == commands.length) alert('KONAMI!');
}
window.addEventListener('keydown', keyDown);
})(0, [38, 38, 40, 40, 37, 39, 37, 39, 66, 65]);
@aq2bq
aq2bq / fizzbuzz.js
Created July 10, 2015 02:36
Fizz Buzz on Javascript
// Logic 1: The shortest
(function(i,c){while(i<=100){if(i%15==0){c("FizzBuzz")}else if(i%3==0){c("Fizz")}else if(i%5==0){c("Buzz")}else{c(i)}i++}})(1,console.log.bind(console));
// Logic 2: Use Array#forEach
(function(i,a){while(i<=100){a.push(i);i++}return a;})(1,[]).forEach(function(i){
if(i % 15 == 0){
console.log("FizzBuzz");
} else if(i % 3 == 0) {
console.log("Fizz");
} else if(i % 5 == 0){
@aq2bq
aq2bq / heroku.sh
Last active August 29, 2015 14:00
Deploy Lokka to Heroku
# Regist public-key
$ heroku login
# => input heroku account, email and password
# Remove registered public-key
$ heroku keys:clear
# => All keys removed.
# Reregist public-key
$ heroku keys:add
@aq2bq
aq2bq / seeds.rb
Last active July 28, 2016 01:42
[JPローカライズ]Spree 2.1.1 with Rails4 用シードファイル
# encoding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
@aq2bq
aq2bq / seeds.rb
Last active July 28, 2016 01:41
[JPローカライズ] Spree 2.0.x 向け seeds.rb (Spree 2.1.1 with Rails4 用は https://gist.github.com/aq2bq/6790523 )
# encoding: utf-8
Rails.application.config.active_record.whitelist_attributes = false
ActiveRecord::Base.class_eval do
class << self
def create_or_update! attrs={}
instance = first_or_initialize(attrs, :without_protection => true)
instance.save!
end

Rubyもくもく会 2013/07/20

先週末、神戸東灘区の区民会館で開催された「西脇.rb & 東灘.rb もくもく会」へ参加してきました。

もくもく会とは?

もくもく会は今年3月から始まって5回目の開催で、自分自身は4回目の参加です。内容はシンプルで、もくもく会でやりたいこと(普段開発しているもや調べたいこと)を互いに紹介したものを2,3時間やってみて、それに質問したり、コードレビューしたりするというものです。

これはこの地域での、プレゼンを見るだけだったりや研究会のようなメジャーなプログラミングイベントとは大いに違う点です。もくもく会は実際にコードを書いて、他の開発者からフィードバックをもらって学習することに重きをおいています。本で読んでいるだけでは得られない効果があります。