Skip to content

Instantly share code, notes, and snippets.

@hachy
hachy / price_range.rb
Created November 11, 2023 00:56
Display prices within a 10% to -10% range of the original price.
v = 1234
10.downto(-10) do |i|
print (v * (1 + (i * 0.01))).round
puts "#{i}%".rjust(5)
end
@hachy
hachy / init.lua
Last active May 8, 2023 04:01
with lazy.nvim
vim.loader.enable()
require "core/autocmds"
require "core/options"
require "core/mappings"
require "core/statusline"
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system {
@hachy
hachy / game_status.py
Created February 26, 2023 01:16
ゲームのステータス cf. https://algo-method.com/tasks/1073
STATUS = 10
DIGIT = 5
def change_status(i, val, cur_val):
bit = (1 << (STATUS * DIGIT)) - 1
idx = i * DIGIT
s = (1 << (idx + DIGIT)) - (1 << idx)
mask = bit ^ s
cur_val &= mask
@hachy
hachy / .stylua.toml
Created December 7, 2022 04:24
stylua
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "None"
@hachy
hachy / PrintDiagnostics.lua
Created April 12, 2022 05:49
Use PrintDiagnostics with highlight in nvim-lspconfig
local hl_tbl = {
[vim.diagnostic.severity.ERROR] = "DiagnosticError",
[vim.diagnostic.severity.WARN] = "DiagnosticWarn",
[vim.diagnostic.severity.HINT] = "DiagnosticHint",
[vim.diagnostic.severity.INFO] = "DiagnosticInfo",
}
function PrintDiagnostics(opts, bufnr, line_nr, client_id)
bufnr = bufnr or 0
line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1)
@hachy
hachy / .stylelintrc
Last active November 23, 2022 05:00
prettierとあわせて使う
{
"plugins": ["stylelint-prettier"],
"rules": {
"prettier/prettier": true
},
"extends": ["stylelint-config-standard", "stylelint-config-recess-order", "stylelint-prettier/recommended", "stylelint-config-prettier"]
}
module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true
},
extends: [
'airbnb-base',
'eslint:recommended',
black = %w(16 #000000)
white = %w(15 #FFFFFF)
gray = %w(102 #9E9E9E)
darkgray = %w(240 #585858)
dimgray = %w(235 #262626)
darkpurple = %w(97 #875FAF)
purple = %w(135 #BC79FF) # #B388FF
lightpurple = %w(171 #E080FC) # #C993FF
green = %w(119 #76FF03)
lightgreen = %w(156 #AEEA00)
@hachy
hachy / result.txt
Created December 25, 2018 10:42
12月25日現在 5953コメントを集計 乃木坂46流行語大賞 https://qiita.com/hachy/items/2e4fa0736f98361df5fe
850 | ヤラカシタヤラカシタ
46 | ヤラカシタ
135 | ヤラカシタ、ヤラカシタ
22 | ヤラカシタ ヤラカシタ
1 | ヤラカシタヤラカシタ(棒読み)
2 | ヤラカシタやらかした
2 | ヤラカシタ、ヤラカシタ
2 | ヤラカシタ、ヤラカシタ。
1 | ヤラカシタカラカシタ
489 | 卒業
@hachy
hachy / buzzword.rb
Created November 21, 2018 04:00
乃木坂46流行語大賞2018
# frozen_string_literal: true
words = []
File.open("word.txt", "r") do |f|
words = f.readlines
end
word_count = words.each_with_object(Hash.new(0)) do |word, hash|
hash[word.chomp!] += 1