Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script id="kernel">/** pick the first pending entry and run it
 */
static void async_run_entry_fn(struct work_struct *work)
{
	struct async_entry *entry =
		container_of(work, struct async_entry, work);
	unsigned long flags;
	ktime_t uninitialized_var(calltime), delta, rettime;

	/* 1) run (and print duration) */
	if (initcall_debug && system_state == SYSTEM_BOOTING) {
		printk(KERN_DEBUG "calling  %lli_%pF @ %i\n",
			(long long)entry->cookie,
			entry->func, task_pid_nr(current));
		calltime = ktime_get();
	}
	entry->func(entry->data, entry->cookie);
	if (initcall_debug && system_state == SYSTEM_BOOTING) {
		rettime = ktime_get();
		delta = ktime_sub(rettime, calltime);
		printk(KERN_DEBUG "initcall %lli_%pF returned 0 after %lld usecs\n",
			(long long)entry->cookie,
			entry->func,
			(long long)ktime_to_ns(delta) >> 10);
	}

	/* 2) remove self from the pending queues */
	spin_lock_irqsave(&async_lock, flags);
	list_del_init(&entry->domain_list);
	list_del_init(&entry->global_list);

	/* 3) free the entry */
	kfree(entry);
	atomic_dec(&entry_count);

	spin_unlock_irqrestore(&async_lock, flags);

	/* 4) wake up any waiters */
	wake_up(&async_done);
}

