Skip to content

Instantly share code, notes, and snippets.

View Gaiiden's full-sized avatar

Drew Kerman Gaiiden

View GitHub Profile
@Gaiiden
Gaiiden / Tipped Example
Last active April 16, 2016 16:23
Support for Tipped image map tooltips in Chrome
$(document).ready(function(){
// Chrome support for image map tooltips with Tipped
$("area").hover(function() {
// HTML data is stashed in the alt attribute so Chrome doesn't show its own tooltip
if (browserName == "Chrome" && $(this).attr("alt")) {
$("#chromeMapTipData").html($(this).attr("alt"));
// get the coordinate data for the area and size/center the div around it
@Gaiiden
Gaiiden / path.ks
Created April 14, 2016 08:32
renders ascent profiles (or any path really)
clearscreen.
set pathData to readjson("path.json").
set colorList to list(green, red, cyan, purple, yellow, blue).
set colorListIndex to -1.
set lastPhase to "".
clearvecdraws().
from { local index is 0. } until index = pathData["geo"]:length-1 step { set index to index + 1. } do {
if pathData["phase"][index] <> lastPhase {
set lastPhase to pathData["phase"][index].
set colorListIndex to colorListIndex + 1.
@Gaiiden
Gaiiden / logger.ks
Created April 14, 2016 08:31
Logging data for path renderer
clearscreen.
set currTime to ceiling(time:seconds).
set phase to "Booster Ascent".
lock srb to ship:partstagged("srb")[0]:getmodule("moduleengines"):getfield("status").
set pathData to lexicon().
set altData to list().
set geoData to list().
set vecData to list().
set phaseData to list().
pathData:add("alt", altData).
@Gaiiden
Gaiiden / boot.min.ks
Last active April 7, 2016 06:13
Minimized version of kOS bootscript
clearscreen. set dOF to 0.set bO to 0.set oL to shipname+".log.np2".log "" to oL. function DL{parameter aF,lF.if not addons:rt:haskscconnection(ship) return 0.if not archive:exists(aF) return 0.if exists(lF) set lFS to open(lF):size. else set lFS to 0.set aFS to archive:open(aF):size. if core:volume:freespace-aFS+lFS<0{if core:volume:freespace-aFS+lFS+open(oL):size>0{copy shipname+".log.backup.np2" to 0.delete(oL).print "deleting log to free up space".}else{print "unable to copy file "+aF+". Not enough disk space".return 0.}}copy aF from 0.archive:delete(aF).if lFS delete(lF).rename aF to lF. return 1.}if exists("backup.op.ks") and not addons:rt:haskscconnection(ship){delete operations. rename "backup.op.ks" to "operations.ks".print "KSC connection lost. Stored operations file loaded".}else{if not addons:rt:haskscconnection(ship){print "waiting for KSC link...".wait until addons:rt:haskscconnection(ship).}print "KSC link established, fetching operations...".wait addons:rt:kscdelay(ship).if DL(shipname+".boot.
@Gaiiden
Gaiiden / boot.ks
Last active April 15, 2016 02:12
Bootscript for kOS
clearscreen.
set deleteOnFinish to false.
set backupOps to false.
log "" to ship:name + ".log.np2".
// checks if the requested file exists on the KSC disk
// checks if there is enough room to copy a file from the archive to the vessel
// will remove the log file if the space it frees will allow the transfer
// also accounts for wether the transfer file has a local copy that will be replaced
function download {