Skip to content

Instantly share code, notes, and snippets.

xabi wangzhe1995

Block or report user

Report or block wangzhe1995

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Javascript Singleton
var Singleton = (function () {
var instance;
function createInstance() {
var object = new Object("I am the instance");
return object;
}
return {
getInstance: function () {
@wangzhe1995
wangzhe1995 / uilabelheight
Created Dec 29, 2014
计算UILabel的高度
View uilabelheight
/*//创建一个UILabel
var articleLabel:UILabel = UILabel(frame: CGRectMake(20.0, 100.0, self.view.frame.width - 40.0, 0.0));
//设置AttributedText
var attributeString:NSMutableAttributedString = NSMutableAttributedString(string: self.article!);
var style:NSMutableParagraphStyle = NSMutableParagraphStyle();
style.lineSpacing = 5.0;
attributeString.addAttribute(NSParagraphStyleAttributeName, value: style, range: NSMakeRange(0, attributeString.length));
articleLabel.attributedText = attributeString;
@wangzhe1995
wangzhe1995 / gist:ca1e482a2f8ad84ffdcd
Created Jan 13, 2015
在SVG当中添加foreignObject
View gist:ca1e482a2f8ad84ffdcd
var foreignObject = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject' );
var body = document.createElement( 'body' ); // you cannot create bodies with .apend("<body />") for some reason
$(foreignObject).attr("x", 0).attr("y", 0).attr("width", 100).attr("height", 100).append(body);
$(body).append("<div>real auto</div>");
$("#group").append(foreignObject);
@wangzhe1995
wangzhe1995 / gist:8305f3c6e670535cf75f
Last active Aug 29, 2015
计算机圆的X,Y坐标
View gist:8305f3c6e670535cf75f
function createXAxisCategories(){
//计算出弧
var canvas = $('#risk_report_polar_outside')[0];
var context = canvas.getContext('2d');
var width = canvas.width / 2;
var height = canvas.height / 2;
var radius = 230;
for(var i=0;i<categories.length;i++){
View gist:7684b3c11eacaceedf86
var lastPostionY = 0;
var lastPostionX = 0;
var currentPositionY = 0;
var currentPositionX = 0;
var turntableCircleLeft = $('.turntable_circle').offset().left;
var turntableCircleHalfWidth = $('.turntable_circle').width() / 2;
var turntableCircleTop = $('.turntable_circle').offset().top;
var turntableCircleHalfHeight = $('.turntable_circle').height() / 2;
@wangzhe1995
wangzhe1995 / gist:e7a8e63164045d77034f
Created Jan 20, 2015
用来判断,鼠标点击了哪个扇区 (Canvas)
View gist:e7a8e63164045d77034f
$('#circle').on('touchstart',function(event){
//需要先判断点击了哪个扇区的位置
var x = event.originalEvent.touches[0].pageX - $('#circle')[0].getBoundingClientRect().left - 200;
var y = event.originalEvent.touches[0].pageY - $('#circle')[0].getBoundingClientRect().top - 200;
var anglePosition = Math.atan2(y,x);
var angle = 90 - anglePosition * (180/Math.PI);
@wangzhe1995
wangzhe1995 / less
Created Jul 13, 2015
666的Less代码
View less
.desktop-and-old-ie(@rules) {
@media screen and (min-width: 1200) { @rules(); }
html.lt-ie9 & { @rules(); }
}
header {
background-color: blue;
.desktop-and-old-ie({
background-color: red;
View gist:658b06e67c4f8af29cc53797f4a9fec4
function generationGrid() {
var size = 500, step = 50;
var geometry = new THREE.Geometry();
for (var i = - size; i <= size; i += step) {
geometry.vertices.push(new THREE.Vector3( - size, 0, i));
geometry.vertices.push(new THREE.Vector3(size, 0, i));
geometry.vertices.push(new THREE.Vector3(i, 0, -size));
geometry.vertices.push(new THREE.Vector3(i, 0, size));
}
@wangzhe1995
wangzhe1995 / series promises
Last active May 4, 2016
随便的撸了一个流式的 promise
View series promises
// need lodash
const seriesPromise = promises => {
let promisesResults = [];
const tmpPromises = promises.concat(() => {
return Promise.resolve(promisesResults)
});
return _.tail(tmpPromises).reduce((cPromise, nPromise) => {
return cPromise.then(data => {
promisesResults.push(data);
return nPromise();
You can’t perform that action at this time.