Skip to content

Instantly share code, notes, and snippets.

View naotone's full-sized avatar
🤓
.•

Naoto Yoshimoto naotone

🤓
.•
View GitHub Profile
@naotone
naotone / maintenance.tsx
Last active October 3, 2023 03:32
Maintenance mode redirection for next.js
import { GetServerSideProps } from 'next'
import React from 'react'
import Head from 'next/head'
import Header from '../components/header'
import Footer from '../components/footer'
const Layout: React.FunctionComponent = () => (
<>
<Head>
<title></title>
@naotone
naotone / script.fql
Created February 12, 2021 00:51
Fauna: Add serial num id to collection
Reduce(
Lambda((acc, value) =>
Let(
{
count: Add(Select("count", acc), 1),
update: Update(value, { data: { id: Var("count") } })
},
{
count: Var("count")
}
@naotone
naotone / ruleset.xml
Last active December 23, 2018 02:24
WordPress-Core-non-Yoda
<?xml version="1.0"?>
<ruleset name="WordPress Core">
<description>Non-controversial generally-agreed upon WordPress Coding Standards</description>
<autoload>./../WordPress/PHPCSAliases.php</autoload>
<!-- Treat all files as UTF-8. -->
<config name="encoding" value="utf-8"/>
<!-- Default tab width for indentation fixes and such. -->
@naotone
naotone / index.js
Created December 14, 2018 03:45
Remove row with matching values from CSV.
const targets = ['aaa@test.test', 'bbb@test.test']
const input = 'data/input.csv'
const fs = require('fs')
const csv = require('csv')
const csvSync = require('csv-parse/lib/sync')
const results = []
const data = fs.readFileSync(input)
const res = csvSync(data)
@naotone
naotone / ResponsiveImages.vue
Last active June 3, 2021 02:20
Vue component for responsive images with Sanity CMS.
<template>
<picture
v-if="devices === '3x'"
:role="role"
>
<source
v-for="(val, key, index) in sizes"
:key="index"
:media="`(min-width: ${val.media}em)`"
:srcset="`
@naotone
naotone / Contract Killer 3.md
Created March 20, 2018 18:13 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

set displays to {}
set newimage to "OS X:Library:Desktop Pictures:Beach.jpg" as alias
tell application "System Events"
set displays to a reference to every desktop
repeat with i from 1 to count of displays
set picture of item i of displays to newimage
end repeat
end tell
@naotone
naotone / README.md
Last active July 16, 2023 18:28
My Macbook settings

OS X For Hackers

Run osxForHackers.sh
System Preferences

  • General
    • Highlight color: Graphite
    • Recent items: 50
  • Mission Control
    • All Hot Croners: Shift + Desktop
  • Security & Privacy
  • Turn on FileVault
@naotone
naotone / wp_search_wpdb_taxonomy_term.php
Created December 3, 2014 15:28
Wordpress search - wpdb taxonomy term
<?php
$search_query = get_search_query();
$results = $wpdb->get_results("SELECT *
FROM $wpdb->terms AS wt
INNER JOIN $wpdb->term_taxonomy AS wtt ON wt.term_id=wtt.term_id
INNER JOIN $wpdb->term_relationships AS wtr ON wtr.term_taxonomy_id=wtt.term_taxonomy_id
LEFT JOIN $wpdb->posts wp ON wp.ID=wtr.object_id
WHERE taxonomy='$taxonomy' AND name LIKE '%%$search_query%%'
" );
@naotone
naotone / setMovIcon.sh
Last active August 29, 2015 14:08
Auto set thumbnail icons to .mov.
#!/bin/sh
# Based on http://stackoverflow.com/questions/8371790/how-to-set-icon-on-file-or-directory-using-cli-on-os-x
# Usage
# cd path/to/moviesAndImagesDir/
# thisFileName.sh ./ [jpg|png]
dirPath=$1
thumbExt=$2
IFS=$'\n'