Skip to content

Instantly share code, notes, and snippets.

fukajun fukajun

Block or report user

Report or block fukajun

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View update_pdf_size.rb
require 'combine_pdf'
#require 'prawn'
def crop(page, x1, y1, x2, y2)
size = page.page_size
x1_new = size[0] - x1
y1_new = size[1] - y1
x2_new = size[2] + x2
y2_new = size[3] + y2
page.mediabox = [x1_new, y1_new, x2_new, y2_new]
View README_ika_sync.md

Setup

envchain --set isucon IKA_USER IKA_HOSTS

IKA_USER : fukajun

IKA_HOSTS : isu1,isu2,isu3

config

View aws.json
{"regions":[{"id":"us-east-1","name":"US East","location":"N. Virginia"},{"id":"us-east-2","name":"US East","location":"Ohio"},{"id":"us-west-1","name":"US West","location":"N. California"},{"id":"us-west-2","name":"US West","location":"Oregon"},{"id":"ap-south-1","name":"Asia Pacific","location":"Mumbai"},{"id":"ap-northeast-2","name":"Asia Pacific","location":"Seoul"},{"id":"ap-southeast-1","name":"Asia Pacific","location":"Singapore"},{"id":"ap-southeast-2","name":"Asia Pacific","location":"Sydney"},{"id":"ap-northeast-1","name":"Asia Pacific","location":"Tokyo"},{"id":"ca-central-1","name":"Canada","location":"Central"},{"id":"eu-central-1","name":"EU","location":"Frankfurt"},{"id":"eu-west-1","name":"EU","location":"Ireland"},{"id":"eu-west-2","name":"EU","location":"London"},{"id":"eu-west-3","name":"EU","location":"Paris"},{"id":"sa-east-1","name":"South America","location":"São Paulo"}],"consoleHomeServiceCategoriesByColumn":[["compute","storage","database","migration","networking","developer_tools"],
@fukajun
fukajun / limit_worker_sample.js
Created Aug 24, 2017
Limit concurency count on javascript
View limit_worker_sample.js
var list = []
for(i = 0; i < 200; i++) {
list.push(i)
}
var semaphore = [true, true, true, true, true, true]
var uploadImage = function(num, callback) {
setTimeout(function() {
console.log('upload', num)
callback()
}, 2000)
View github_release_download_count.md
curl https://api.github.com/repos/fukajun/245cloud-app/releases\?access_token\=$GITHUB_PERSONAL_TOKEN | vim -
View gist:8d476965cf11a184bcec
class User < ActinveRecord::Base
# address = '1540022 tokyo aa street
Address = Struct.new(:zip, :street)
before_save :rebuild_address
def address_object
@address_object ||= Address.new(address[0..5], address[6..-1])
end
def rebuild_address
address = @address_object.zip + ...
end
@fukajun
fukajun / YAPC2105schedule.js
Last active Aug 29, 2015
YAPC のスケージュールのページでchrome developperツールから流すとハイライトできるようになります。( http://yapcasia.org/2015/talk/schedule?date=2015-08-21 ) だからなに?
View YAPC2105schedule.js
var render = function() {
$('.talk').css('background-color', 'white')
result = ''
Object.keys(list).map(function(id) {
var $el = $('.talk').has('#' + id)
$el.css('background-color', 'pink')
result += $el.find('.title').text() + '\n'
})
console.log(result)
localStorage.wanted = JSON.stringify(list);
View App.js
import React from 'react'
export class Appp extends React.Component{
constructor(props) {
super(props)
this.state = {
counter: 0
}
}
change(e) {
console.log(e.target.value)
View flux_validatio.md

Nailing that validation with React JS

Validation is complex. Validation is extremely complex. I think it is right up there at the top of implementations we misjudge regarding complexity. So why is validation so difficult in general? How could we implement this with React JS? And do you get a prize for reading through this article? ... yep, you do! Look forward to a virtual cookie at the bottom of this article, you will definitely deserve it ;-)

At my employer, Gloppen EDB Lag, we are building a React JS component framework for application development. We have everything from grids and panels to calendars and forms. Think of it as React Bootstrap, but with bigger parts specific to our applications. So we have lots of forms in our applications and we needed a form that could handle both user input validation, server validation and be very flexible with the contents of the form.

This article will explain the challenges and the thought process of building such a form component. Forms and validation is comple

@fukajun
fukajun / gist:81397a29fedbf5dccb4c
Created Jun 29, 2015
コードをコピーしてコメント付きのMarkdownをレジスタに登録する
View gist:81397a29fedbf5dccb4c
function! Memo() range
let tmp = @@
silent normal gvy
let selected = @@
let @@ = tmp
let line = line('.')
let memo = input('memo: ')
let fpath = expand('%:p')
let buf = ''
You can’t perform that action at this time.