Skip to content

Instantly share code, notes, and snippets.

View iwatakeshi's full-sized avatar
📚
Always learning

Takeshi iwatakeshi

📚
Always learning
View GitHub Profile
@iwatakeshi
iwatakeshi / useScrollDirection.js
Last active January 9, 2020 19:19 — forked from reecelucas/useScrollDirection.js
React hook to detect scroll direction, based on the API of https://github.com/dollarshaveclub/scrolldir
const SCROLL_UP = 1;
const SCROLL_DOWN = -1;
const useScrollDirection = ({
initialDirection,
thresholdPixels,
off
} = {}) => {
const [scrollDir, setScrollDir] = useState(initialDirection);
@iwatakeshi
iwatakeshi / hide-scroll.css
Created December 21, 2019 23:26
Hide scroll bar on Chrome, IE, and Firefox
.element {
-ms-overflow-style: none; /* Internet Explorer 10+ */
scrollbar-width: none; /* Firefox */
&::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
@iwatakeshi
iwatakeshi / install_tailwind_for_next.md
Last active December 14, 2019 18:18
Install Tailwind for Next.js

Install dependencies

yarn add -D @zeit/next-css postcss-preset-env
yarn add tailwindcss

# or a copy-friendly version
yarn add -D @zeit/next-css postcss-preset-env postcss-easy-import && \
yarn add tailwindcss
@iwatakeshi
iwatakeshi / sanitizeUrl.js
Last active October 4, 2019 18:35
Sanitize Prismic URLs
const hashLink = /(#)([^\s]+)/gi
function isAnchor (url) {
if (!process.client) {
return false
}
if (url) {
if (
url.includes(location.href) &&
hashLink.test(url)
@iwatakeshi
iwatakeshi / settings.json
Created September 28, 2019 21:02
My VScode settings
{
"window.zoomLevel": 3,
"eslint.autoFixOnSave": true,
"eslint.validate": [
{
"language": "vue",
"autoFix": true
},
{
"language": "html",
@iwatakeshi
iwatakeshi / launch.json
Created September 28, 2019 19:47
Nuxt debugger
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "client: chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
@iwatakeshi
iwatakeshi / nginx.conf
Created September 20, 2019 05:33 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@iwatakeshi
iwatakeshi / nginx.conf
Created September 12, 2019 05:59 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
#! /usr/bin/env python
import asyncio
import tldextract
import functools
import os
import click
from urllib.parse import urlparse
from usp.tree import sitemap_tree_for_homepage
from pyppeteer import launch
from functools import wraps
@iwatakeshi
iwatakeshi / responsive-badge.html
Created August 25, 2019 21:37 — forked from ericclemmons/responsive-badge.html
Responsive indicators for TailwindCSS
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/tailwind.min.css">
<!-- Responsive indicators! -->
<div class="fixed top-0 right-0 z-50 bg-pink-500 text-white shadow-md px-2 rounded-bl font-mono">
<span class="sm:hidden">default</span>
<span class="hidden sm:inline md:hidden">sm</span>
<span class="hidden md:inline lg:hidden">md</span>
<span class="hidden lg:inline xl:hidden">lg</span>
<span class="hidden xl:inline">xl</span>
</div>