Skip to content

Instantly share code, notes, and snippets.

@LukeXF
Created August 30, 2014 13:14
Show Gist options
  • Save LukeXF/d83941413cf56743e885 to your computer and use it in GitHub Desktop.
Save LukeXF/d83941413cf56743e885 to your computer and use it in GitHub Desktop.
A simple Gist to convert ram.
<div class="tab-pane" id="ramconvert">
<h3>Convert RAM</h3>
<p>While working with server pretty much every day, RAM allocation becomes a largely used featured in the day to day running of servers. I have adapted this script to provide a simple and easily to use tool to convert from the 4th smallest RAM values.</p>
<div class="row">
<div class="col-md-10">
<script language="JavaScript">
<!--
function byteConverter(){
document.converter.kb.value = document.converter.byte.value / 1024
document.converter.mb.value = document.converter.byte.value / (1024*1024)
document.converter.gb.value = document.converter.byte.value / (1024*1024*1024)
}
function kbConverter(){
document.converter.byte.value = document.converter.kb.value * 1024
document.converter.mb.value = document.converter.kb.value / 1024
document.converter.gb.value = document.converter.kb.value / (1024*1024)
}
function mbConverter(){
document.converter.byte.value = document.converter.mb.value * 1024 * 1024
document.converter.kb.value = document.converter.mb.value * 1024
document.converter.gb.value = document.converter.mb.value / 1024
}
function gbConverter(){
document.converter.byte.value = document.converter.gb.value * 1024 * 1024 * 1024
document.converter.kb.value = document.converter.gb.value * 1024 * 1024
document.converter.mb.value = document.converter.gb.value * 1024
}
//-->
</script>
<form name="converter">
<div class="row">
<div class="col-md-6">
<div class="input-group">
<input type="text" name="byte" onChange="byteConverter()" class="form-control">
<span class="input-group-addon">&nbsp;B&nbsp;&nbsp;</span>
</div>
<div class="input-group">
<input type="text" name="kb" onChange="kbConverter()" class="form-control">
<span class="input-group-addon">KB</span>
</div>
</div>
<div class="col-md-6">
<div class="input-group">
<input type="text" name="mb" onChange="mbConverter()" class="form-control">
<span class="input-group-addon">MB</span>
</div>
<div class="input-group">
<input type="text" name="gb" onChange="gbConverter()" class="form-control">
<span class="input-group-addon">GB</span>
</div>
</div>
</div>
<a class="btn btn-success" href="github-ception" target="_blank"><i class="fa fa-github fa-lg"> </i>&nbsp;&nbsp;Source</a>
<input type="button" class="btn btn-primary" value="Convert!" />
</form>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment