Skip to content

Instantly share code, notes, and snippets.

@tonyanhq
tonyanhq / gist:348aa880ddbcc0e0b9ad994e62f1206b
Created March 31, 2017 09:36 — forked from kiwiholmberg/gist:8433478
Make a JSON array of state capitals with coordinates (data from different sources)
<p class="results"></p>
<ol>
<li>
<p>Name: Alabama</p>
<p>Capital Name: Montgomery</p>
<p>Capital Latitude: 32.361538</p>
<p>Capital Longitude: -86.279118</p>
</li>
<li>
<p>Name: Alaska</p>
@tonyanhq
tonyanhq / get_translated_media_or_original.php
Created March 30, 2017 08:50 — forked from chodorowicz/get_translated_media_or_original.php
get file media file in current language, if it doesn't exist get original version
<?php
if (!function_exists('get_translated_media_or_original')) {
function get_translated_media_or_original($media_file_id) {
global $wpdb;
// check language of media file
$custom_query = "SELECT * FROM ".$wpdb->postmeta." WHERE meta_key='wpml_media_lang' AND post_id=".$wpdb->escape($media_file_id);
$meta = $wpdb->get_results( $custom_query );
$media_file_language = $meta[0]->meta_value;
// if language of media file equals current language, return that id
if($media_file_language == ICL_LANGUAGE_CODE) {
@tonyanhq
tonyanhq / autoplay-audio-ios.html
Created March 7, 2017 05:48 — forked from ufologist/autoplay-audio-ios.html
在 iOS 微信浏览器中自动播放 HTML5 audio(音乐) 的正确方式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>Auto play html audio in iOS WeChat InAppBrowser the right way</title>
</head>
<body>
<h1>在 iOS 微信浏览器中自动播放 HTML5 audio(音乐) 的正确方式</h1>
<p>核心原理: 在微信的JS-API 中 play 一下 audio 即可达到自动播放的目的(应该是微信自己做了处理)</p>
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('load-grunt-tasks')(grunt);
//MODIFIED: add require for connect-modewrite
var modRewrite = require('connect-modrewrite');
grunt.initConfig({