Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

ushironoko ushironoko

👋
View GitHub Profile
@ushironoko
ushironoko / github-title-and-url-copy.js
Created May 11, 2021
Place a button to copy the GitHub title and URL
View github-title-and-url-copy.js
const title = document.querySelector('.js-issue-title').textContent.trim()
const url = location.href
const copyButton = document.createElement('button')
copyButton.addEventListener('click', () => navigator.clipboard.writeText(`${title}\n${url}`))
copyButton.textContent = "copy"
copyButton.classList.add("btn", "btn-sm", "ml-1")
View SnippetAutoRunner.js
/*
* Paste in "SunippetAutoRunner" Extention and enter "jobcan.jp" as the hostname
* https://chrome.google.com/webstore/detail/scriptautorunner/gpgjofmpmjjopcogjgdldidobhmjmdbm
*/
document.querySelector('html').style.transition = 'all .6s'
document.querySelector('main').style.display = 'flex';
document.querySelector('main').style.justifyContent = 'center';
document.querySelector('html').style.webkitFilter = 'invert(1) hue-rotate(180deg)'
const result = document.querySelector('#search-result')
const list = result.getElementsByTagName('div')
@ushironoko
ushironoko / getCompilerOptions.ts
Created Aug 26, 2020
get tsconfig compiler options
View getCompilerOptions.ts
function getCompilerOptions(rootDir: string, configName = 'tsconfig.json') {
const parseConfigHost: ts.ParseConfigHost = {
fileExists: ts.sys.fileExists,
readFile: ts.sys.readFile,
readDirectory: ts.sys.readDirectory,
useCaseSensitiveFileNames: true,
}
const configFileName = ts.findConfigFile(
rootDir,
@ushironoko
ushironoko / keybindings.json
Last active Jun 11, 2020
toggle vetur.experimental.templateInterpolationService Settings
View keybindings.json
// add extention "Toggle" https://marketplace.visualstudio.com/items?itemName=rebornix.toggle
[
{
"key": "alt+cmd+v",
"command": "toggle",
"when": "editorTextFocus",
"args": {
"id": "vetur",
"value": [
{
@ushironoko
ushironoko / sample.ts
Created Jun 8, 2020
copy to clipboard
View sample.ts
copyToClipboard(copyText: string) {
const text = document.createElement('textarea')
text.classList.add('invisible')
text.value = copyText
const elem = document.getElementById('copy')
elem.appendChild(text)
text.select()
document.execCommand('copy')
text.remove()
}
View sample.ts
interface DataType {
sub: SubType | null
// なんかいっぱい
}
interface SubType {
val: string
// なんかいっぱい
}
@ushironoko
ushironoko / snippets.ts
Last active May 22, 2020
rollup-vue-plugin typescript2 snippet
View snippets.ts
// rollup.build.config
import path from 'path'
import vue from 'rollup-plugin-vue'
import resolve from '@rollup/plugin-node-resolve'
import common from '@rollup/plugin-commonjs'
import babel from '@rollup/plugin-babel'
import typescript from 'rollup-plugin-typescript2'
import alias from '@rollup/plugin-alias'
import postcss from 'rollup-plugin-postcss'
@ushironoko
ushironoko / .hyper.js
Last active Jun 17, 2020
hyper terminal settings
View .hyper.js
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
//pokemon: 'golbat',
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
View webpack.config.js
/* eslint-disable @typescript-eslint/no-var-requires */
const { resolve } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
const webpack = require('webpack')
const outputPath = resolve(__dirname, 'dist')
/** @type {import('webpack').ConfigurationFactory} */
View camel-to-snake.js
function camelToSnakeCase(text){
if(text === null || text === undefined){
return text;
}
var result = "";
var upper = 0;
var numeric = undefined;
var string = String(text);
for(var i = 0; i < string.length; i++){
var ch = string[i];