Skip to content

Instantly share code, notes, and snippets.

@wintercn
wintercn / magic.py
Created June 4, 2014 14:05
python magic
#:tabstop=4
if 1 :
if 1 :
if 0 :
print 1
else :
print 2
#:tabstop=8
if 1 :
@wintercn
wintercn / RemoveMultipleSpaces.cs
Created March 28, 2012 16:26 — forked from Ninputer/RemoveMultipleSpaces.cs
模拟微面试之去空格
//请实现下面的函数,输入参数baseStr是一个(可以更改的)字符串,请将其中所有连续出现的多个空格都替换成一个空格,单一空格需保留。
//请直接使用baseStr的空间,如需开辟新的存储空间,不能超过o(N)(注意是小o,N是字符串的长度)。返回值是替换后的字符串的长度。
//样例代码为C#,但可以使用任何语言。如需使用任何库函数,必须同时给出库函数的实现。
class Program
{
public static int RemoveMultipleSpaces(char[] baseStr)
{
int r = 0, w = 0;
char c;
while (r < baseStr.Length)
@wintercn
wintercn / gist:3923697
Created October 20, 2012 15:53
计算“某个范围内能被最多的数整除的数”
var primes = [2,3,5,7,11,13,17];
function find(n){
var table = new Array(n+1);
table[1] = [0,0,0,0,0,0,0];
for(var i = 1;i<n;i++) {
if(!table[i]) {
table[i] = [0,0,0,0,0,0,0];
continue;
}
@wintercn
wintercn / gist:5918272
Created July 3, 2013 14:18
CSS3 标准和属性对应数据
[
{
"spec name": "CSS Animations",
"uri": "http://www.w3.org/TR/css3-animations",
"category": "css-property",
"Name": "animation-name",
"Value": "<single-animation-name> [\n ‘,’ <single-animation-name> ]*",
"Initial": "‘none’",
"Applies To": "all elements, ::before and ::after pseudo-elements",
"Inherited": "no",
@wintercn
wintercn / adhocSort.js
Created September 30, 2013 03:19
假期前小玩意,ad-hoc排序
function shuffle(array){
for(var i = array.length-1; i > 0; i--) {
var rnd = Math.floor(Math.random() * (i+1));
var tmp = array[i];
array[i] = array[rnd];
array[rnd] = tmp;
}
}
function isInOrder(array) {
for(var i = 0; i < array.length-1; i++)
@wintercn
wintercn / JD.md
Last active December 29, 2015 14:58

移动富交互应用Job Design

Moria[Mobile Rich Interactive App]

工作职责

  • 负责Mobile端创意营销和游戏化场景的业务开发
@wintercn
wintercn / unhappy.md
Last active May 9, 2016 09:06
一件不开心的事

有一天,我切了个页面,有个按钮点了以后要跳转到另一个页面,于是我把代码这么写:

    window.location = "xxxxxx";

结果那个页面lazyload组件有bug,跳过去一片灰色,沟通了半天没解决,经过反复试验,我发现只要我页面的滚动位置不在顶部就会有问题,于是我想办法绕了过去,代码变成了这样:

 document.body.style.display = "none";
@wintercn
wintercn / gist:5342839
Created April 9, 2013 03:55
取两个HTML节点最近的公共父节点
function getCommonParent(el1,el2){
var parents1 = [];
var el = el1;
while(el) {
parents1.unshift(el);
el = el.parentNode;
}
var parents2 = [];
@wintercn
wintercn / gist:6666747
Created September 23, 2013 05:28
Web API里可以new的东西
//Chrome上能用的
["Image", "Audio", "MediaController", "TrackEvent", "Option", "PopStateEvent", "HashChangeEvent", "PageTransitionEvent", "Event", "CustomEvent", "MutationObserver", "Document", "FormData", "XMLHttpRequest", "FormData", "IDBVersionChangeEvent", "StorageEvent", "RTCSessionDescription", "RTCIceCandidate", "MediaStreamEvent", "Notification", "Blob", "FileReader", "ErrorEvent", "Worker", "SharedWorker", "TransitionEvent"]
//标准里有但是还不能用的
["RelatedEvent", "DragEvent", "AnonXMLHttpRequest", "RTCPeerConnection", "RTCPeerConnectionIceEvent", "DataChannelEvent", "ClipboardEvent", "FileReaderSync", "BlobBuilder", "FileSaver", "ParGroup", "SeqGroup", "Animation", "PseudoElementReference", "KeyframeAnimationEffect", "PathAnimationEffect", "TimingEvent", "AnimationEvent"]
@wintercn
wintercn / showboxes.js
Created May 21, 2013 06:34
显示页面的盒结构
function randomColor(){
return "rgb("+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+")";
}
function showBoxes(window) {
var rects = [];
function getRects(node){
var range = window.document.createRange();
range.setStartBefore(node);
range.setEndAfter(node);