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/sh | |
set -e | |
for f in *.c *.cc *.h; do | |
sed -i -e 's/1984-2012/1984-2013/' $f | |
done |
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
(* | |
* Prints the timing when the Mathematica kernel is terminated. | |
*) | |
Print["Begin at: ", DateString[]]; | |
$Epilog := ( | |
Print["End at: ", DateString[]]; | |
Print["Elapsed Time: ", SessionTime[]]; | |
Print["CPU Time: ", TimeUsed[]]; | |
); |
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/sh | |
# | |
# A (client-side) git hook script which warns if there are too long lines in | |
# the commit message, not fitting with 50/72 formatting. | |
# | |
# To use this script, copy it as .git/hooks/commit-msg and give it an executable | |
# file permission. | |
# | |
FILE=$1 |
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
# Checks if $1 is a text file. | |
is_text() { | |
file "$1" | grep text >/dev/null | |
} |
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/sh | |
# | |
# @file gist+x.sh | |
# | |
# Gives executable file permissions to files in a Gist. | |
# | |
set -e | |
prog=`basename "$0"` | |
# Command line options. |
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/sh | |
# | |
# @file rstrip.sh | |
# | |
# Removes trailing whitespace from text files. | |
# | |
# Example: | |
# rstrip.sh *.c | |
# rstrip.sh -r . # all files in the current directory | |
# |
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
(* | |
* Makes a directory tree. | |
*) | |
EnsurePath[path_String] := Module[{names, cd, p}, | |
names = FileNameSplit[path]; | |
cd = {}; | |
While[Length[names] > 0, | |
AppendTo[cd, First[names]]; | |
names = Rest[names]; | |
p = FileNameJoin[cd]; |
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 | |
# | |
# @file tarb | |
# | |
# Creates a tarball of the current directory. | |
# | |
# Examples: | |
# $ cd tarb-test | |
# $ tarb # create ../tarb-test.tar.gz | |
# $ tarb -j # create ../tarb-test.tar.bz2 |
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
(* | |
* Tested in v5.1, v5.2, v6.0.3, v7.0.1, v8.0.4 and v9.0.1. | |
* It is said that Wolfram changed the way how Series works between v5.0 and | |
* v5.1, but I don't have any working binaries of <= v5.0 for now. | |
*) | |
ExplicitFunc[x_] := 1/x^3 Log[1-x]; | |
Series[ExplicitFunc[x], {x, 0, 3}] // Print; | |
Series[Log[1-x] ExplicitFunc[x], {x, 0, 3}] // Print; |
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
(* https://news.ycombinator.com/item?id=7144616 *) | |
SplitDigits[x_, n_, m_] := Module[{a}, | |
a = RealDigits[FractionalPart[N[x, n + 1]]]; | |
a = Join[ConstantArray[0, -a[[2]]], a[[1]]]; | |
a = Drop[a, -1]; | |
a = ToString /@ a; | |
a = Partition[a, m]; | |
a = (StringJoin @@ # &) /@ a; | |
a = ToExpression /@ a; |