Skip to content

Instantly share code, notes, and snippets.

@colorbox
colorbox / README.md
Last active October 14, 2021 16:00
納得いかないやつ
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
@colorbox
colorbox / challenge.rb
Last active September 29, 2019 06:30
def split_num(num)
("%04d" % num).split('').map(&:to_i)
end
def split_num_f(num)
split_num(num).map(&:to_f)
end
def twined(nums, symbols)
nums.zip(symbols).flatten.compact.map(&:to_s).join('')
@colorbox
colorbox / priority_queue.rb
Last active August 12, 2019 12:10
low number precedence
class PriorityQueue
attr_accessor :data
def initialize(arr=[])
@data = arr
end
def push(e)
@data.push(e)
eval File.read('doukaku.rb').scan(/gemfile do\n(.*?)\nend/m)[0][0]
@colorbox
colorbox / lazy_map.rb
Last active January 21, 2019 08:02
lazy確認
class Hoge
attr_accessor :body
def initialize(body)
@body = body
end
def squisher
pp "i squished #{@body}"
@body.squish
@colorbox
colorbox / curl request for post PR comment
Created December 28, 2018 15:38
PRのコメントを作成するcurlコマンド
curl -X POST -H "Content-Type: application/json" -H "Authorization: token <your GitHub token>" --data '{"commit_id":"8ae911bfd368794ba8955793faff475dcf0b81b7","body":"test","path":"app/models/space_include_ _file_name.rb","position":2}' https://api.github.com/repos/colorbox/kata/pulls/3/comments
@colorbox
colorbox / crop_image.rb
Created August 18, 2018 15:58
crop image with RMagick
require 'RMagick'
original = Magick::Image.read('original.jpg').first
image = original.crop(0, 0, 10, 10)
image.write('cropped.jpg')
import os
import shutil
import numpy as np
from PIL import Image
from skimage import data
from sklearn.cluster import KMeans
cluster_count = 4
feature = np.array([data.imread("./icons/" + path) for path in os.listdir('./icons')])
require 'RMagick'
require 'rubygems'
def crop_icons(filename)
original = Magick::Image.read(filename).first
prefix = File.basename(filename, ".*")
image = original.crop(356, 15, 53, 60)
image.write("icons/#{prefix}-1.jpg")