Skip to content

Instantly share code, notes, and snippets.

View hagata's full-sized avatar
🦦

Genki Hagata hagata

🦦
  • Pixar
  • United States
View GitHub Profile
@hagata
hagata / PRICE_INCREASE.sol
Created September 28, 2021 13:14
Solidity Smart Contract implementation to define an increasing pricing structure for selling tokens/NFT's
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract PriceIncrease {
// @dev starting the pricelist tier from 0 index
int public priceTier = 0;
uint256 public totalPurchased = 0;
@hagata
hagata / accessibility-utils-trap-focus.js
Last active October 23, 2020 00:15
Object based accessibility-utils file for managing and traping focus within a given dialog or modal box. Also includes a handy escape handler.
const accessibilityUtils = {
/**
* string list of selectors that are valid types that can be focused on.
* Used in querySelectorAll to create a NodeList of child elements within
* intended element to trap focus (the parent)
*/
focusableElements: 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',
/**
* Local context for mounting Nodes to be referenced when the handler is
@mixin font-family($name) {
@font-face {
font-family: #{$name};
src:url("./Fonts/#{$name}.otf");
src:url("/Static/Core/Fonts/#{$name}.eot");
src:url("/Static/Core/Fonts/#{$name}.eot?#iefix") format("embedded-opentype"),
url("/Static/Core/Fonts/#{$name}.woff") format("woff"),
url("/Static/Core/Fonts/#{$name}.ttf") format("truetype");
font-weight: normal; //optionally add in the default font styles
font-style: normal;
@hagata
hagata / module-loader.js
Last active March 24, 2017 23:22
Basic Module/Component loader. Starts up new instances of classes based on data attributes on elements in the DOM.
import {exampleModue} from '../modules/exampleModue';
const modules = {
exampleModue: exampleModue
};
function loadModules() {
const moduleNodes = document.querySelectorAll('[data-component]');
console.log('Loading', modules);
@hagata
hagata / basic-go-gin-server.go
Created November 8, 2016 03:32
The minimum setup for a simple HTML server with GO + Gin.
// Assumes a directory structure like the following.
// ├── app.go
// └── src
// ├── css
// │   └── global.css
// ├── index.html
// └── js
package main
@hagata
hagata / docker-makefile
Created October 25, 2016 13:18
Simple Makefile for Docker container starting, stopping, and entering an interactive shell
current_dir = $(shell pwd)
IMAGE = hagata/basic-box
CONTAINER = -any-container-name
VOLUMES ?= -v $(current_dir)/:/app
# RUN_PORTS = -p 8080:8080 \
# -p 8000:8000
#pull the latest image, and start a container.
start:
@hagata
hagata / helpers.dom.js
Created September 3, 2016 05:33
es6 dom util functions module (export opject)
/**
* Utility functions for common dom operations.
*/
const dom = {
/**
* Gets closest ancestor element with matching class.
* ref: http://stackoverflow.com/questions/22119673/find-the-closest-ancestor-element-that-has-a-specific-class
*
* @param {Node} el Root note to begin search.
* @param {String} cls Class to match.
@hagata
hagata / pubsub.js
Last active September 3, 2016 04:38
Simple es6 flavored PubSub Class. Exports a pubsub "singleton" for shared access app wide.
class PubSub {
constructor(params) {
this.subscriptions_ = {};
}
/**
* Publishes a Topic. If the topic exists in the PubSub subscriptions, the
* corresponding function will be invoked
*
* @param {String} topic Topic to publish.
@hagata
hagata / Multiple XMLHttpRequest Promises
Created December 9, 2015 05:15
Written in a little bit of ES6. A class that has a few methods including a couple that are resposible for creating multiple XMLHttpRequests and returning ONLY when they are all complete with Promises.all([…])
'use strict';
/**
* Testing multiple promises for Promise.all([…]).then callback
*/
class Prom {
constructor(name) {
this.name = name;
this.promises = [];
}
@hagata
hagata / gist:026de9d52d91564bd5c5
Created October 26, 2015 05:41
Docker CLI shortcuts
alias dk="docker"
# Start up docker Daemon shortcut
docker-env(){
eval $(docker-machine env $1)
}