Skip to content

Instantly share code, notes, and snippets.

@yuqianma
yuqianma / font-test-quxian-names.html
Last active April 24, 2021 17:09
Test Chinese county name characters in font file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Font Test</title>
<link rel="stylesheet" href="adobe-blank.css">
<style>
@font-face {
font-family: 'zcoolwenyiti';
@yuqianma
yuqianma / param.json
Created November 14, 2018 14:19
gpslogger
{
"time": {
"__type": "Date",
"iso": "%TIME"
},
"latlng": {
"__type": "GeoPoint",
"latitude": %LAT,
"longitude": %LON
},
@yuqianma
yuqianma / GestureMouse.js
Last active June 21, 2022 03:15
zrender custom gesture pan. The element can be panned outside the canvas.
import HandlerProxy from 'zrender/src/dom/HandlerProxy';
// You can also use the `addEventListener` to implement the `docHandlerProxy.on` below
// There's no much difference.
const param = target => ({target});
export default function GestureMouse (handler) {
let checkingTarget = null,
panningTarget = null;
const docHandlerProxy = new HandlerProxy(document);
@yuqianma
yuqianma / .block
Last active December 11, 2017 01:12 — forked from mbostock/.block
Collision Detection
license: gpl-3.0
height: 960
@yuqianma
yuqianma / README.md
Last active December 8, 2017 18:14 — forked from pbogden/README.md
Clustered Force Layout v4
@yuqianma
yuqianma / piTemp.py
Last active September 9, 2017 14:30
raspberry pi temperature
#!/usr/bin/env python
import os
# Return CPU temperature as a character string
def getCPUtemperature():
res = os.popen('vcgencmd measure_temp').readline()
return(res.replace("temp=",""))
# Return RAM information (unit=kb) in a list
# Index 0: total RAM
@yuqianma
yuqianma / noCircularJson.js
Created May 8, 2017 08:07
[noCircularJson.js]
function jsonStringify (obj) {
var cache = []
function filter (key, value) {
if (typeof value === 'object' && value != null) {
if (cache.includes(value)) {
return // may circular
}
cache.push(value)
}
return value
@yuqianma
yuqianma / flask_crossdomain.py
Created April 29, 2017 08:50
Flask crossdomain
from datetime import timedelta
from flask import make_response, request, current_app
from functools import update_wrapper
# replaced 'basestring' width 'str' for python3
def crossdomain(origin=None, methods=None, headers=None,
max_age=21600, attach_to_all=True,
automatic_options=True):
if methods is not None:
@yuqianma
yuqianma / parseUrl.js
Last active April 7, 2017 07:15
[parse url] hash search url
// parseSearch('?gws_rd=ssl')
// {gws_rd: "ssl"}
function parseSearch (str) {
str = str.split('?').pop()
var search = {}
str && str.replace(
/([^?=&]+)(=([^&]*))?/g,
function ($0, $1, $2, $3) {
search[ $1 ] = $3
@yuqianma
yuqianma / phantomjs-process.js
Created March 30, 2017 19:18
phantomjs child process exp
var system = require('system'),
fs = require('fs'),
process = require("child_process");
var children = {};
var port = system.args[1];
var isParent = system.args[2];
console.log('[process] port:', port);