Skip to content

Instantly share code, notes, and snippets.

@simongcc
simongcc / wp_mysql_queries.sql
Created January 14, 2014 05:55
Common use MySQL queries for developing Wordpress convenice
Reset positions of metaboxes in admin
SELECT *
FROM `wp_usermeta`
WHERE `user_id` =1
AND `meta_key` LIKE '%meta-box%'
@simongcc
simongcc / common_mysql.sql
Created January 15, 2014 08:54
Common MySQL command for development
#Select desired table and create "drop table" command for the them
SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' )
AS statement FROM information_schema.tables WHERE table_schema = 'SCHEMA_NAME' and table_name LIKE 'SOMETHING%';
Then copy and paste the result to use.
###
@simongcc
simongcc / common_regex.txt
Created January 23, 2014 18:37
Regular expression
Reference: http://www.regular-expressions.info/
Email validation
^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$
/*
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
*/
/*
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
/*
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.
@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"
@echo off
set file=config.rb
set project=%1
set lang=tc
echo( # Ensure UTF-8 css is correctly parsed by Ruby compiler >> %file%
echo(Encoding.default_external = "utf-8" >> %file%
echo( >> %file%
echo(# Require any additional compass plugins here. >> %file%
@echo off
rem Automatically name with timestamp by drag and drop folder or file into this batch file
rem originally refer to some online tutorials, will add back if I find it
rem get local date time
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
rem set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2% %ldt:~8,2%:%ldt:~10,2%:%ldt:~12,6%
set ldt=%ldt:~0,4%%ldt:~4,2%%ldt:~6,2%-%ldt:~8,2%%ldt:~10,2%%ldt:~12,2%
set destination=C:\_Public-Share\_Project_Bak
set destination2=Z:\_Project_Bak
@echo off
rem create compass config.rb and necessary folders
set file=config.rb
set project=%1
set lang=tc
if not exist "_source" mkdir _source
if not exist "%project%/js" mkdir js
if not exist "%project%/%lang%/css" mkdir css
if not exist "%project%/%lang%/img" mkdir img