Skip to content

Instantly share code, notes, and snippets.

@hideack
hideack / fix.php
Last active October 3, 2020 08:44
<?php
add_action('parse_query', 'date_base_permalink');
function date_base_permalink($wp_query) {
$q = (object)$wp_query->query_vars;
if (!empty($q->year) && !empty($q->monthnum) && !empty($q->day) && !empty($q->minute) && !empty($q->hour)) {
$wp_query->is_single = true;
$wp_query->is_singular = true;
$wp_query->is_archive = false;
// Setup
const {WebClient} = require("@slack/client");
const web = new WebClient(token, {logLevel: "error"});
web.users.list().then((response) => {
response.members.forEach((v, i) => {
// Slackの参加者にまつわる諸々
});
return web.channels.list();
// test/foo.test.js
var should = require('should');
function Foo() {
return {
hoge: function(val) {
if (val == '') {
throw new Error('fail');
}
return val;
@hideack
hideack / region.js
Created August 30, 2020 00:59
ip-api.com を利用した所在地取得
function getRegionName(ip) {
var cache = CacheService.getPublicCache();
var cacheKey = "api:ip-api.com:" + ip;
var region = cache.get(cacheKey);
if (region == null) {
var geo = UrlFetchApp.fetch("http://ip-api.com/json/" + ip).getContentText();
region = JSON.parse(geo).regionName;
cache.put(cacheKey, region, 60 * 60 * 8);
catch :loop do
foo.each do |onefoo|
bar.each do |onebar|
# いろいろ処理
throw :loop if count > 5
end
end
end
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=EUC-JP" />
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript">
//<![CDATA[
function addItem(){
$('area1').innerHTML = "<div id='add1'>加えられました</div>";
}
function changeStyle(){
before_fork do |server, worker|
ENV['BUNDLE_GEMFILE'] = "#{pj_root_dir}/current/Gemfile"
# The following is only recommended for memory/DB-constrained
# installations. It is not needed if your system can house
# twice as many worker_processes as you have configured.
#
# # This allows a new master process to incrementally
# # phase out the old master process with SIGTTOU to avoid a
# # thundering herd (especially in the "preload_app false" case)
# # when doing a transparent upgrade. The last worker spawned
<?php
function change_title_tag( $title ) {
//条件分岐タグ等を使ってページにより $title を変更する処理
if (is_date()) {
$title = get_the_title($title) . " | " . get_bloginfo('name');
}
return $title;
}
add_filter( 'pre_get_document_title', 'change_title_tag' );
var pHash = require("phash");
var samples = [
"samples/lena.jpg",
"samples/lena-small.jpg",
"samples/lena-sepia.jpg",
"samples/lena-mosaic.jpg",
"samples/lena-cut.jpg",
"samples/lena-cut2.jpg",
"samples/lena-horizonal-flip.jpg"
// api.shop-pro.jp で表示された内容を設定
var CLIENT_ID = '*****';
var CLIENT_SECRET = '*****';
function getOAuthService() {
return OAuth2.createService('colormeshop')
.setAuthorizationBaseUrl('https://api.shop-pro.jp/oauth/authorize')
.setTokenUrl('https://api.shop-pro.jp/oauth/token')
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)