Skip to content

Instantly share code, notes, and snippets.

@hoox
hoox / top-power-consumption.md
Created August 26, 2015 12:42
Top - Power Consumption

Top - Power Consumption

top -stats pid,command,cpu,idlew,power -o power -d
@hoox
hoox / gist:daeb8c47db7dd1e01935
Last active August 29, 2015 14:21
iOS Simulator

iOS Simulator

  • Run xcrun simctl list to get a list of available devices (with a UDID).
  • Run open -a "iOS Simulator" --args -CurrentDeviceUDID <UDID>
@hoox
hoox / git-rewrite-history.md
Last active August 29, 2015 14:26
Git Rewrite History

Rewriting History

Run the command:

git rebase -i @~5

This displays the last 5 commits.

Then:

@hoox
hoox / git-push-up-to-a-particular-commit.md
Last active August 29, 2015 14:26
Git Push up to a particular Commit

Push up to a particular Commit

Run the command:

git push origin <commit>:master

This will push up to the inclusive.

@hoox
hoox / device-light.js
Last active August 29, 2015 14:27
Ambient Light API - "Device Light" Event Listner
window.addEventListener('devicelight', function(event) {
var media = document.querySelectorAll("img");
for (var i=0;i<media.length;i++) {
media[i].style.opacity = event.value / 100;
}
});
@hoox
hoox / device-orientation.js
Created August 10, 2015 06:14
"Device Orientation" Event Listner
window.addEventListener('deviceorientation', function(e) {
var media = document.querySelectorAll("img");
for (var i=0;i<media.length;i++) {
media[i].style.transform = "rotate("+ Math.round(e.gamma) +"deg) rotate3d(1,0,0, "+ (Math.round(e.beta)*-1)+"deg)";
}
});
@hoox
hoox / get-battery.js
Created August 11, 2015 00:12
Battery Details
navigator.getBattery().then(function(battery){
console.log(battery.level);
console.log(battery.charging);
});
@hoox
hoox / gamepad-connection.js
Created August 22, 2015 12:19
"Gamepad Connected/Disconnected" Event Listener
window.addEventListener("gamepadconnected", function(e) {
console.log(e.gamepad);
});
window.addEventListener("gamepaddisconnected", function(e) {
console.log(e.gamepad);
});
@hoox
hoox / online-offline-event.js
Last active September 3, 2015 11:58
"Online Offline" Event Listener
window.addEventListener("online", function(e) {
console.log(e.type, navigator.onLine);
});
window.addEventListener("offline", function(e) {
console.log(e.type, navigator.onLine);
});
@hoox
hoox / visibilitychange.js
Last active September 25, 2015 04:21
"Visibility Change" Event Listener
document.addEventListener("visibilitychange", function() {
console.log(document.hidden);
});
window.addEventListener("focus", function() {
console.log("focus");
});
window.addEventListener("blur", function() {
console.log("blur");
});