Skip to content

Instantly share code, notes, and snippets.

View smagch's full-sized avatar
🗾
Japan

Shimaguchi Tomoya smagch

🗾
Japan
View GitHub Profile
@smagch
smagch / hoge.js
Last active April 14, 2018 12:26
reselect test
const { createSelector } = require('reselect');
const ids = [1,2,3];
const byIds = {
1: {
name: 'one'
},
2: {
name: 'two'
@smagch
smagch / index.html
Last active December 7, 2022 07:40
HTML Canvas text highlighter
<!DOCTYPE html>
<html>
<head>
<title>Strepsirrhini</title>
<meta name="viewport" content="user-scalable=no" />
<style>
body {
margin: 0;
font-size: 1em;
@smagch
smagch / index.html
Last active December 20, 2016 19:35
zoomable canvas
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
body {
margin: 0;
}
.box {
display: block;
@smagch
smagch / test.js
Created October 1, 2016 09:45
Test Getting Tree Data in flattened Array
class Tree {
constructor(name) {
this.name = name;
this.children = [];
}
append(item) {
this.children.push(item);
}
getDescendantNames() {
@smagch
smagch / sequential-promise-execution-test.js
Created September 13, 2016 12:49
Sequential Promise execution
// StackOverFlow: http://stackoverflow.com/a/30823708/1248952
function getTimer(name, timeout) {
return () => new Promise((resolve, reject) => {
setTimeout(() => {
console.log(name);
resolve();
}, timeout);
});
}
@smagch
smagch / index.html
Last active September 9, 2016 16:45
Scroll Selection testing
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
#container {
position: absolute;
top: 0;
@smagch
smagch / index.html
Created September 9, 2016 12:56
Infinite scroll with prepending items -- testing scrollTop adjustment
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
html {
scroll-behavior: smooth;
min-height: 200%;
}
Promise.resolve(100).then(num => {
console.log('num: ', num);
return num + 100;
}).then(num => {
console.log('num2:', num);
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log('timeout');
resolve('World');
@smagch
smagch / densuke.go
Last active May 1, 2016 23:58
伝助データジェネレーター
package main
import (
"fmt"
"log"
"time"
)
var (
dateStart = "2016-05-02"
@smagch
smagch / responsive_images.sh
Last active August 29, 2015 14:27
Imagemagick multiple files
#!/bin/bash
SIZES=(320 640 960 1280 1920 2560)
target=$1
extension="${target##*.}"
filename="${target%.*}"
echo "ext is $extension"
if [ ! -f $target ]; then