Skip to content

Instantly share code, notes, and snippets.

View dreamsxin's full-sized avatar

Dreamszhu dreamsxin

View GitHub Profile
@dreamsxin
dreamsxin / 00-jquery.nhpm.js
Created June 3, 2016 03:07 — forked from amcgregor/00-jquery.nhpm.js
Nginx HTTP Push Module adapter for jQuery.
// A jQuery extension to handle Nginx HTTP Push Module (NHPM) communication.
// alice@gothcandy.com -- Copyright (c) 2012 Alice Bevan-McGregor
// Released under an MIT license.
var Channel = function(options) {
this.settings = jQuery.extend({}, Channel.defaults, options);
this.alive = true;
this.failures = 0;
<?php
#source: http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-char
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
function unicode_decode($str) {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
}
<?php
#source: http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-char
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
function unicode_decode($str) {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
}