Skip to content

Instantly share code, notes, and snippets.

Leonid Shifrin lshifr

Block or report user

Report or block lshifr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lshifr
lshifr / FrozenCode.m
Created May 19, 2016
A non-standard evaluator for Mathematica code, allowing to evaluate the code in the "frozen" mode
View FrozenCode.m
BeginPackage["FrozenCode`"]
FrozenCodeEvaluate::usage = "FrozenCodeEvaluate[Hold[code], {heads}] evaluates the code
in the 'frozen' mode, where only specific heads are allowed to evaluate";
Begin["`Private`"]
ClearAll[symbolToHideQ]
SetAttributes[symbolToHideQ, HoldFirst];
symbolToHideQ[s_Symbol, expandedSymbs_] :=! MemberQ[expandedSymbs, Unevaluated[s]];
@lshifr
lshifr / SmartLet.m
Created Nov 7, 2014
Smart Let in Mathematica
View SmartLet.m
ClearAll[Let, let, symbolOrListQ, inSetDelayed];
SetAttributes[{Let, let, symbolOrListQ}, HoldAll];
symbolOrListQ[_Symbol] = True;
symbolOrListQ[{___?symbolOrListQ}] = True;
symbolOrListQ[_] = False;
Let::lvset = "Local variable specification `1` is not valid.";
@lshifr
lshifr / ReferenceTracker.m
Created Apr 29, 2016
A Mathematica package to track which symbols may reference a given symbol
View ReferenceTracker.m
BeginPackage["ReferenceTracker`"]
TrackReferences;
Begin["`Private`"]
Clear[$globalProperties];
$globalProperties = {
OwnValues,
DownValues,
@lshifr
lshifr / Defines.m
Last active Mar 18, 2016
Static code analyzer for Mathematica code
View Defines.m
ClearAll[shead];
SetAttributes[shead, HoldAllComplete];
shead[f_Symbol[___]] := HoldComplete[f];
shead[f_[___]] := shead[f];
shead[f_ /; AtomQ[Unevaluated[f]]] := Head[f];
(* TODO:This is a bit too simplisitc,since some pattern symbols might \
be localized by inner rules inside expr,and should not be \
counted.We might miss some extra dependencies this way *)
@lshifr
lshifr / HTMLParser.m
Last active Mar 9, 2016
A very simplistic breadth - first HTML parser in Wolfram Mathematica
View HTMLParser.m
BeginPackage["HTMLParser`"]
ParseHTML::usage = "ParseHTML[s] parses a string of HTML code";
HTMLContainer::usage = "HTMLContainer[tag] is an inert container for the contents of html tag";
Begin["`Private`"]
listSplit[x_List,lengthlist_List,headlist_List]:=
@lshifr
lshifr / SEFormatter.m
Last active Dec 18, 2015
Code formatter palette for mathematica.stackexchange.com
View SEFormatter.m
(* Mathematica Package *)
(* :Title: SEFormatter *)
(* :Author: Leonid B. Shifrin *)
(* :Summary: Code formatting palette for mathematica.stackexchange.com
(but can be useful also for other formatting purposes) *)
(* :Context: SEFormatter` *)
@lshifr
lshifr / lincomp.c
Last active Dec 14, 2015
LinearComplexity
View lincomp.c
# include <stdio.h>
# include <stdlib.h>
# include <time.h>
int random_in_range (unsigned int min, unsigned int max)
{
int range = max - min,
remainder = RAND_MAX % range,
bucket = RAND_MAX / range;
@lshifr
lshifr / EntireTableReader.m
Last active Dec 14, 2015
Java code for Mathematica to read entire file of floats
View EntireTableReader.m
JCompileLoad@"
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
import java.util.Arrays;
public class EntireTableReader{
public static float[] getFloatTable(String filename, int rowByteCount, int rowChunkSize)
@lshifr
lshifr / SimpleOO.m
Last active Dec 10, 2015
The most simple basic core of the OO extension to Mathematica.
View SimpleOO.m
(* Mathematica Package *)
BeginPackage["SimpleOO`"]
(* Exported symbols added here with SymbolName::usage *)
Object;
@lshifr
lshifr / RawVCS.m
Created Dec 19, 2012
Simple version control system for Mathematica projects hosted on Github via Github gists
View RawVCS.m
(* Mathematica Package *)
BeginPackage["RawVCS`", { "RuleTreeInfo`", "GithubGistClient`", "FileInfo`", "GithubGistProjectInfo`", "OO`", "OO`Methods`", "OO`Errors`"}]
(* Exported symbols added here with SymbolName::usage *)
RawVCS;
Begin["`Private`"] (* Begin Private Context *)
You can’t perform that action at this time.