Skip to content

Instantly share code, notes, and snippets.

import cv2
# https://github.com/nagadomi/lbpcascade_animeface/blob/master/lbpcascade_animeface.xml
cascade_path = './lbpcascade_animeface.xml'
def detect(image):
image_gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
image_gray = cv2.equalizeHist(image_gray)
cascade = cv2.CascadeClassifier(cascade_path)
face_rect = cascade.detectMultiScale(image_gray, scaleFactor=1.1, minNeighbors=3, minSize=(50, 50))
require 'selenium-webdriver'
require 'uri'
require 'open-uri'
require 'fileutils'
require 'digest/md5'
def write_urls(label, keyword)
driver = Selenium::WebDriver.for(:chrome)
driver.navigate.to('https://www.google.co.jp/imghp')
driver.find_element(:id, 'lst-ib').send_keys(keyword)
@quanon
quanon / quicksort.js
Last active March 21, 2017 14:22
quicksort
const quicksort = (array) => {
if (array.length <= 1) return array;
const pivot = array[Math.floor(Math.random() * array.length)];
// 余計な走査は許してください。
const left = array.filter(i => i < pivot);
const middle = array.filter(i => i === pivot);
const right = array.filter(i => i > pivot);
def stack(current, result)
unless current.length < 4
result << current
return
end
stack(current + 'a', result)
stack(current + 'b', result)
stack(current + 'c', result)
stack(current + 'd', result)
module Procedural
extend ActiveSupport::Concern
included do
private_class_method :new
end
class_methods do
def call(*args)
new(*args)
# ~/.config/fish/config.fish
## peco ##
function fish_user_key_bindings
bind \cr peco_select_history
end
## rbenv ##
set -x PATH $HOME/.rbenv/bin $PATH
rbenv init - | source
var page = require('webpage').create();
var args = require('system').args;
page.viewportSize = {
width: 1200,
height: 780
};
page.open(args[1], function (status) {
if (status !== 'success') {
@quanon
quanon / enum_value_getter.rb
Created May 13, 2016 09:21
enum の整数値をゲットするマン
# enum 定義の後で include すること。
module EnumValueGetter
extend ActiveSupport::Concern
included do
defined_enums.keys.each do |name|
define_method("#{name}_value") { self[name] }
end
end
end
@quanon
quanon / Gemfile
Created February 6, 2016 04:39
Rails 5.0.0.beta2 をインストールした際のログ
ruby '2.3.0'
source 'https://rubygems.org'
gem 'rails', '~> 5.0.0.beta2'
@quanon
quanon / binary_number_counter.ino
Created January 6, 2016 16:25
2 進数カウンター
const int LED4 = 13;
const int LED3 = 12;
const int LED2 = 11;
const int LED1 = 10;
const int BTN1 = 7;
int old_input = LOW;
int new_input = LOW;
int count = 0;