主板鸣叫_代码3鸣叫

主板鸣叫

You don't need a thousand lines of code to make a big difference in any coding language.  Oftentimes it's quite the opposite:  a few tiny code snippets can do a world of good and accomplish big things.  I asked my Twitter followers to tweet to me their favorite tiny snippets of code -- that's a bit difference to try to pack into 140 characters!  Here are my favorites from this round!

您不需要一千行代码就可以在任何一种编码语言中产生很大的不同。 通常情况恰恰相反:一些小巧的代码片段可以成就一个美好的世界,并成就大事。 我要求我的Twitter关注者向我发送他们最喜欢的小片段代码-尝试打包成140个字符有点不同! 这是我这一轮的最爱!

字谜检查 (Anagram Check)

Anagrams are cool, and I'm gonna let ya finish, but this is the smallest checker code of all time!

字谜很酷,我要让您完成,但这是有史以来最小的检查代码!

@davidwalshblog function isAnagram(a,b){function _(s){return s.toLowerCase().replace(/[^a-z]+/g).split('').sort().join()}return _(a)==_(b)}

— forever aloe (@potch)

@davidwalshblog函数isAnagram(a,b){函数_(s){返回s.toLowerCase()。replace(/ [^ az] + / g).split('')。sort()。join()} return _(a)== _(b)}

—永远的芦荟(@potch) June 4, 2014 2014年6月4日

文字显示优化 (Text Display Optimization)

Sometimes fonts don't display optimally on all devices, so let the device browser help:

有时,字体在所有设备上的显示效果都不理想,因此请设备浏览器提供帮助:

@davidwalshblog html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }

— Achal Varma (@_achalv)

@davidwalshblog html {-webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:灰度; 文本渲染:optimizeLegibility; }

— Achal Varma(@_achalv) June 2, 2014 2014年6月2日

等宽表单元格 (Equal Width Table Cells)

We all know that tables are a pain to work with but this snippet ensures cells stay equal in width:

我们都知道表是一个痛苦的工作,但是此代码段可确保单元格保持相等的宽度:

@davidwalshblog .calendar {table-layout:fixed;} (equal width cells in table)

— Andrew McGivery (@andrewmcgivery)

@davidwalshblog .calendar {table-layout:fixed;}(表中相等宽度的单元格)

— Andrew McGivery(@andrewmcgivery) June 2, 2014 2014年6月2日

幻灯片标题居中 (Slide Title Centering)

This gem from Ana Tudor vertically centers a slide title when using HTML/CSS/JavaScript slides...which you should be using!  Death to Keynote and Powerpoint!

使用HTML / CSS / JavaScript幻灯片时,Ana Tudor的这颗宝石会垂直居中显示幻灯片标题……您应该使用它! 主题演讲和Powerpoint之死!

@davidwalshblog line-height: 100vh; /* for slideshows, put the title of the slide in the middle */

— Ana Tudor (@thebabydino)

@davidwalshblog行高:100vh; / *用于幻灯片显示,将幻灯片标题放在中间* /

— Ana Tudor(@thebabydino) June 2, 2014 2014年6月2日

浮点修复 (Floating Point Fix)

Floats in JavaScript can be a pain point to those who don't already know about the issue.  Here's the fix to keep in mind:

对于那些尚不了解该问题的人来说,JavaScript中的浮点数可能会是他们的痛点。 这里是要记住的解决方法:

@davidwalshblog var num = 0.2*0.2; //0.04000000000000001 var fixedNum = parseFloat(num.toPrecision(12)); //0.04 Floating point problem fix

— Sergey Gospodarets (@Malyw)

@davidwalshblog var num = 0.2 * 0.2; //0.04000000000000001 var fixedNum = parseFloat(num.toPrecision(12)); //0.04浮点问题修复

— Sergey Gospodarets(@Malyw) June 3, 2014 2014年6月3日

关闭浏览器标签 (Closing a Browser Tab)

This blog post will now self-destruct...

该博客文章现在将自毁...

@davidwalshblog open(location, '_self').close();

— Alex Tkachman (@alextkachman)

@davidwalshblog open(location,'_self')。close();

— Alex Tkachman(@alextkachman) June 2, 2014 2014年6月2日

Until the next Tweet For Code!

直到下一个Tweet For Code!

翻译自: https://davidwalsh.name/tweet-code-3

主板鸣叫

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值