static async_cookie_t __async_schedule(async_func_t func, void *data, struct async_domain *domain)
{
	struct async_entry *entry;
	unsigned long flags;
</script>

<script id="ssh">Root access granted.
Scanning open ports...
Found open diagnostic port 1002...
Satellite uplink established...
Virus uplink intercept running...
</script>

<script id="psaux" type="text/x-handlebars-template">Processes: {{wiggle 150 5 0 3}} total, 3 running, 1 stuck, 152 sleeping, {{wiggle 900 10}} threads             
Load Avg: 1.71, 1.19, 1.12  CPU usage: {{wiggle 15 4 2 3}}% user, {{wiggle 5 1 2 3}}% sys, {{wiggle 78 2 2 5}}% idle
SharedLibs: {{wiggle 14 2}}M resident, {{wiggle 7000 3000}}K data, 0B linkedit.
MemRegions: {{wiggle 41240 2000}} total, {{wiggle 2000 200}}M resident, 74M private, 1526M shared.
PhysMem: 2121M wired, 2975M active, 995M inactive, 6091M used, 2099M free.
VM: 351G vsize, 1053M framework vsize, {{wiggle 8000000 2000000}}(0) pageins, 0(0) pageouts.
Networks: packets: 3113187/2343M in, 3477572/3655M out.
Disks: 1381259/28G read, 3013776/33G written.

PID   COMMAND      %CPU      TIME     #TH  #WQ  #POR #MREG RPRVT  RSHRD  RSIZE  VPRVT
{{#each processes}}{{id}}  {{name}} {{cpu}} {{time}} {{threads}}    {{wq}}    {{por}} {{mreg}} {{rprvt}} {{rshrd}} {{rsize}} {{vprvt}}
{{/each}}</script>
              
            
!

CSS

              
                @green: #67ccbe;
@dark: #111;

@font-face {
    font-family: 'profontwindowsregular';
    src: url('https://s.cdpn.io/48706/ProFontWindows-webfont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

body, html {
  margin: 0;
  padding: 0;
  background: @dark;
  color: @green;
}

body {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  border: 2px solid @green;
  text-shadow: 0 0 2px @green;
  font-family: profontwindowsregular;
}

.window {
  border: 1px solid @green;
  font-size: 13pt;
  box-shadow:0 0 4px @green;
  background: @dark;
  position: fixed;
  overflow: hidden;
  .titlebar {
    background: @green;
    color: @dark;
    text-align: center;
    text-transform: uppercase;
    text-shadow: 0;
  }
}

.terminal {
  .content {
    padding: 10px 14px;
    white-space: pre;
  }
  
  @-webkit-keyframes blink {
    0%   { background: @green }
    47%  { background: @green }
    50%  { background: transparent }
    97%  { background: transparent }
    100% { background: @green }
  }
  
  .cursor {
    display: inline-block;
    background: @green;
    width: 1ex;
    height: 1em;
    -webkit-animation: blink 1s linear 0s infinite;
  }
}

.mugs {  
  .shot {
    border: 1px solid @green;
    margin: 20px auto;
    height: 300px;
    background-size: cover;
    position: relative;
    .eye {
      @animate: 0.2s ease 0.1s;
      height: 20px;
      width: 20px;
      background: @green;
      opacity: 0.6;
      border-radius: 10px;
      position: absolute;
      -webkit-transition: top @animate, left @animate;
    }
  }
}

.status {
  background: @dark;
  font-family: monospace;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  border-top: 1px solid @green;
  padding: 8px 20px;

  .time {
    display: inline-block;
    width: 400px;
  }
  .location {
    float: right;
  }
  
  .ip {
    margin-left: 20%;
  }
}
              
            
!

JS

              
                command = line: 0, col: 0
commands = [
  "sshnuke 10.2.2.2 --rootpw=\"210N0101\""
  "telnet shishkabob 12.32.911"
]

MUGS = [
   {
     name: "Ocarina Marapova"
     born: "July 4, 1988"
     src: "https://4.bp.blogspot.com/_sta9VHvtFmU/TMhzQHLxnyI/AAAAAAAAACQ/_ykpq8IolvU/s640/mugshot_blond.jpg"
     eyes:
       left: [360, 120]
       right: [406, 116]
   }, {
     name: "Ivan Ivanonich"
     born: "December 1, 1976"
     src: "https://t0.gstatic.com/images?q=tbn:ANd9GcRMpBc5yoeeFZaiYIWEUZWQu4p5v-MirZetKS5yoy8cgS8w1aRM"
     eyes:
       left: [405, 98]
       right: [450, 96]
   }, {
     src: "https://24.media.tumblr.com/tumblr_lkhbkbxE7E1qjzo23o1_400.jpg"
     name: "Ronnie Van Sustren"
     born: "May 28, 1946"
     eyes:
        left: [110, 104]
        right: [156, 104]
   }, {
     src: "http://img.izismile.com/img/img4/20111229/640/celeb_mug_shots_640_12.jpg"
     name: "Micky \"The Hand\" Andretti"
     born: "December 1, 1976"
     eyes:
       left: [377, 118]
       right: [423, 118]
   }
]

class Window extends Spine.Controller
  className: "window"
  
  elements:
    ".titlebar span": "etitle"
    ".content": "econtent"
  
  constructor: ({@x, @y, @width, @height, @title}) ->
    super
    
    @html """
      <div class="titlebar">
        <span></span>
      </div>
      <div class="content">
      </div>
    """
    @el.css top: @y, left: @x, height: @height, width: @width
    @etitle.html @title

class Terminal extends Window
  TYPE_DELAY = 30
  
  clear: =>
    @econtent.empty()
    @econtent.append @cursor = $ """
      <div class="cursor"></div>
    """
    
  type: (text, done) ->
    position = 0
    interval = setInterval =>
      @cursor.before text[position++]
      if position is text.length
        clearInterval interval
        done?()
    , TYPE_DELAY
    
  constructor: ({@content}) ->
    super
    @el.addClass "terminal"
    @econtent.text @content
    @econtent.append @cursor = $ """
      <div class="cursor"></div>
    """
    
class PSAUX extends Terminal
  REFRESH_EVERY = 1000
  
  processes: _.map [
    "com.enron.Prism"
    "mdworker"
    "stuxnet"
    "folding@home"
    "android"
    "ssh-ftp"
    "wormbuild"
    "xkcd"
    "DEATH.com"
    "fubar_nyan"
    "Google Chrome"
    "prism"
    "00010001011"
    "georgebuzh"
    "0xDEADBEEF"
    "111012001111123"
    "))<>(("
    "obamacare"
    "scaryprogram"
    "rapedEAth"
    "baby-tears.NET"
    "com.enron.Prism"
    "mdworker"
    "stuxnet"
    "folding@home"
    "android"
    "ssh-ftp"
    "wormbuild"
    "xkcd"
    "DEATH.com"
    "fubar_nyan"
    "Google Chrome"
    "prism"
    "00010001011"
    "georgebuzh"
    "0xDEADBEEF"
    "111012001111123"
    "insta ))<>(("
    "obamacare"
    "scaryprogram"
    "rapedEAth"
    "baby-tears.NET"
  ], (name) -> { name }
  
  fit = (s, n) ->
    s = s.slice 0, n
    _.str.rpad s, n

  refresh: =>
    # Randomly swap neighbors
    for i in [0..@processes.length-2] when Math.random() < 0.05
      prev = @processes[i]
      @processes[i] = @processes[i+1]
      @processes[i+1] = prev
      
    # have to do some formatting on the process data
    for proc in @processes
      proc.cpu = fit (wiggle 2, 1, 1), 9
      proc.time = "00:0" + wiggle 5, 1, 2, 3
      proc.threads = parseInt wiggle proc.threads, 1, 0, 3
    @econtent.html @render @
  
  wiggle = (base, wiggleroom, deci, every = 1) ->
    # Setup defaults manually
    wiggleroom = base unless typeof wiggleroom is "number"
    deci = 0 unless typeof deci is "number"
    every = 1 unless typeof every is "number"
    # Calculate probability of a wiggle
    pwiggle = REFRESH_EVERY / (every * 1000)
    # To wiggle or not to wiggle, that is the question
    wig = if Math.random() < pwiggle then Math.random() - 0.5 else 0
    (base + wiggleroom * wig).toFixed deci
    
  constructor: ->
    # have to do some formatting on the process data
    for proc in @processes
      proc.id = fit (wiggle 5000), 4
      proc.name = fit proc.name, 12
      proc.threads = parseInt wiggle 5
      proc.wq = parseInt wiggle 3, 2
      proc.por = fit (wiggle 100, 50), 4
      proc.mreg = fit (wiggle 400, 200), 5
      proc.rprvt = fit "#{wiggle 3000}K", 6
      proc.rshrd = fit "#{wiggle 3000}K", 6
      proc.rsize = fit "#{wiggle 3000}K", 6
      proc.vprvt = fit "#{wiggle 70}M", 6
     
    Handlebars.registerHelper "wiggle", wiggle
    @render = Handlebars.compile $("#psaux").html()
    
    super
      x: 30, y: 20
      height: 800, width: 800
      title: "PS AUX"
      
    @refresh()
    setInterval @refresh, REFRESH_EVERY

class SSH extends Terminal
  constructor: ->
    super
      x: 200, y: 140
      height: 500, width: 800
      title: "SSH"
      content: $("#ssh").text()
      
    $(document).keyup @advanceChar
    
  advanceChar: ->
    line = commands[command.line]
    char = line[command.col]
    @type char
  
    command.col++
    if line.length is command.col
      command.line++ 
      command.col = 0
      @type "\n"
      lines = 3 + Math.floor Math.random() * 4
      for line in [0..lines]
        dots = 10 + Math.floor Math.random() * 30
        for dot in [0..dots]
          @type "."
        @type "\n"
class Kernel extends Terminal
  writeCode: =>
    @clear()
    @type $("#kernel").text(), @writeCode
  
  constructor: ->
    super
      x: $(document).width() - 800, y: 40
      height: 740, width: 700
      title: "async.c"
    @writeCode()
  
class Mugs extends Window
  elements:
    ".shot": "shot"
    ".name": "name"
    ".born": "born"
    ".eye.left": "lefteye"
    ".eye.right": "righteye"
    
  currentMug: 0
  
  nextMug: =>
    @currentMug = (@currentMug + 1) % MUGS.length
    mug = MUGS[@currentMug]
    @shot.css "background-image": "url('#{mug.src}')"
    @name.text mug.name
    @born.text mug.born
    
    for [eye, [left, top]] in [[@lefteye, mug.eyes.left], [@righteye, mug.eyes.right]]
      eye.css { left, top }
  
  constructor: ->
    super
      x: $(document).width() - 610
      y: $(document).height() - 470
      width: 560
      title: "Interpol Target Database"
    @el.addClass "mugs"
    @append """
      <div class="shot">
        <div class="left eye"/>
        <div class="right eye"/>
      </div>
      Name: <span class="name"/>
      <br />
      Born: <span class="born"/>
    """
    @nextMug()
    setInterval @nextMug, 800

class Status extends Spine.Controller
  className: "status"
  
  elements:
    ".time": "time"
    ".ip": "ip"
    ".location": "location"
    
  displayClock: =>
    @time.text new Date
  
  displayClient: (@client) =>
    @ip.text "01010000 01010010 01001001 01010011 01001101 "
    @location.text "LOGGED IP #{@client.host} LAT #{@client.latitude} LON #{@client.longitude}"
  
  constructor: ->
    super
    
    @displayClock()
    setInterval @displayClock, 1000
    
    $.getJSON "http://smart-ip.net/geoip-json?callback=?", @displayClient
    
    @html """
    <span class="time"></span>
    <span class="ip"></span>
    <span class="location"></span>
    """
    
add = (e) -> $("body").append e.el or e
add new w for w in [Kernel, PSAUX, Mugs, SSH, Status]
              
            
!
999px

Console