This file contains 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
Reference: http://www.regular-expressions.info/ | |
Email validation | |
^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$ |
This file contains 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
/* | |
Edit Page Customization | |
Customizable: | |
Column Head (filter: manage_posts_columns => manage_{$post_type}_columns ) | |
Column Contents (filter: manage_posts_custom_column => manage_{$post_type}_custom_column) | |
Function link (called $views) | |
Version Tested: 3.8 | |
*/ |
This file contains 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
// foreach by default is using value after "as" | |
foreach( $num_posts as $value ): | |
// echo $value."<br>"; | |
endforeach; | |
// using foreach with key instead of value | |
foreach( array_keys( $num_posts ) as $key ): |
This file contains 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
// valid outside the loop | |
$page_object = get_queried_object(); | |
$page_id = get_queried_object_id(); | |
$ID = get_the_ID(); //get the post ID | |
$post = get_post( $ID )->post_content; // default is post object | |
// var_dump( get_post( $post->post_content ) ); |
This file contains 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
/* | |
fallback order: | |
use post thumbnail(featured post) if available, otherwise | |
use first attachment image if available, otherwise | |
use first image link if available, otherwise | |
stay blank... | |
*/ | |
// inside a loop |
This file contains 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
// redirect to somewhere else if calling path is not valid(as expected) | |
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; | |
DEFINE('HTTP_ROOT', $_SERVER['HTTP_HOST']); | |
$path_arr = explode("/", $_SERVER['REQUEST_URI']); | |
$url_chk = in_array("path-name", $path_arr); | |
$location = $protocol . HTTP_ROOT . '/somewhere-to-redirect/'; | |
if( !$url_chk ) header("Location: $location"); | |
This file contains 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
<link rel="import" href="../topeka-elements/category-images.html"> | |
<link rel="import" href="../core-icon/core-icon.html"> | |
<link rel="import" href="../core-icons/core-icons.html"> | |
<link rel="import" href="../core-icons/av-icons.html"> | |
<link rel="import" href="../paper-fab/paper-fab.html"> | |
<link rel="import" href="../paper-calculator/paper-calculator.html"> | |
<polymer-element name="my-element"> | |
<template> |
This file contains 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
/* | |
Last updated: 2016/Sep/08 | |
step to fetch data from instagram api | |
1. Register account in instagram | |
2. Go to API section (since the footer is not fixed at the bottom, one must go to Edit Profile and go to API link at the bottom. | |
3. Manage Clients > Register a New Client | |
4. Go to Security Tab inside the New Client | |
5. add URIs for redirect, only allowed URIs can fetch the access token (URIs can include .html) | |
6. use this url to get access token: | |
https://www.instagram.com/oauth/authorize/?client_id=CLIENT_ID&redirect_uri=ALLOWED_URIs&response_type=token&scope=public_content |
This file contains 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. use Apps like Sim Manager to verify if there is any message or contact in the sim cards | |
*remember Android can only read Sim Card other than Airplane mode | |
2. if there is message -> go to Messaging -> Settings -> Manage Sim Card Messages, copy to device for backup later | |
if there is contact -> go to Contact -> Settings -> Contact to display to display Sim Card only contacts | |
3. Install tools like https://www.wandoujia.com/### | |
4. Connect the device | |
5. Go to contact -> select Sim Card only in the top right selection -> Select All -> Export -> Select Format -> Save | |
6. Since message is in device, can be exported together if there is no need to split them to backup separately. | |
This file contains 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
@echo off | |
rem for Windows environment | |
rem after installing imageMagick in windows | |
rem convert interlace *.jpg to progressive *.jpg in current folder | |
rem for /r %%i in (*) do magick convert -interlace Plane %%i %%~na | |
rem for /r %%a in (*.jpg) do echo "%%~na.jpg" | |
for /r %%a in (*.jpg) do magick convert -interlace Plane "%%~na.jpg" "%%~na.jpg" |