Skip to content

Instantly share code, notes, and snippets.

@yaquawa
yaquawa / cp.sh
Created June 26, 2021 18:11
copy except ...
cp -R $(ls | grep -v -e XXX -e YYY) ZZZ/
@yaquawa
yaquawa / propagate_iframe_click_event.js
Created August 9, 2019 06:51
Propagate iframe click event
// Click event happened in iframe won't propagate to the containing element of it.
// This script provides a workaround to simulate the propagation of click event of iframe.
//
// inspired by https://gist.github.com/jaydson/1780598#gistcomment-2609301
(function ($) {
var selector = '[data-event-category][data-event-action]';
var $elementsContainIframe = $(selector).filter(function () {
return $(this).find('iframe,script').length;
@yaquawa
yaquawa / fluid_ad.js
Last active September 21, 2020 08:39
Fluid Ad
/*
# Usage
1. Place this script anywhere after your gpt tag.
2. Add class `js-gpt-fluid-size` to your slot element.
# Notice
This script require jQuery to be installed,
but you can place this script before jQuery if you want.
*/
@yaquawa
yaquawa / constant-lookup.md
Created July 7, 2019 09:47
Decode Ruby's constant lookup with example
module Kernel
# Constants defined in Kernel
  A = B = C = D = E = F = "defined in kernel"
end

# Top-level or "global" constants defined in Object
A = B = C = D = E = "defined at toplevel"

class Super
@yaquawa
yaquawa / singleton-class.md
Last active July 7, 2019 08:37
Decode Ruby's `Singleton-Class` with example

The singleton methods of an object are not defined by the class of that object. But they are methods and they must be associated with a class of some sort. The singleton methods of an object are instance methods of the anonymous singleton-class(eigenclass) associated with that object.

To open the singleton-class of the object obj, use class << obj

class Object
  # Get the singleton-class object of a class object. 
  def singleton_class
@yaquawa
yaquawa / Simple-Sharing-Buttons.md
Last active May 20, 2020 00:35
Simple Sharing Buttons

Twitter

https://twitter.com/share?url=[URL]&text=[TEXT]&related=[USER-NAME]

Facebook

https://www.facebook.com/share.php?u=[URL]

Hatena

https://b.hatena.ne.jp/entry/[URL]

LINE

@yaquawa
yaquawa / migration.sql
Created March 5, 2017 07:31
WordPress database migration SQL
UPDATE wp_options SET option_value = replace(option_value, 'http://OLD', 'https://NEW') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://OLD','https://NEW');
UPDATE wp_posts SET post_content = replace(post_content, 'http://OLD', 'https://NEW');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://OLD','https://NEW');
@mixin responsive-property($max-amount,$min-amount,$max-viewport-width,$min-viewport-width,$properties) {
@media (min-width: $min-viewport-width) {
& {
$amount-difference: $max-amount - $min-amount;
$viewport-width-difference: $max-viewport-width - $min-viewport-width;
@each $property in $properties {
#{$property}: calc(#{$min-amount} + ((1vw - #{$min-viewport-width / 100}) * #{100 * $amount-difference / $viewport-width-difference}));
}
}
}
@mixin responsive-font-size($max-font-size,$min-font-size,$max-viewport-width,$min-viewport-width) {
@media (min-width: $min-viewport-width) {
:root {
$font-size-difference: $max-font-size - $min-font-size;
$viewport-width-difference: $max-viewport-width - $min-viewport-width;
font-size: calc(100% + ((1vw - #{$min-viewport-width / 100}) * #{100 * $font-size-difference / $viewport-width-difference}));
}
}
// Stop font scaling above $max-viewport-width
@yaquawa
yaquawa / functions.php
Last active August 5, 2016 03:27
Change the number of posts per page in the admin panel
$post_type = 'your-post-type';
add_filter("edit_{$post_type}_per_page", function ($posts_per_page) {
return 999;
});
// Search `edit_{$post_type}_per_page` in `wp-admin/includes/post.php` for more infomation.