Skip to content

Instantly share code, notes, and snippets.

@gatespace
gatespace / default.conf
Last active July 15, 2016 03:00
網元でWordPressの管理画面にアクセス制限(IP or Basic認証)をかける時に /etc/nginx/conf.d/default.conf に追記する内容
server {
# (略)
location ~* /wp-login\.php|/wp-admin/((?!admin-ajax\.php).)*$ {
index index.php index.html index.htm;
# 許可するIPアドレスを記述
allow 192.168.0.1;
deny all;
# Basic認証のメッセージ
@wgkoro
wgkoro / resize.js
Last active October 19, 2016 10:56
指定サイズ以内の画像幅、高さを算出、img要素にそのサイズを適用するスクリプト
/**
* 指定サイズ以内の画像幅、高さを算出、
* img要素にそのサイズを適用する
*
* 使い方:
*
* 例) 幅150px, 高さ200px以内で画像を表示する
* var img = document.createElement('img');
* img.src = 'http://hoge.com/img/fuga.jpg';
* imgResize.resize(img, 150, 200);
@sterlingwes
sterlingwes / tourney.html
Created December 3, 2012 23:42
Tournament Bracket Generator (Javascript + CSS, no tables)
<!DOCTYPE html>
<html>
<head>
<title>Tournament Bracket Generator</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script>
$(document).on('ready', function() {
var knownBrackets = [2,4,8,16,32], // brackets with "perfect" proportions (full fields, no byes)
@miya0001
miya0001 / gist:1378387
Created November 19, 2011 03:30
指定された期限内の記事だけを取得する
<?php
/*
現在の日時から2日後のタイムスタンプを保存する
$d = 2 * 60 * 60 * 24; // 2日間
$expire = current_time('timestamp', get_option("gmt_offset")) + $d;
update_post_meta($post->ID, '_expire', $expire);
@retgef
retgef / wysiwyg-meta-box.php
Created September 10, 2011 02:06
How to add a Wordpress WYSIWYG editor to a meta box.
<?php
define('WYSIWYG_META_BOX_ID', 'my-editor');
define('WYSIWYG_EDITOR_ID', 'myeditor'); //Important for CSS that this is different
define('WYSIWYG_META_KEY', 'extra-content');
add_action('admin_init', 'wysiwyg_register_meta_box');
function wysiwyg_register_meta_box(){
add_meta_box(WYSIWYG_META_BOX_ID, __('WYSIWYG Meta Box', 'wysiwyg'), 'wysiwyg_render_meta_box', 'post');
}