Skip to content

Instantly share code, notes, and snippets.

View CodeDreamfy's full-sized avatar
💭
I may be slow to respond.

CodeDreamfy CodeDreamfy

💭
I may be slow to respond.
View GitHub Profile
@CodeDreamfy
CodeDreamfy / autoplay-audio-ios.html
Created May 25, 2016 06:27 — 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>
@CodeDreamfy
CodeDreamfy / adaptUILayout.js
Created November 17, 2016 17:00 — forked from ijse/adaptUILayout.js
adaptUILayout
/*
* 使用说明:
* 本程序以完成固定宽度布局的网页在iPhone/Android设备上浏览时可以适配设备屏幕宽度(竖屏浏览, 暂未支持横屏浏览)
* 为目的。正常运行的环境是: iPhone/Android设备的自带浏览器.
* 如有问题,意见或建议,请到我的博客页面留言,或发送邮件.
* 其他移动版浏览器的适配问题, 不在本程序处理范围, 若有相关问题, 请留言或发送邮件.
*
* 博客页面地址:
* http://www.cnblogs.com/plums/archive/2013/01/10/WebApp-fixed-width-layout-of-multi-terminal-adapter-since.html
* 邮箱: limuchen12@126.com
@CodeDreamfy
CodeDreamfy / git-flow.md
Created June 19, 2017 07:22 — forked from yesmeck/git-flow.md
Git 开发流程

Git 协作流程

master 分支

master 永远处于稳定状态,这个分支代码可以随时用来部署。不允许在该分支直接提交代码。

develop 分支

开发分支,包含了项目最新的功能和代码,所有开发都在 develop 上进行。一般情况下小的修改直接在这个分支上提交代码。

@CodeDreamfy
CodeDreamfy / git-stash.md
Created June 22, 2017 05:49 — forked from subchen/git-stash.md
Git Stash 用法

git stash用于保存和恢复工作进度

  • git stash

    保存当前的工作进度。会分别对暂存区和工作区的状态进行保存

  • git stash save "message..."

这条命令实际上是第一条 git stash 命令的完整版

@CodeDreamfy
CodeDreamfy / make_writable.js
Created July 7, 2017 05:49 — forked from moehlone/make_writable.js
Make JavaScript readonly propertys writable (example for overwriting navigator.userAgent; useful for unit tests -> browser detection)
/**
* Creates a read/writable property which returns a function set for write/set (assignment)
* and read/get access on a variable
*
* @param {Any} value initial value of the property
*/
function createProperty(value) {
var _value = value;
/**
@CodeDreamfy
CodeDreamfy / visible_area.js
Created September 7, 2017 08:19 — forked from simplelife7/visible_area.js
【JS】判断元素是否在可视区域内
var a = document.getElementById("eq").offsetTop;
if (a >= $(window).scrollTop() && a < ($(window).scrollTop()+$(window).height())) {
alert("div在可视范围");
}
@CodeDreamfy
CodeDreamfy / multiple_ssh_setting.md
Created November 29, 2017 01:34 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@CodeDreamfy
CodeDreamfy / js
Created September 4, 2018 11:08 — forked from hugohu/js
JavaScript获取图片的原始尺寸
//HTML5提供了一个新属性naturalWidth/naturalHeight可以直接获取图片的原始宽高。这两个属性在Firefox/Chrome/Safari/Opera及IE9里已经实现。改造下获取图片尺寸的方法。
//http://www.w3.org/TR/2011/WD-html5-author-20110705/the-img-element.html#dom-img-naturalwidth
//http://www.w3.org/TR/2011/WD-html5-author-20110705/the-img-element.html#dom-img-naturalheight
function getImgNaturalDimensions(img, callback) {
var nWidth, nHeight;
if (img.naturalWidth) {
nWidth = img.naturalWidth;
nHeight = img.naturalHeight;
} else {
<script type="text/javascript">
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
if(window.location.href.indexOf("?mobile")<0){
try{
if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
window.location.href="http://shipei.qq.com/index.htm";
}else if(/iPad/i.test(navigator.userAgent)){
}else{
window.location.href="http://shipei.qq.com/simple/s/index/"
}
<script type="text/javascript">
var bForcepc
= fGetQuery("dv") == "pc";
function
fBrowserRedirect(){
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) ==
"ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";