This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| // define a struct for a single node: two data fields and a next pointer | |
| struct listNode { | |
| int number; | |
| char *name; | |
| struct listNode *next; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <libgen.h> // basename | |
| #include <math.h> // sqrt | |
| double get_sum(const double vals[], const size_t n); | |
| double get_mean(const double sum, const size_t n); | |
| double get_median(const double sorted[], const size_t n); | |
| double get_mode(const double sorted[], const size_t n, int* has_mode); | |
| double get_variance(const double vals[], const size_t n, const double mean); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.swing.*; | |
| import java.awt.*; | |
| /** | |
| * Class to demonstrate creation and manipulation of a Container's anonymous Components. | |
| * We can use methods like getComponent, getComponents, getComponentCount and getContentPane to | |
| * extract components that have been added to a container. | |
| */ | |
| public class ContainerDemo extends JApplet { | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Experiments with the Array library, including the Enumerable mixins | |
| ################################################################################ | |
| # initialization | |
| # Array.[] denotes array literally, or can be used as factory method | |
| [-2, 'a string', __FILE__] # => [-2, "a string", "(irb)"] | |
| Array.[](-2, 'a string', __FILE__) # => [-2, "a string", "(irb)"] | |
| # empty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'ncoop' | |
| class Thing: | |
| def __init__(self, val): | |
| self.val = val | |
| def __str__(self): | |
| return "~%d" % self.val |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function dumpSERVER() { | |
| $ary = $_SERVER; | |
| echo "<hr>\n<h3>\$_SERVER: ".count($ary)."-entry array</h3>"; | |
| echo "<dl>\n"; | |
| foreach (array_keys($ary) as $key) { | |
| echo "<dt>$key</dt>"; | |
| echo "<dd>$ary[$key]</dd>"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head lang="en"> | |
| <meta charset="UTF-8"> | |
| <title>TOC maker</title> | |
| <style type="text/css"> | |
| body { | |
| font-family: sans-serif; | |
| background-color: lightgreen; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %{ | |
| "MATLAB Programming with Applications for Engineers", Stephen Chapman, 2013 | |
| Chapter 4: Branching Statements and Program Design; Exercise 17 | |
| Purpose: | |
| - For a ray or light passing between two regions, calculate the angle of | |
| incidence into the second region given the indices of refraction. | |
| - Properly handle cases where no light is refracted into the second region. | |
| - Plot the incident ray, the boundary, and the refracted ray. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| def parseArgs(): | |
| from sys import stderr | |
| import argparse | |
| from os.path import expanduser, isfile | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument( | |
| '-f', '--file', help='file to be cleaned', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'matrix' | |
| class Matrix | |
| # Attempt to recast each entry of the matrix to clazz | |
| def to(clazz) | |
| self.each_with_index do |entry, i, j| | |
| self[i, j] = send(clazz.name.to_sym, entry) | |
| end | |
| end | |
| end |