Skip to content

Instantly share code, notes, and snippets.

View torounit's full-sized avatar

Hiroshi Urabe torounit

View GitHub Profile
@helgatheviking
helgatheviking / wordpress-add-custom-menu-meta-fields.php
Created February 26, 2020 02:06
Add an example custom meta field to WordPress menu and display text on front-end (Requires WP5.4)
<?php
/**
* Add custom fields to menu item
*
* This will allow us to play nicely with any other plugin that is adding the same hook
*
* @param int $item_id
* @params obj $item - the menu item
* @params array $args
@torounit
torounit / run-httpd-as-ec2-user.sh
Created November 7, 2019 06:37
amimoto で ec2-user する。
#!/usr/bin/env bash
set -e
echo '{
"nginx" : { "config" : { "user" : "ec2-user" } },
"php" : { "config" : { "user" : "ec2-user" } },
"run_list" : [ "recipe[amimoto]" ]
}' > /opt/local/amimoto.json
/opt/local/provision
@joshangell
joshangell / PhpStorm-and-Gridsome.md
Last active December 21, 2022 10:13
Quick and dirty explanation of how to get autocomplete, syntax highlighting etc when using Gridsome in PhpStorm.

PhpStorm

  1. Make sure your gridsome dev server is running: cd frontend and then yarn dev or npm run dev
  2. Install JS GraphQL plugin: https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
  3. Select everything inside <page-query>, click the light bulb icon, choose "Inject language or reference" and select GraphQL, like this:

NOTE: you only have to do this once and then all your .vue files will support GraphQL queries inside <page-query> tags.

@maepon
maepon / zoomup201810.md
Last active October 11, 2018 13:54
#2 WP ZoomUP 前川昌幸『2018年のフロントエンドのトレンドから見るコーディング事情』

Time Travel Debugging

Time Travel refers to the ability to record a tab and later replay it ([WebReplay][wrr]). The technology is useful for local development, where you might want to:

  • pause and step forwards or backwards
  • pause and rewind to a prior state
  • rewind to the time a console message was logged
  • rewind to the time an element had a certain style or layout
  • rewind to the time a network asset loaded
@teppeis
teppeis / es-class-fields.md
Last active March 13, 2022 13:57
ES Class Fieldsのプライベートフィールドがハッシュな変態記法なのは何でなんだぜ?

ES Class Fields (Stage 2 now)

プライベートフィールドがハッシュな変態記法なのは何でなんだぜ?

class Point {
    #x;
    #y;
 constructor(x = 0, y = 0) {
@tanshio
tanshio / search-page.php
Last active August 31, 2017 14:18
20170624
<?php
/*
Template Name: インクリメンタルサーチページ
*/
?>
<?php get_header(); ?>
<h1>インクリメンタルサーチ</h1>
@hissy
hissy / HOWTOUSE.md
Created January 31, 2017 16:18
[WordPress] Extended WP_Query implements Iterator
<?php
$args = ['post_type' => 'post'];
foreach((new Iterative_WP_Query($args)) as $post_id => $post) {
	echo get_the_title($post_id);
}
@rmarchei
rmarchei / route53.py
Last active June 16, 2022 04:11
route53 hook for dehydrated - python2 / python3 + boto2 version. Tested on Ubuntu 16.04
#!/usr/bin/env python
# How to use:
#
# Ubuntu 16.04: apt install -y python-boto OR apt install -y python3-boto
#
# Specify the default profile on aws/boto profile files or use the optional AWS_PROFILE env var:
# AWS_PROFILE=example ./dehydrated -c -d example.com -t dns-01 -k /etc/dehydrated/hooks/route53.py
#
# Manually specify hosted zone:
<?php
function test($init, $key = 'a')
{
$var = $init;
$var[$key] = 1;
echo var_export($init, true), ': ', is_array($var) ? 1 : 0, "\n";
}
test(null); // OK