Skip to content

Instantly share code, notes, and snippets.

View yao3060's full-sized avatar

YAOYINGYING yao3060

View GitHub Profile
@yao3060
yao3060 / content_img_filter.php
Last active August 29, 2015 14:06
Reduces size of images in posts using bfi_thumb
<?php
require_once('BFI_Thumb.php');
add_filter( 'the_content', 'itc_the_content_img_filter', 999 );
/**
* Reduces size of images in posts using bfi_thumb
*
*/
function itc_the_content_img_filter( $content ) {
/* Add here the width you prefer (max width of your posts) */
@yao3060
yao3060 / wpml_appendto_primary_menu.php
Created September 18, 2014 02:31
Append custom WPML switcher to primary menu.
<?php
add_filter('wp_nav_menu_items', 'itc_wp_nav_menu_items_filter', 10, 2);
function itc_wp_nav_menu_items_filter($items, $args){
if($args->theme_location == 'primary'){
$items .= '<li class="menu-item menu-item-language menu-item-language-current">';
$items .= itc_icl_post_languages();
$items .= '</li>';
return $items;
@yao3060
yao3060 / gist:3650568
Created September 6, 2012 03:13
Javascript Field Valid
function isEmail(str){
var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
return reg.test(str);
}
function IsNumeric(input)
{
return (input - 0) == input && input.length > 0;
}
@yao3060
yao3060 / gist:3650850
Created September 6, 2012 03:35
Wp PageNavi
<?php if(function_exists('wp_pagenavi')) { // if PageNavi is activated ?>
<?php wp_pagenavi(); // Use PageNavi ?>
<?php } else { // Otherwise, use traditional Navigation ?>
<?php if ( get_next_posts_link() ) : ?>
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'glasses' ) ); ?></div>
<?php endif; ?>
@yao3060
yao3060 / gist:3650732
Created September 6, 2012 03:26
CSS snippets
/*opacity-hack*/
selector {
filter: alpha(opacity=60); /* MSIE/PC */
-moz-opacity: 0.6; /* Mozilla 1.6 and older */
opacity: 0.6;
}
/* clear float */
.clear {
@yao3060
yao3060 / gist:3650692
Created September 6, 2012 03:23
.htaccess force-www
# force www in url
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# END force www in url
Report
@yao3060
yao3060 / gist:3651021
Created September 6, 2012 03:55
Get Featured Image with timthumb
<?php
$w = '350';
$h = '200';
if (has_post_thumbnail()) {
$large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
echo '<img class="wp-post-image" src="' . get_bloginfo("template_url") . '/timthumb.php?src=' . $large_image_url[0] . '&w=' . $w . '&h=' . $h . '" alt="' . get_the_title() . '" title="#htmlcaption' . get_the_ID() . '" /></a>';
} else {
echo '<img src="http://fakeimg.pl/350x200/?text=NoPictrue&font=lobster" alt="no pictrue" />';
}
?>
@yao3060
yao3060 / my-theme-options.php
Created February 25, 2013 08:07
My Wordpress theme options - 我正常用的主题设置的拓展页面
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
add_action('admin_menu', 'my_theme_options_menu');
function my_theme_options_menu() {
add_action('admin_print_scripts', 'my_options_admin_scripts');
add_action('admin_print_styles', 'my_options__admin_styles');
## Logs
```
kubectl logs my-pod # dump pod logs (stdout)
kubectl logs -l name=myLabel # dump pod logs, with label name=myLabel (stdout)
kubectl logs my-pod --previous # dump pod logs (stdout) for a previous instantiation of a container
kubectl logs my-pod -c my-container # dump pod container logs (stdout, multi-container case)
kubectl logs -l name=myLabel -c my-container # dump pod logs, with label name=myLabel (stdout)
kubectl logs my-pod -c my-container --previous # dump pod container logs (stdout, multi-container case) for a previous instantiation of a container
@yao3060
yao3060 / Simple Tic Tac Toe Game By React
Created October 17, 2022 11:46
Simple Tic Tac Toe Game By React
import React, { useState, useContext, createContext } from 'react';
import ReactDOM from 'react-dom';
function log(...str){
console.log(...str)
}
const rowStyle = {
display: 'flex'
}