Skip to content

Instantly share code, notes, and snippets.

View yhirano's full-sized avatar

Yuichi Hirano yhirano

View GitHub Profile
@yhirano
yhirano / colorblend.rb
Created October 8, 2017 03:49
HTMLカラーコードで指定した色をRGBに分解して、それぞれに指定の割合をかけてHTMLカラーコードに戻すスクリプト
#!/usr/bin/env ruby
# Color blend
#
# Usage
# $ colorblend.rb cfd2ce 0.9
# babdb9
require 'color'
require 'pp'
@yhirano
yhirano / mvi.sh
Last active October 23, 2017 22:26
The script to move Android images of exported from Adobe Illustrator CC(21) to directories for each resolution
#!bin/sh
dirs=("xxxhdpi" "xxhdpi" "xhdpi" "hdpi" "mdpi")
for dir in "${dirs[@]}"; do
mkdir drawable-${dir}
for file in *${dir}.png; do
mv -- "$file" "drawable-${dir}/${file%%${dir}.png}.png"
done
done
@yhirano
yhirano / RxDownloader.java
Last active June 15, 2018 03:27
Downloader with RX for Android
// Copyright (c) 2017 Yuichi Hirano
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
@yhirano
yhirano / NumberLoopBenchmark.swift
Last active June 21, 2017 23:53
数値をループさせるアルゴリズムの速度比較
func runBench() {
let loop = 1000000
let measurements = 100
var total = 0.0
// If condition loop
for _ in 0..<measurements {
let timeElapsed = timeElapsedInSecondsWhenRunningCode {
var num: Int = 0
@yhirano
yhirano / esp32_ap_sample.c
Created April 20, 2017 22:07
ESP32 Wifi AP mode sample
#include <esp_event.h>
#include <esp_event_loop.h>
#include <esp_log.h>
#include <esp_system.h>
#include <esp_wifi.h>
#include <freertos/FreeRTOS.h>
#include <nvs_flash.h>
// Defines for WiFi
#define SSID "YOUR SSID"
@yhirano
yhirano / fetch_google_image.py
Last active February 24, 2021 22:48
[No longer available] Download a random picture from Google image search.
#!/usr/bin/env python
# coding: utf-8
# Download a random picture from Google image search.
#
# Usage:
# $ fetch_google_image.py cat cute # Download a cute cat picture
import os
import sys
@yhirano
yhirano / fetch_4u.rb
Created March 28, 2012 10:54
Download a beauty picture from http://4u-beautyimg.com/
#!/usr/bin/env ruby
# Download a beauty picture from http://4u-beautyimg.com/
#
# Usage:
# $ fetch_4u.rb # Download a picture to /tmp/4u.jpg
# $ fetch_4u.rb ~/pic.jpg # Download a picture to ~/pic.jpg
require 'open-uri'
require "rexml/document"