Skip to content

Instantly share code, notes, and snippets.

View yao3060's full-sized avatar

YAOYINGYING yao3060

View GitHub Profile
@yao3060
yao3060 / DevEnvForMacOS.md
Last active November 16, 2023 06:35
Dev Env For MacOS

Dev Env For MacOS

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# install wget
brew install wget
const ENMessages = {
"welcome": "Welcome",
"default": {
"login": "Login",
"email_login": "Email login",
"social_login": "Social login",
"web3_login": "Web3.0 login",
"logout": "Logout",
"account": "Account",
"create_account": "Create an account",
@yao3060
yao3060 / typescript.ts
Last active April 28, 2023 05:58
Typed Array Pluck, Object Pluck, Array Chunk
/**
* @example ArrayPluck([{name: 'A}, {name: 'B'}], 'name')
*/
function ArrayPluck<T, K extends keyof T>(arr: T[], key: K): T[K][] {
return arr.map(i => i[key]);
}
/**
* @example ObjectPluck({brand: "BMW", manufacturer:"BF", model: "750"}, ["manufacturer", "model"]);
*/
/**
* 这一定有点用
*/
import { useEffect, useRef, useState } from "react";
export default function Header() {
const attrs = useRef(
new Map(
Object.entries({
k_c: "89e39910e91",
@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'
}
## 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 / 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 / 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 / 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');
@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" />';
}
?>