icon-plus

从数组去重来看 javascript 的进化

Semper crescis Aut decrescis Vita detestabilis Nunc obdurat Et tunc curat Ludo mentis aciem Nunc obdurat Et tunc curat Ludo mentis aciem Egestatem Potestatem Dissolvit ut glaciem Divano Divano me Divano messi Divano messia Divano messia Divano Divano me Divano messia Divano messia Sors salutis Et virtutis Michi nunc contraria Est affectus Et defectus Semper in angaria Hac in hora Sine mora Corde pulsum tangite Divano Divano me Divano messi Divano messia Divano messia Divano Divano me Divano messia Divano messia Divano Divano me Divano messia Divano messia In divanooooo Sors salutis Et virtutis Michi nunc contraria Est affectus Et defectus Semper in angaria Hac in hora Sine mora Corde pulsum tangite Divano Divano me Divano messi Divano messia Divano messia Divano Divano me Divano messia Divano messia Hac in hora Sine mora Corde pulsum tangite Quod per sortem Sternit fortem Mecum omnes plangite 说到 javascript 数据去重,估计所有做前端的都并不陌生
数组去重的算法即使在实际生产中不一定用的多,但是在面试中几乎成为了必考的题目
这是一个神奇的题目,看上去好像是死的,应该已经没有什么发挥空间了
但事实上它随着 ECMAScript 标准的发展,数据去重的实现反倒是在不断变化
许多公司甚至可以单从一个数组去重直接看出一个前端工程师的大致水平
今天我也来说说我所知道的 javascript 数组去重吧

icon-plus

从 webpack 1 到 webpack 2 的迁移记

Tryin' to get control Pressure's takin' its toll Stuck in the middle zone I just want you alone My guessing game is strong Way too real to be wrong Caught up in your show Yeah, at least now I know It wasn't love, it wasn't love It was a perfect illusion (Perfect illusion) Mistaken for love, it wasn't love It was a perfect illusion (Perfect illusion) You were a perfect illusion I don't need eyes to see I felt you touchin' me High like amphetamine Maybe you're just a dream That's what it means to crush Now that I'm wakin' up I still feel the blow But at least now I know It wasn't love, it wasn't love It was a perfect illusion (Perfect illusion) Mistaken for love, it wasn't love It was a perfect illusion (Perfect illusion) Where are you? Cause I can't see you It was a perfect illusion But I feel you watchin' me Dilated, falling free In a modern ecstasy Where are you? Cause I can't see you It was a perfect illusion But I feel you watchin' me But I feel you watchin' me Illusion But I feel you watchin' me Mistaken for love Dilated, falling free In a modern ecstasy Mistaken for love In a modern ecstasy In a modern ecstasy I'm over the show Yeah, at least now I know It wasn't love, it wasn't love It was a perfect illusion (Perfect illusion) Mistaken for love, it wasn't love It was a perfect illusion(Perfect illusion) You were a perfect illusion It was a perfect illusion It was a perfect illusion Somewhere in all the confusion It was a perfect illusion, illusion, illusion It was a perfect illusion Somewhere in all the confusion You were so perfect You were a, you were a perfect illusion 最近上手新项目的时候想要用个 sass,结果发现 npm 里面的 sass-loader 默认的 peerDependencies 中的 webpack 版本被升级到了 2
当时没想太多,就装了个 webpack 2.2.1来用,结果发现以前项目的 webpack 配置居然不能够直接用!一跑起来一还堆错
上网查了下,才知道 webpack 2 弄了很多 breaking changes ,想着反正这些问题迟早要解决的,于是就开始了我的 webpack 2 踩坑过程

icon-plus

原生 js 中的各种宽高以及位置的获取

我打电话比你 讲左几句你就收线喇 你变左好多呀 点解唔同我倾落去 点解心不在焉呢 点解对我冷淡 点解 我讲乜野你都反应既呢 从你 你不停的追问 你痴情的态度 令我停停下脚步 还有你追求的心愿 我心曾想配合 但我难照做 这是你爱的控诉 还是爱的追讨 但我始终感觉到 此去没去路 我没有说不爱你 从未说不喜欢 但我心知此刻相爱 时机未到 个个边个黎架 讲左几耐呀 去左几多次街呀 有拖过手呀 点解唔介绍我识 有上过你屋企 有一齐听唱片呀 从你 你不停的追 你痴情的态度 令我停停下脚步 还有你追求的心愿 我心曾想配合但我难照做 这是你爱的控诉 还是爱的追讨 但我始终感觉到 此去没去路 我没有说不爱你 从未说不喜欢 但我不想只讲一句 无可奉告 最近在用原生的js来实现一些交互特效,写的时候发现这些宽度和高度的获取真的是太常用了
而且获取他们的方法不止一个两个,上网一搜发现有好多,看得我眼花缭乱的
于是我自己做了一个归纳,方便以后快速查阅

对于移动端,一般要统一初始化视口宽高缩放比例

icon-plus

在windows下制作macOS Sierra(10.12)正式版的安装U盘

