Skip to content

Instantly share code, notes, and snippets.

View Wintus's full-sized avatar
📡
on the ground

wint Wintus

📡
on the ground
  • Tokyo
  • 17:30 (UTC +09:00)
  • X @wint7
View GitHub Profile
@Wintus
Wintus / round-up.rb
Created April 18, 2017 07:10
Round Up in Ruby
# http://stackoverflow.com/questions/3400915/how-do-i-round-an-integer-up-to-nearest-large-number-in-ruby
def round_up_10th(n)
d = 10 ** Math.log10(n).floor
q, r = n.divmod(d)
m = r.zero? ? q : q.succ
d * m
end
def round_up_2nd(n)
d = 2 ** Math.log2(n).floor
@Wintus
Wintus / a10n.rb
Last active July 24, 2024 11:23
Ruby: playground & snippets & scratches
# make abbreviation
def a10n(s)
n = s.size
if n < 2
s
else
a, z = s[0], s[-1]
"#{a}#{n-2}#{z}"
end
end
@Wintus
Wintus / mono-repo.md
Created May 26, 2017 02:23
Monorepo Structure

Monorepo Structure

Directury Structure

  • src/
    • app-name/
  • infra/
    • terraform/
      • main.tf
  • provisiosing
  • ansible.cfg
@Wintus
Wintus / doc-utils.js
Last active January 27, 2020 07:49
ES2015 utils for DOM API
document.documentMode && document.documentMode < 11 && alert("Browser below IE11 is unsupported.");
document.documentMode || console.log("No more IE.");
@Wintus
Wintus / array.js
Last active September 16, 2017 23:31
ES6 generators - Fibonacci - FizzBuzz
const iota = (n = 0) => Array(n).fill().map((_, i) => i);
@Wintus
Wintus / amazon-url-jp.js
Last active September 27, 2017 17:59
Amazon Minimum URL JS
const domId = "productDetailsTable";
const asinMatcher = /(?:ASIN:\s*)(\w+)/;
const detail = document.getElementById(domId);
const asin = detail.innerText.match(asinMatcher)[1];
location.href = location.origin + "/dp/" + asin;
// oneline
(()=>{location.href = location.origin + "/dp/" + document.getElementById("productDetailsTable").innerText.match(/(?:ASIN:\s*)(\w+)/)[1];})();
@Wintus
Wintus / disable-narutal-scroll.ps1
Created October 15, 2017 14:33
Scripts for Natural Scroll in Windows
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA SilentlyContinue | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 0 }
@Wintus
Wintus / evdev-layout-oea.xml
Last active November 1, 2017 06:22
OEA keymap in linux
<!-- //LayoutList -->
<layout>
<configItem>
<name>oea</name>
<shortDescription>en</shortDescription>
<description>OEA layout</description>
<languageList>
<iso639Id>eng</iso639Id>
<iso639Id>jpn</iso639Id>
@Wintus
Wintus / arg.fish
Last active November 1, 2017 07:18
~/.config/fish/functions
# Defined in - @ line 0
function arg --description 'alias arg xargs -n 1'
xargs -n 1 $argv;
end
@Wintus
Wintus / ifconfig_cidr.rb
Last active November 1, 2017 09:12
Ruby net tools
#! /usr/bin/env ruby
require 'socket'
require 'netaddr'
interface = $*.first
ifaddr = Socket.getifaddrs.find { |i| i.name =~ /#{Regexp.quote(interface)}/ && i.addr.ipv4? }
ip, mask = ifaddr.addr.ip_address, ifaddr.netmask.ip_address