Skip to content

Instantly share code, notes, and snippets.

View YoshiTheChinchilla's full-sized avatar
:octocat:
On GitHub

Yoshi YoshiTheChinchilla

:octocat:
On GitHub
  • Worldwide
View GitHub Profile
{
"data": [
"#Android",
"#Ansible",
"#Arduino",
"#AWS",
"#Azure",
"#bash",
"#C#",
"#centos",
// https://www.oreilly.co.jp/ebook/
// or JSON without file types
// https://www.oreilly.co.jp/catalog/
const rows = [...document.querySelector('#bookTable').rows]
rows.shift()
const books = rows.map(r => {
const [isbnElm, titleElm, priceElm, dateElm, typesElm] = r.children
@YoshiTheChinchilla
YoshiTheChinchilla / BaseAlert.vue
Last active April 19, 2021 05:30
Simple Event Bus pattern in Vue.js and Nuxt.js
<template>
</template>
<script>
// Import the Event Bus of Vue instance
import { EventBus } from './event-bus.js'
export default {
created() {
(this.$nuxt || EventBus || this.$EventBus).$on('open-alert', this.openAlert)
@YoshiTheChinchilla
YoshiTheChinchilla / macbuntu-transformer.sh
Created July 19, 2019 02:05
Tranforming Ubuntu 18.04(LTS) to MacBuntu Shell Script
#!/bin/bash
# Transform Ubuntu 18.04 or Linux Mint 19 to MacBuntu
# https://www.noobslab.com/2018/08/macbuntu-1804-transformation-pack-ready.html
# If you want to change another version Ubuntu or Linux Mint?
# Search MacBuntu for your version on https://www.noobslab.com/search?q=MacBuntu
# Setup workspace
WORKSPACE=~/Desktop/macbuntu
/// "2$4$8$16"
/// ↓
/// "$"を"#"に置換
/// ↓
/// "2#4#8#16"
/// ↓
/// "#"を区切り文字に配列へ分割
/// その要素数を表示
/// ↓
fn to_rgb(r: usize, g: usize, b: usize) -> String {
format!("#{:02X}{:02X}{:02X}", r, g, b)
}
fn main() {
// let mut args = std::env::args();
// args.skip().next().unwrap(), args.next().unwrap(), args.next().unwrap()
assert_eq!(to_rgb(200, 15, 1), "#C80F01");
}
@YoshiTheChinchilla
YoshiTheChinchilla / match-pattern-benchmark.js
Created January 29, 2021 07:53
Benchmarking RegExp and String procedure in JavaScript https://github.com/bestiejs/benchmark.js
// $ npm i --save benchmark microtime
const Benchmark = require('benchmark')
const suite = new Benchmark.Suite
const str = 'E0123'
const compiledRegex = new RegExp(/E\d{4}/)
suite
.add('RegExp#match', function() {
const matched = str.match(/E\d+/)

問題1. 選択肢の中からRubyの予約語ではないものを2つ選択してください。

  • A. super
  • B. begin
  • C. try
  • D. goto
解答

C,D

@YoshiTheChinchilla
YoshiTheChinchilla / zero_array_of.rs
Created January 18, 2021 16:26
Zero array with generics
#![feature(const_generics)]
#![feature(const_evaluatable_checked)]
use std::mem::size_of;
pub fn zero_array_of<T>() -> [u8; size_of::<T>()] {
[0u8; { size_of::<T>() }]
}
#[cfg(test)]
[
{"year": 1983, "slogan": "これまでで一番強くかつ攻撃的な味"},
{"year": 1985, "slogan": "近年にない上物"},
{"year": 1992, "slogan": "過去2年のものよりフルーティーで、軽い"},
{"year": 1995, "slogan": "ここ数年で一番出来が良い"},
{"year": 1996, "slogan": "10年に1度の逸品"},
{"year": 1997, "slogan": "まろやかで濃厚。近年まれにみるワインの出来で過去10年間でトップクラス"},
{"year": 1998, "slogan": "例年のようにおいしく、フレッシュな口当たり"},
{"year": 1999, "slogan": "1000年代最後の新酒ワインは近年にない出来"},
{"year": 2000, "slogan": "今世紀最後の新酒ワインは色鮮やか、甘みがある味"},