She got a body like an hourglass, but I can give it to you all the time She got a booty like a Cadillac, but I can send you into overdrive (oh) (Stop and wait, wait for that, stop, hold up, swing your bat See anybody could be bad to you, you need a good girl to blow your mind, yeah Bang bang into the room (I know you want it) Bang bang all over you (I’ll let you have it) Wait a minute let me take you there (ah) Wait a minute tell you (ah) Bang bang there goes your heart (I know you want it Back, back seat of my car (I’ll let you have it) Wait a minute let me take you there (ah) Wait a minute tell you (ah) She might've let you hold her hand in school, but I'mma show you how to graduate No, I don't need to hear you talk the talk, just come and show me what your momma gave (Oooh yeah) (You've got a very big shhh, love but don’t say a thing See anybody could be good to you, you need a bad girl to blow your mind Bang bang into the room (I know you want it) Bang bang all over you (I’ll let you have it) Wait a minute let me take you there (ah) Wait a minute tell you (ah) Bang bang there goes your heart (I know you want it) Back, back seat of my car (I’ll let you have it) Wait a minute let me take you there (ah) Wait a minute tell you (ah) It’s Myx moscato, it’s frizz in a bottle It’s Nicki full throttle, it’s oh, oh Swimming in the grotto, we winning in the lotto We dipping in the powder blue four door Kitten so good, it's dripping on wood Get a ride in the engine that could - GO!, Batman robbin' it, bang bang, cockin' it Queen Nicki dominant, prominent It's me, Jessie, and Ari, if they test me, they sorry Ride his uh like a Harley then pull off in his Ferrari If he hanging we banging, phone ranging, he slanging It ain't karaoke night but get the mic ‘cause I'm singing (B to the A to the N to the G to the uh) (B to the A to the N to the G to the hey) See, anybody could be good to you You need a bad girl to blow your mind Bang bang into the room (I know you want it) Bang bang all over you (I’ll let you have it) Wait a minute let me take you there (ah) Wait a minute tell you (ah) Bang bang there goes your heart (I know you want it) Back, back seat of my car (I’ll let you have it) Wait a minute let me take you there (ah) Wait a minute tell you (ah) Bang bang into the room (I know you want it) Bang bang all over you (I’ll let you have it) Bang bang there goes your heart (I know you want it) Back, back seat of my car (I’ll let you have it) Wait a minute let me take you there (ah) Wait a minute tell you (ah) 最近咱老大丢给我了一台 Mac mini,准备给我用来做前端用。
说实话,要不是咱老大拿出了这台 Mac mini ,我还不知道苹果有这么一条产品线呢。
mini 应该算是整个苹果PC产品线上,用来给mac新手上路的成本最低的方案了。
而且作为一个台式机来说,确实够小巧精致,面积才一个小鼠标垫那么大,高度大概也只有一个键盘那么高。
拿起来其实感觉还没有Macbook Air重,可以能像笔记本一样能够便携,咱只要花上air一半的价钱就能够用上macOS
个人感觉这对mac新人来说还是挺划算的。于是马上接好了线,开机,发现系统版本还是Yosemite,还装了一堆我用不到的东西。
作为一个爱干净前端,看到这一堆乱七八糟的东西之后强迫症开始犯了,于是开始想办法,把系统给干了,重新装一遍。
由于是新手,不能够像重装windows一样那么熟练地重装mac,倒腾了几天,终于找到了一个可行的 U 盘安装方法。

icon-plus

使用阿里巴巴矢量图标库自定义图标集

Do you recall, not long ago We would walk on the sidewalk Innocent, remember? All we did was care for each other But the night was warm We were bold and young All around the wind blows We would only hold on to let go Blow a kiss, fire a gun We need someone to lean on Blow a kiss, fire a gun All we need is somebody to lean on Blow a kiss, fire a gun We need someone to lean on Blow a kiss, fire a gun All we need is somebody to lean on What will we do when we get old? Will we walk down the same road? Will you be there by my side? Standing strong as the waves roll over When the nights are long Longing for you to come home All around the wind blows We would only hold on to let go Blow a kiss, fire a gun We need someone to lean on Blow a kiss, fire a gun All we need is somebody to lean on Blow a kiss, fire a gun We need someone to lean on Blow a kiss, fire a gun All we need is somebody to lean on All we need is somebody to lean on All we need is somebody to lean on Lean on, lean on, lean on, lean on... Blow a kiss, fire a gun We need someone to lean on Blow a kiss, fire a gun All we need is somebody to lean on Blow a kiss, fire a gun We need someone to lean on Blow a kiss, fire a gun All we need is somebody to lean on 最近用上了阿里巴巴的矢量图标库后,简直爱不释手,对小网站来说真是太好用了。
有的时候,对于自己开发的小型网站来说,不太想用 bootstrap 这么重的框架,但又想用 bootstrap 里面的字体图标
一般我的做法就是直接手动引入font-awesome,然后在对应要用到图标的地方加 class
但从现在看来,直接引用font-awesome还是有这么一些个很明显的缺陷: