Pensieve header: My global Mathematica initialization file.

Setting Up a Configuration File for the Kernel

(Information from tutorial/SystemwideDefaults)

Launch Mathematica and create a new file.

Add any Mathematica commands that should be evaluated on startup. For example, you may want to add a function definition or display a message at startup. Enter all the commands in the same cell, separating commands with semicolons.

Make this cell an initialization cell by selecting the cell bracket and then choosing Cell ▶ Cell Properties ▶ Initialization Cell.

When you have finished making your changes, choose File ▶ Save and select Mathematica Package from the Save as type popup menu. Then save the file as $BaseDirectory\Kernel\init.m.

These commands will be evaluated when users launch Mathematica. If you added a function definition, that function will be available to all users.

If you have created systemwide defaults you want to carry over to new local installations, you can add lines to an installation script to copy preconfigured init.m files as part of a new installation. For information about installation scripts, see "Installing Mathematica". To copy systemwide defaults, add a line to the script similar to the line that copies the mathpass file.

$BaseDirectory<>"\\Kernel"

Prolog

BeginPackage["DrorBarNatan`"];
$DBNExtensions={As, BetterBlackBoard, MakeImage,RotateToMinimal, $Image, $NewInputAliases};
(*Print["DBN Extensions: ",$DBNExtensions];*)
Begin["`Private`"];

Setting the path

$Path=Join[$Path, {
"C:\\drorbn\\AcademicPensieve\\Projects\\KnotTheory"
}]

BetterBlackBoard

As in pensieve://Projects/BBS.

BetterBlackBoard[shot_] := Module[{diag, s1,s2},
diag=Norm[ImageDimensions[shot]];
s1=ColorConvert[shot, "Grayscale"];
s2=ImageAdjust[ ImageApply[Max[#1-#2,0]&, {s1, Blur[s1, 0.01diag]}] ] // ColorNegate;
ImageAdjust[s2, 0.3]
];

As

Enables the likes of Table[As[n,6], As[k,0,n], Binomial[n,k]], as in pensieve://2017-01/As.nb.

SetAttributes[As,HoldAll];
As /: (op:Do|Product|Sum|Table)[As[iter___], ℰ__] := op[ℰ, {iter}]

MakeImage

Options[MakeImage] = {ImageSize -> {2400}, ThumbnailSize -> {512}};
MakeImage[g_, opts___Rule] := Module[
{isize = ImageSize /. {opts} /. Options[MakeImage]},
ImageResize[
ImageCrop[Rasterize[g, RasterSize -> isize, ImageSize -> isize]],
isize]
];
MakeImage[name_String, g_, opts___Rule] := Module[{s,
isize = ImageSize /. {opts} /. Options[MakeImage],
tsize = ThumbnailSize /. {opts} /. Options[MakeImage]
},
Export[name<>".png",
s=ImageResize[
ImageCrop[Rasterize[$Image[name]=g, RasterSize -> isize, ImageSize -> isize]],
isize]
];
ImageResize[s, tsize]
];

RotateToMinimal

RotateToMinimal[l_]:=Module[
{bestl=l,rotatedl=RotateLeft[l]},
While[rotatedl=!=l,
bestl=First[Sort[{bestl,rotatedl}]];
rotatedl=RotateLeft[rotatedl]
];
bestl
];
RotateToMinimal[s_String] := StringJoin[RotateToMinimal[Characters[s]]];

New Esc-shortcut-Esc Shortcuts

Following http://mathematica.stackexchange.com/questions/6725/defining-symbol-shortcuts-in-the-front-end.

$NewInputAliases={"Zhe"->"Ж", "zhe"->"ж","<<"->"≺", "<<="->"⪯", ">>"->"≻", ">>="->"⪰"};

If[$FrontEnd =!= Null,
SetOptions[$FrontEnd,
InputAliases->$NewInputAliases
]
]

Epilog

End[]; EndPackage[];

Testing

<< KnotTheory`

$BaseDirectory

{
p=1;Do[As[k,1,5], p*=k]; p,
Product[As[k,1,7], k],
Sum[As[k,1,100], k],
Table[As[n,6], As[k,0,n], Binomial[n,k]]
}

RotateToMinimal/@ {"31415926", "271828"}

//BetterBlackBoard // Rasterize

Saving

NotebookSave[
EvaluationNotebook[],
FileNameJoin[{$BaseDirectory, "Kernel", "init.m"}]
];
NotebookSave[
EvaluationNotebook[],
"C:\\drorbn\\AcademicPensieve\\Projects\\Mathematica\\init.m"
]

Modifying Key Event Translations

trdir="SystemFiles\\FrontEnd\\TextResources";
CreateDirectory[FileNameJoin[{$UserBaseDirectory, trdir}]];
tr= FileNameJoin[{$UserBaseDirectory, trdir, "KeyEventTranslations.tr"}];
If[FileExistsQ[tr], DeleteFile[tr]];
CopyFile["C:\\drorbn\\AcademicPensieve\\Projects\\Mathematica\\KeyEventTranslations.tr", tr]