Skip to content

Instantly share code, notes, and snippets.

View ygkn's full-sized avatar
A believing heart is your magic.

YAGITA Yugo ygkn

A believing heart is your magic.
View GitHub Profile
@ygkn
ygkn / download-example.js
Last active February 9, 2017 14:46
JavaScript で a 要素を使用したダウンロードでネットワークエラーが起きた ref: http://qiita.com/ygkn/items/de2457796fdd03928481
const downloader = document.createElement("a");
downloader.download = "ファイル名";
downloader.href = "data:..."; // URL (Data URI scheme や object URLも可能)
downloader.click();
@ygkn
ygkn / session.py
Last active July 24, 2021 12:15
小林さんちのメイドラゴンで出てきたコード(小林さんを探せ!) ref: https://qiita.com/ygkn/items/6b3be1afa31e4092826e
"""
Session Management
(from web.py)
"""
@ygkn
ygkn / file0.html
Last active May 8, 2017 14:51
【ハッカソン/キャンプに】 Web で最小の時間でちょっと「おっ」ってさせる小ネタ ref: http://qiita.com/ygkn/items/03cb8ba5c54058103c49
<script>
new SweetScroll({
trigger: "[data-scroll]",
afterScroll(toScroll, trigger){
location.hash = trigger.hash.slice(1)}
});
</script>
@ygkn
ygkn / CSS
Last active June 18, 2017 04:18
CSS Variables(カスタムプロパティ) は CSS Animation と使うと幸せ ref: http://qiita.com/ygkn/items/33abcc3a5621bdf77c8d
@keyframes anim {
from {width: 0}
to {width: var(--max)}
/* ポイント: @keyframes 内で変数を参照できる */
}
.anim {
background: #1bb8f3;
height: 30px;
margin: 10px;
@ygkn
ygkn / file0.txt
Last active October 26, 2017 14:55
jQueryとは何なのか? なぜ使わなくても(あるいは使わないほうが)いいのか? ref: http://qiita.com/ygkn/items/eed01ae9c01339d6086a
$(() => {
/* 処理 */
})
@ygkn
ygkn / searchlight.js
Created June 20, 2018 03:23
searchlight.js
const { promisify } = require("util");
const { writeFile } = require("fs");
const svgexport = require("svgexport");
const { sin, cos, PI } = Math;
const writeFileAsync = promisify(writeFile);
const svgexportAsync = arg =>
new Promise(res => svgexport.render(arg, () => res()));
const delay = () => new Promise(res => setTimeout(() => res(), 1));
@ygkn
ygkn / withSocket.jsx
Created September 14, 2018 13:29
React で Socket.IO を扱うHOC
import React from 'react';
import io from 'socket.io-client';
const withSocket = (initalStates, mapEventToStates, url, option) => Component => class extends React.Component {
constructor() {
super();
this.state = initalStates;
}
componentDidMount() {
@ygkn
ygkn / README.md
Last active April 24, 2019 05:13
express router example

Gistのファイル名でスラッシュが使えないので_で代用しています。

@ygkn
ygkn / svg.js
Last active May 13, 2019 08:32
C = (command, start=[0,0]) => command
.split(' ')
.reduce((b,c,i) =>
!(i % 3) ?
[...b, [c.split(',').map(v=>parseFloat(v))]] :
[...b.slice(0,-1), [...b[b.length - 1],c.split(',').map(v=>parseFloat(v))]]
,[]) // to [[[x,y],[x,y],[x,y]] * n]
.reduce((b, c) =>
[...b, c.map(cood => cood.map((v,i) =>
v + (b.length ? b[b.length-1][b[b.length-1].length-1]:start)[i]))]
PFont font;
int canvasSize = 700;
int drawCount = 50;
float reiwaSize = canvasSize / 5;
class SugaCood {
PVector p;
PVector v;
PVector a;
float angle;