// selection range | |
var range = window.getSelection().getRangeAt(0); | |
// plain text of selected range (if you want it w/o html) | |
var text = window.getSelection(); | |
// document fragment with html for selection | |
var fragment = range.cloneContents(); | |
// make new element, insert document fragment, then get innerHTML! |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This is a quick guide for people who don’t feel confident with OOP concepts yet, but want to make first steps towards improving their code using OOP principles.
If you don’t know where to start, try to look for the following patterns and apply provided recipes. Here are some problem you can find and possible solutions:
Problem | Recipes |
---|---|
Code repetition: literals (numbers, string) that you use more than once | Use power of constants: remove code repetition (less literals in code), reduce typing errors, get better IDE support. Bonus: document your code by giving meaningful names to values. |
Code repetition: expressions | Look for repeated patterns and put them into functions. Same bonuses with documenting your code. |
If you have more you can still use this method (3 accounts per instance)
⚠ This guide is for the app available here: https://desktop.telegram.org/ not the one in the Mac/Windows App Store. For the Mac App Store app this should work: https://gist.github.com/Nachtalb/ec590dc974f6ba4674972d4937b230be/#gistcomment-3611415 ⚠
Table of Contents
// create a bookmark and use this code as the URL, you can now toggle the css on/off | |
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3 | |
javascript: (function() { | |
var domStyle = document.createElement("style"); | |
domStyle.append( | |
'* { color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }\ | |
* * { background-color: rgba(0,255,0,.2) !important; }\ | |
* * * { background-color: rgba(0,0,255,.2) !important; }\ | |
* * * * { background-color: rgba(255,0,255,.2) !important; }\ | |
* * * * * { background-color: rgba(0,255,255,.2) !important; }\ |
В общем случае команда git rebase
добавляет все коммиты из ветки, на которой вы находитесь, следующими за коммитом, который вы передаете git rebase
как аргумент. Если передать первым аргументом ветку, Git найдет последний общий коммит между текущей веткой и целевой веткой и добавит коммиты из текущей в целевую один за одним. Можно представить себе, что git rebase
по очереди "накатывает" каждый из коммитов вашей ветки на целевой коммит. При этом у всех "накатанных" коммитов изменяются метаданные (например, родительский коммит), поэтому с точки зрения Git это теперь новые коммиты.
На семинаре мы познакомились с двумя случаями применения git rebase
.
Для того, чтобы объединить две ветки в одну (например, когда работа над задачей закончена и нужно влить это задачу в ветку master
), часто используют команду git merge
. Это команда объединяет ветки путем создания отдельного коммита, у которого два родителя - комм