This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// SVGファイルに対応する | |
add_filter( 'upload_mimes', 'my_add_mime_type' ); | |
if( !function_exists('my_add_mime_type') ) { | |
function my_add_mime_type($mime_types) | |
{ | |
$mime_types['svg'] = 'image/svg+xml'; | |
$mime_types['svgz'] = 'image/svg+xml'; | |
return $mime_types; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
### | |
* 色を変換する関数を定義する | |
### | |
hex2rgb = (hexcode) -> | |
# rgbに変換する | |
result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hexcode); | |
if result is null | |
console.log "error!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hex2rgb = (hexcode) -> | |
# rgbに変換する | |
result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hexcode); | |
if result is null | |
console.log "error!" | |
return | |
[r,g,b] = [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)] | |
return [r,g,b] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
* ローソンの店舗情報を1件スクレイピングする | |
### | |
target_url = "http://store.lawson.co.jp" | |
casper = require('casper').create() | |
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36') | |
casper.start target_url | |
# 都道府県リスト表示 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
links = [ | |
'http://google.co.jp/' | |
'http://yahoo.co.jp/' | |
'http://bing.com/' | |
] | |
casper = require('casper').create() | |
# iPhone 6 | |
casper.userAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django import forms | |
from myapp.models import DataGroup # Overwrite this to your model | |
from django.utils.encoding import force_text | |
from django.utils.safestring import mark_safe | |
from django.utils.html import format_html | |
class DataGroupSelect(forms.widgets.Select): | |
def render_option(self, selected_choices, option_value, option_label): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Widgetタイトルを画像に置き換える(タイトル検知版) | |
if( !function_exists('change_widget_title_to_image') ) { | |
function change_widget_title_to_image($params) { | |
// widget-idを、widget名と数字に分ける | |
if(preg_match('/^(?<name>.+)\-(?<key>\d+)$/', $params[0]['widget_id'], $m)) { | |
$option_name = 'widget_' . $m['name']; | |
$widgets = get_option($option_name, array()); | |
$index = intval($m['key']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Widgetタイトルを画像に置き換える | |
if( !function_exists('change_widget_title_to_image') ) { | |
function change_widget_title_to_image($params) { | |
// categories-xxの形式で、画像を挿入する | |
if(preg_match('/^categories-\d+/', $params[0]['widget_id'])) { | |
$params[0]['before_title'] = $params[0]['before_title'].'<img src="'.get_bloginfo('template_url').'/img/categories_2x.png" width="91" height="20" alt="categories" /><span style="display:none;">'; | |
$params[0]['after_title'] = '</span>'.$params[0]['after_title']; | |
} else if ( preg_match('/^recent-posts-\d+/', $params[0]['widget_id']) ) { | |
// recent-posts-xxの形式で、画像を挿入する |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function($) { | |
// 投稿用スクリプト. 見出しにぬこクラス追加 | |
$(".post-content h3").addClass("cat-header1").wrapInner("<span></span>"); | |
// 行数カウントして、ライン幅を補正する | |
function main() { | |
// ぬこクラス | |
$("div.post-content .cat-header1 span").css("line-height", "1em"); | |
$('div.post-content .cat-header1 span').each(function(index) { | |
var header_height = $(this)[0].offsetHeight; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// javascript | |
add_action('wp_head', 'myJavaScript_head', 1); | |
if( !function_exists('myJavaScript_head') ) { | |
function myJavaScript_head() { | |
wp_deregister_script('jquery'); | |
wp_register_script('jquery',get_bloginfo('template_url'). '/js/jquery-1.7.1.min.js'); | |
wp_enqueue_script('jquery'); | |
wp_enqueue_script('pageslide', get_bloginfo('template_url'). '/js/jquery.pageslide.min.js', array('jquery'), false, true); | |
wp_enqueue_script('mypageslide', get_bloginfo('template_url'). '/js/myPageslide.js', array('jquery'), false ,true); |
NewerOlder