Archive for September, 2013

Linux kernel config to fix high pitch noise from CPU

Sep 30 2013 Published by under Linux

On one of the computers I was using, I started noticing a high pitched noise after I moved into a quieter room. At first, I thought I heard it after I turned off the computer. It must have been one of those ghosts. I haven’t bothered with it until today because I rarely turn off my computer. Also, it didn’t have support for suspend compiled into the kernel, which often requires a lot of modules to be built. I am using a minimal kernel seed from http://kernel-seeds.org/, so I didn’t bother adding those modules.
You can tell the high pitched noise is coming from your CPU if running a computationally intensive process suddenly silences it. First, I tried adding more CPU power management and adjusting fan speeds in the BIOS. They are related. If the CPU is using less power and running cooler, the fan also spins slower with less noise. I didn’t expect Intel’s market dominating CPU to be producing the noise. However, just like Windows or any market leader, there’s not enough competition for such things to be a threat. Next, typing a simple search query for “linux kernel config high pitch” lead me to http://www.thinkwiki.org/wiki/Problem_with_high_pitch_noises, and I tried the first solution by recompiling my kernel. I had a similar problem with my old Dell laptop when it went to sleep. I ended up never using sleep so that I could sleep at night.
The solution is to set CONFIG_ACPI_PROCESSOR=n under ACPI options. If you’re new to compiling a kernel, a good guide is Linux Sea.

— ACPI (Advanced Configuration and Power Interface Support)
[*] Deprecated /proc/acpi files
[*] Deprecated power /proc/acpi directories
< > ACPI 4.0 power meter
[*] Future power /sys interface
[*] Deprecated /proc/acpi/event support
<*> AC Adapter
<*> Battery
<*> Button
<*> Video
<*> Fan
< > Processor
<*> Thermal Zone
[ ] Debug Statements
< > PCI slot detection driver
< > Smart Battery System

No responses yet

Using Encapsulation to Make an Awesome Angular JS Editor in Fiddle Salad

Sep 26 2013 Published by under Fiddle Salad,Programming

Angular JS is a popular MVC framework by Google, and I received a bug report that Fiddle Salad wouldn’t reload the preview as it does in all other cases. This problem was noticed before, but it wasn’t a priority since pressing the refresh button as required in all other web development methods solves the problem. However, this was because I was attempting to solve it at the wrong level by modifying a method. As I’ve learned, there are dependencies between the execute, reset, and initiation of the class involved.

Fiddle Salad’s CodeRunner class has just 5 public methods. They are

  • execute()
  • add_file()
  • remove_css()
  • reset()
  • debug()

as in the class diagram on the wiki at https://github.com/yuguang/fiddlesalad/wiki/2.-Classes. Therefore, any implementation of a CodeRunner just needs to support these 5 methods. The debug method could be refactored into a super class because it would generate the template for the new execute() method.

debug: ->
  ###
  Debug opens a new window with the code loaded in the page. External CSS and JS files are loaded through head tags.
  It assumes all external resources are stored in the view model.
  ###

  template =
    css: _.template '<link rel="stylesheet" type="text/css" href="<%= source %>" />'
    js: _.template '<script type="text/javascript" src="<%= source %>"></script>'
    html: _.template """
          <!DOCTYPE html>
          <html>
            <head>
              <title>Fiddle Salad Debug View</title>
              <script src="http://leaverou.github.com/prefixfree/prefixfree.min.js"></script>
              <style>
                <%= css %>
              </style>
            </head>
            <body>
              <%= body %>
              <%= headtags %>
              <script type="text/javascript">
                <%= javascript %>
              </script>
            </body>
          </html>
          """

  # initialize array of head tags
  headTags = new Array
  # for each external resource in view model
  _.each viewModel.resources(), (resource) =>
    # get the file type of the resource, call mapped template with resource, and append generated HTML to head tags
    headTags.push template[@filetype resource.source()](source: resource.source())
  headtags = headTags.join('')
  # get JavaScript and CSS code from the engine
  javascript = engine.get_code LANGUAGE_TYPE.COMPILED_PROGRAM
  body = engine.get_code LANGUAGE_TYPE.COMPILED_DOCUMENT
  css = engine.get_code LANGUAGE_TYPE.COMPILED_STYLE
  # call the template for the window with the head tags and code
  html = template.html {javascript, css, body, headtags}
  # open window with generated HTML
  window.open = 'data:text/html;charset=utf-8,' + encodeURIComponent(html)

If I just change the last line, the debug method turns into a reset method.

@window.location = 'data:text/html;charset=utf-8,' + encodeURIComponent(html)

The rest of the class still needs to be completed, but they are as obvious as appending to an array when adding JS/CSS files.

No responses yet