Skip to content

Instantly share code, notes, and snippets.

View potato4d's full-sized avatar
💭
It's not so easy to be consistent

Takuma HANATANI potato4d

💭
It's not so easy to be consistent
View GitHub Profile
@potato4d
potato4d / Greeting.spec.js
Created December 9, 2016 15:01
Vue.js Vueコンポーネントのユニットテストを書いてみよう ref: http://qiita.com/potato4d/items/8215941b84c11b845886
import Vue from 'vue'
import Greeting from 'src/components/Greeting.vue'
function getInstance (Component, propsData) {
const Ctor = Vue.extend(Component)
const vm = new Ctor({ propsData }).$mount()
return vm
}
describe('Greeting.vue', () => {
@potato4d
potato4d / main.js
Created November 16, 2016 10:05
Electronでタイトルバーを非表示にしつつウィンドウの操作ボタンを表示する方法 ref: http://qiita.com/potato4d/items/7cf11b75176cb355f364
function createWindow () {
// Create the browser window.
--- mainWindow = new BrowserWindow({width: 800, height: 600})
+++ mainWindow = new BrowserWindow({titleBarStyle: 'hidden',width: 800, height: 600})
@potato4d
potato4d / electron-fix.js
Created November 15, 2016 07:25
ElectronのWebviewにexecuteJavaScriptを利用した場合のコールバックについて ref: http://qiita.com/potato4d/items/9261908aba01f29c6f5f
const $ = e=>document.querySelector(e);
const webview = $("webview");
webview.addEventListener("did-stop-loading", ()=>{
webview.executeJavaScript(
`color:{$("#col_channels_bg").css("backgroundColor")}`,
false,
function(color){
console.log(color); // rgb(100, 100, 100);
// 決してcolor.colorではなく、colorでアクセスすることになるので注意
}
@potato4d
potato4d / style.css
Last active December 20, 2018 01:27
CSS3でWebサイト上のナビゲートに使える「くり抜き(スポットライト)」を実装する ref: https://qiita.com/potato4d/items/3db5be441d89ea448c3c
.spotlight{
position: absolute;
left: 0;
top : 0;
width: 100vw;
height: 100vh;
background: radial-gradient(transparent, transparent 100px, rgba(0,0,0,0.4) 100px, rgba(0,0,0,0.4));
@potato4d
potato4d / Response.php
Last active October 5, 2016 07:19
雑Router(ちゃんとしたい)
<?php
namespace Utilitys;
class Response
{
private static $instance;
/**
* getInstance
*
@potato4d
potato4d / radwimps.php
Last active February 22, 2017 05:00
RADWIMPSで学ぶ再帰関数 「(前)\1{1,}世」から探し始めよう ref: http://qiita.com/potato4d/items/e3905927670787b34946
<?php
function prev_life($count){
$life = "";
for ($i=0; $i < $count; $i++) {
$life .= "前";
}
return $life;
}
@potato4d
potato4d / file3.txt
Last active March 4, 2019 07:09
npmモジュール`pre-commit`を利用してチーム全体で低品質なコードをコミットできないようにする ref: https://qiita.com/potato4d/items/5dfebb9da1c5fe400809
/path/to/pre-commit-sample/index.js
1:1 error Unexpected var, use let or const instead no-var
✖ 1 problem (1 error, 0 warnings)
pre-commit:
pre-commit: We've failed to pass the specified git pre-commit hooks as the `test`
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit:
pre-commit:
@potato4d
potato4d / CompA.vue
Created September 5, 2016 05:22
Vue.js vue-routerのページに対してコンポーネントを大量に読み込むのがつらい問題を解消する ref: http://qiita.com/potato4d/items/a82be294225cea2ead8b
<template lang="html">
<p>Hello.</p>
</template>
<style lang="css"></style>
<script>
module.exports = {};
</script>
@potato4d
potato4d / main.js
Last active August 24, 2016 10:34
Node.jsでユーザーのホームディレクトリのパスを取得する ref: http://qiita.com/potato4d/items/7131028497de53ceb48e
const path = require("path");
const userHome = process.env[process.platform == "win32" ? "USERPROFILE" : "HOME"];
console.log(path.join(userHome, "Desktop"));
// /Users/foo/Desktop
console.log(path.join(userHome, "Documents"));
// /Users/foo/Documents
@potato4d
potato4d / terminal
Created August 17, 2016 04:52
Atomを利用したターミナル in エディタによるQoL向上計画 ref: http://qiita.com/potato4d/items/0931126f9fb0ea558f1e
$ apm install terminal-plus