Skip to content

Instantly share code, notes, and snippets.

Ginpei ginpei

Block or report user

Report or block ginpei

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View speech-on-google-home.js
const { Client, DefaultMediaReceiver } = require('castv2-client');
const googleTTS = require('google-tts-api');
const address = '192.168.1.86';
const message = {
language: undefined, // default: 'en'
body: 'Hello World!',
speed: undefined, // default: 1
timeout: undefined, // default: 1000
};
View lifx-breathe.js
// https://api.developer.lifx.com/docs/breathe-effect
(async () => {
const token = prompt('Token?');
const selector = 'all';
const url = `https://api.lifx.com/v1/lights/${selector}/effects/breathe`;
const params = {
color: 'red',
cycles: 3,
View wip-coding-note.md

Coding notes

[WIP] Component categories

TODO: find better names

The word "component" is so general that we leave it from our categories.

  • pages ... Largest components
  • organizations ... Small size components
View ws-server.js
const WebSocket = require('ws');
let numClients = 0;
// start server
// https://github.com/websockets/ws
const wss = new WebSocket.Server({
port: 8080,
perMessageDeflate: {
zlibDeflateOptions: { // See zlib defaults.
View color-list.js
Object.entries(Array.from(document.querySelectorAll('*'))
.reduce((list, el) => {
const styles = window.getComputedStyle(el);
Object.values(styles).forEach((prop) => {
const value = styles[prop];
if (prop.toLowerCase().includes('color')) {
(value.match(/rgba?\(\d+, \d+, \d+(, \d+(.\d+)?\))?/g) || [])
.map(s => (s.match(/\d+(.\d+)?/g) || []).join(', '))
.forEach((color) => {
if (!(color in list)) {
View z-index-table.js
((document, limit) => {
const data = Array.from(document.querySelectorAll('*'))
.map((el) => ({zIndex: Number(getComputedStyle(el).zIndex), element: el }))
.filter(({ zIndex }) => !isNaN(zIndex))
.sort((r1, r2) => r2.zIndex - r1.zIndex)
.slice(0, limit);
console.table(data);
})(document, 50);
@ginpei
ginpei / README.md
Last active Apr 8, 2018
TS Compiler doesn't work with @types/sinon-chai
View README.md

Environment

Using WSL (Ubuntu) on Windows 10.

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"
View hello-js-world.html
<!DOCTYPE html>
<title>Hello World!</title>
<button id="hello">Hello</button>
<script>
hello.onclick = () => alert('Hello World!');
</script>
@ginpei
ginpei / replaceWords.js
Created Dec 20, 2017
ページ中の単語を置き換える
View replaceWords.js
{
replaceWords(//g, '');
function replaceWords(target, result) {
const texts = [];
const els = document.querySelectorAll('title, body *:not(script):not(style)')
els.forEach(el => {
texts.push(...findTextNodes(el))
})
@ginpei
ginpei / vim.md
Last active Nov 12, 2017
Vim始めるぞ
View vim.md
You can’t perform that action at this time.