Gistのファイル名でスラッシュが使えないので_で代用しています。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const downloader = document.createElement("a"); | |
downloader.download = "ファイル名"; | |
downloader.href = "data:..."; // URL (Data URI scheme や object URLも可能) | |
downloader.click(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Session Management | |
(from web.py) | |
""" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
new SweetScroll({ | |
trigger: "[data-scroll]", | |
afterScroll(toScroll, trigger){ | |
location.hash = trigger.hash.slice(1)} | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@keyframes anim { | |
from {width: 0} | |
to {width: var(--max)} | |
/* ポイント: @keyframes 内で変数を参照できる */ | |
} | |
.anim { | |
background: #1bb8f3; | |
height: 30px; | |
margin: 10px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(() => { | |
/* 処理 */ | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PFont font; | |
int canvasSize = 700; | |
int drawCount = 50; | |
float reiwaSize = canvasSize / 5; | |
class SugaCood { | |
PVector p; | |
PVector v; | |
PVector a; | |
float angle; |