Skip to content

Instantly share code, notes, and snippets.

View xingmolu's full-sized avatar
👋

xingmolu

👋
View GitHub Profile
@xingmolu
xingmolu / iframe.js
Created August 4, 2017 07:26 — forked from nsisodiya/iframe.js
Dynamic IFRAME Using Dynamic Document Fragment when html & css are provided as Strings
var html = '<h1 class="nar">Narendra</div>';
var css = '.nar { color: red; background: url("http://google.com/images/google_favicon_128.png") repeat scroll 0 0 transparent;}';
var nodeWhereToAppend = document.body;
//var nodeWhereToAppend = document.getElementById("container");
function CreateIframe(html, css, nodeWhereToAppend){
var fragment = document.createDocumentFragment();
var iframe = document.createElement('iframe');
iframe.onload = function(){
var doc = this.contentWindow.document;
@xingmolu
xingmolu / Laravel_validation.php
Created May 7, 2017 04:11
Localization Validation Message For Chineses With Laravel 5
<?php
return [
'unique' => ':attribute 已存在',
'accepted' => ':attribute 是被接受的',
'active_url' => ':attribute 必须是一个合法的 URL',
'after' => ':attribute 必须是 :date 之后的一个日期',
'alpha' => ':attribute 必须全部由字母字符构成。',
'alpha_dash' => ':attribute 必须全部由字母、数字、中划线或下划线字符构成',
@xingmolu
xingmolu / getCh.html
Created September 21, 2014 00:48
获取汉字的简拼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>汉字简拼</title>
@xingmolu
xingmolu / direction
Created April 17, 2014 11:34
判断鼠标从什么方向进入容器
$("#wrap").bind("mouseenter,mouseleave", function() {
var w = $(this).width();
var he = $(this).height();
var x = (e.pageX - this.offsetLeft - (w / 2)) * (w > h ? (h / w) : 1);
var y = (e.pageY - this.offsetTop - (h / 2)) * (h > w ? (w / h) : 1);
var direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4; // direction的值为"0,1,2,3" 分别对应着"上右下左"
});
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta content="yes" name="apple-mobile-web-app-capable">
<title>iOS Web App</title>
<!-- iPhone -->
var SHAKE_THRESHOLD = xxx;
var last_update = 0;
var x, y, z, last_x, last_y, last_z;
function deviceMotionHandler(eventData) {
var acceleration =eventData.accelerationIncludingGravity;
var curTime = newDate().getTime();
if ((curTime - lastUpdate)> 100) {