This has been incorporated in a small library.
function getRotationAngle(target) | |
{ | |
const obj = window.getComputedStyle(target, null); | |
const matrix = obj.getPropertyValue('-webkit-transform') || | |
obj.getPropertyValue('-moz-transform') || | |
obj.getPropertyValue('-ms-transform') || | |
obj.getPropertyValue('-o-transform') || | |
obj.getPropertyValue('transform'); | |
let angle = 0; |
// assumes you add a timestamp field to each record (see Firebase.ServerValue.TIMESTAMP) | |
// pros: fast and done server-side (less bandwidth, faster response), simple | |
// cons: a few bytes on each record for the timestamp | |
var ref = new Firebase(...); | |
ref.orderByChild('timestamp').startAt(Date.now()).on('child_added', function(snapshot) { | |
console.log('new record', snap.key()); | |
}); |
(* | |
Installation instructions | |
========================= | |
Run as an Application: | |
1) Open AppleScript Editor and create a new script | |
2) Paste this file into it | |
3) Save name it '§(Toggle Wi-Fi)' | |
- Or substitute '§' for a symbol that you can press with a single key | |
4) Put it in Applications/Utilities |
<?php | |
# http://jeffreysambells.com/2012/10/25/human-readable-filesize-php | |
function human_filesize($bytes, $decimals = 2) { | |
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB'); | |
$factor = floor((strlen($bytes) - 1) / 3); | |
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor]; | |
} | |
echo human_filesize(filesize('example.zip')); |
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
- have PuTTY installed
- make sure you have installed PLink as a part of the installation process.
- open an elevated command prompt
- run the following command
plink.exe -L 3307:localhost:3306 [USERNAME]@[YOURSERVER.COM]
A multi-level groupBy for arrays inspired by D3's nest operator.
Nesting allows elements in an array to be grouped into a hierarchical tree
structure; think of it like the GROUP BY
operator in SQL, except you can have
multiple levels of grouping, and the resulting output is a tree rather than a
flat table. The levels in the tree are specified by key functions.
See this fiddle for live demo.
If you want to get the difference between two branches, say master and branch-name, use the following command:
git diff master..branch-name
If you want that same diff in a patch, because patches are handy, just add the output redirect:
git diff master..branch-name > branch-name.patch
If you need to import that patch into something like Crucible then you'll need to get rid of the a and b prefixes that git adds:
git diff --no-prefix master..branch-name > branch-name.patch
git fetch --all | |
git reset --hard origin/master | |
git pull origin master |