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
| // duck typing | |
| package main | |
| import "fmt" | |
| // Virtual duck | |
| type Duck interface { | |
| Quack() string | |
| } |
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
| // An example of type assertions for empty interface (i.e., interface{}) | |
| package main | |
| import ( | |
| "container/list" | |
| "fmt" | |
| ) | |
| type Node struct { |
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
| #!/bin/bash -x | |
| cat << EOF > foo.cc | |
| #define BOOST_TEST_MODULE foo | |
| #include <boost/test/unit_test.hpp> | |
| BOOST_AUTO_TEST_CASE(foo_test) { | |
| int a = 0; | |
| BOOST_CHECK_EQUAL(0, a); | |
| } |
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
| #!/bin/bash -x | |
| filename=sinx | |
| epsfile=${filename}.eps | |
| tex_master=main.tex | |
| tex_cmd=pdflatex | |
| color=white # color which you want to change to. | |
| gnuplot <<EOF | |
| set terminal postscript eps enhanced color 30 |
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
| # Change colors of elements in Gnuplot | |
| # change a color of border. | |
| set border lw 3 lc rgb "white" | |
| # change text colors of tics | |
| set xtics textcolor rgb "white" | |
| set ytics textcolor rgb "white" | |
| # change text colors of labels |
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
| // Clang does not compile the code, but gcc does. | |
| // See e.g., | |
| // http://www.mail-archive.com/[email protected]/msg08044.html | |
| template <typename T> | |
| class Foo { | |
| public: | |
| Foo() {} | |
| ~Foo() {} | |
| void func(int a); |
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 <cstdlib> | |
| struct Entry { | |
| unsigned char key; | |
| std::size_t value; | |
| }; | |
| template <typename EntryT> | |
| class Klass { | |
| public: |
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
| #!/bin/bash | |
| # A script to generate reduced EPS files. | |
| # Taken from http://electron.mit.edu/~gsteele/pdf/ | |
| # | |
| epsfile=$1 | |
| pngfile=${epsfile/eps/png} | |
| jpgfile=${epsfile/eps/jpg} | |
| new_epsfile=reduced_${epsfile} | |
| echo $new_epsfile |
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
| package main | |
| import ( | |
| "fmt" | |
| "math/cmplx" | |
| ) | |
| // FIXME: | |
| // Currently calculate only real part of the input | |
| // complex number. |
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
| package main | |
| import "fmt" | |
| // Very naive answer. | |
| // fibonacci is a function that returns | |
| // a function that returns an int. | |
| func fibonacci() func() int { | |
| n := 0 | |
| a := 0 |