Skip to content

Instantly share code, notes, and snippets.

@colorbox
colorbox / README.md
Last active Oct 14, 2021
納得いかないやつ
View README.md
View doukaku_2020_12_29.cpp
#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>
View challenge.rb
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 Aug 12, 2019
low number precedence
View priority_queue.rb
class PriorityQueue
attr_accessor :data
def initialize(arr=[])
@data = arr
end
def push(e)
@data.push(e)
View Gemfile.rb
eval File.read('doukaku.rb').scan(/gemfile do\n(.*?)\nend/m)[0][0]
View lazy_map.rb
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 Dec 28, 2018
PRのコメントを作成するcurlコマンド
View curl request for post PR comment
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 Aug 18, 2018
crop image with RMagick
View crop_image.rb
require 'RMagick'
original = Magick::Image.read('original.jpg').first
image = original.crop(0, 0, 10, 10)
image.write('cropped.jpg')
View ika_k-means.py
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')])
View ika_triming
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")