Skip to content

Instantly share code, notes, and snippets.

@sguzman
sguzman / piechart-by-prop.wls
Created November 10, 2020 05:55
Pie chart of diff industries by specified prop
limit = 100;
s = "TotalRevenue";
prop[p_String] := prop[p] = EntityProperty["Company", p];
c[e_, p_String] := c[e, p] = CompanyData[e, p];
ind[e_] := ind[e] = c[e, "Industry"];
m[e_, p_String] := m[e, p] = Not@MissingQ@c[e, p];
es[n_Integer, p_String] :=
es[n, p] =
EntityList@EntityClass["Company", {prop[p] -> TakeLargest[n]}];
sel[n_Integer, p_String] := sel[n, p] = Select[es[n, p], m[#, p] &];
@sguzman
sguzman / rank-by-industry.wls
Last active November 8, 2020 23:14
Rank SP500 companies by industry and plot it
With[{
time = {{2020}},
ents = Table[
CompanyData[FinancialData[s, "Company"], "Industry"], {s,
Select[
EntityList[
EntityClass[
"Financial", {EntityProperty["Financial", "MarketCap"] ->
TakeLargest[100]}
]
@sguzman
sguzman / corr.wls
Last active August 30, 2020 19:31
A simple correlation of two securities
With[{
a = "SPXL",
b = "VIXY"
},
With[{
apath = FinancialData[a, "Close", All]["DatePath"],
bpath = FinancialData[b, "Close", All]["DatePath"]
},
With[{
adiff = Transpose[{
@sguzman
sguzman / ffmpeg-concat.sh
Created July 6, 2020 22:48
Concatenate ts files using ffmpeg
#!/bin/bash
cat segment1_0_av.ts segment2_0_av.ts segment3_0_av.ts > all.ts
ffmpeg -i all.ts -acodec copy -vcodec copy all.mp4
@sguzman
sguzman / collatz-complete-o-grammar.wls
Last active July 4, 2020 02:20
This completely accounts for all occurrences of odd integers appearing in all collatz sequences.
# First Draft
{{e, o, e, o, e} :> C[1], {e, o, e} :> C[2], {e, o, e, o, e, o} :> C[3]}
# More concise story
{{e,o} :> C[1]}
@sguzman
sguzman / redox-qemu.sh
Last active January 19, 2021 18:08
Run Redox OS in qemu
#!/bin/bash
# broken for now - just hangs
#qemu-system-x86_64 -serial mon:stdio -d cpu_reset -d guest_errors -smp 4 -m 1024 -s -machine q35 -device ich9-intel-hda -device hda-duplex -net nic,model=e1000 -net user -device nec-usb-xhci,id=xhci -device usb-tablet,bus=xhci.0 -cpu qemu64 -drive file=harddrive.bin,format=raw
@sguzman
sguzman / tacit.py
Last active June 30, 2020 00:55
An example of tacit programming in python. Pretty
def compose(*fns):
return functools.partial(functools.reduce, lambda v, fn: fn(v), fns)
example = compose(baz, bar, foo)
@sguzman
sguzman / single-axiom-systems.txt
Last active June 30, 2020 01:30
A simple list of axioms corresponding to single-axiomatic systems
# Wolfram Axiom
- {\!\(\*SubscriptBox[\(\[ForAll]\), \({\[FormalA], \[FormalB], \[FormalC]}\)]\(\((\((\[FormalB]\[CenterDot]\[FormalC])\)\[CenterDot]\[FormalA])\)\[CenterDot]\((\[FormalB]\[CenterDot]\((\((\[FormalB]\[CenterDot]\[FormalA])\)\[CenterDot]\[FormalB])\))\) == \[FormalA]\)\)}
# Subtract and branch if less than or equal to zero
- subleq a, b, c ; Mem[b] = Mem[b] - Mem[a] - if (Mem[b] ≤ 0) goto c
# Universal Iota combinator
- {\displaystyle \iota :=\lambda f.((fS)K)}
@sguzman
sguzman / de-morgan-proof.wls
Created June 29, 2020 15:07
Proof of De Morgan rules in boolean algebra using Mathematica
FindEquationalProof[
\!\(
\*SubscriptBox[\(\[ForAll]\), \({\[FormalA], \[FormalB]}\)]\(
\*OverscriptBox[\(\[FormalA]\[CircleTimes]\[FormalB]\), \(_\)] ==
\*OverscriptBox[\(\[FormalA]\), \(_\)]\[CirclePlus]
\*OverscriptBox[\(\[FormalB]\), \(_\)]\)\),
AxiomaticTheory["BooleanAxioms"]
]
@sguzman
sguzman / collatz-grammar-rules.wls
Last active June 21, 2020 08:40
List of dense rules for collatz grammar
{{\[Gamma], 93}, {\[Beta], 67}, {\[Alpha], 72}, {B, 29}, {A, 45}, {F,
28}, {\[Delta], 65}, {\[Zeta], 38}, {e, 13}, {o, 1}}
{
{e, o, e, o, e} :> \[Alpha],
{e, o, e} :> \[Beta],
{\[Alpha], o} :> \[Gamma],
{e, e} :> \[Delta],
{\[Beta], \[Beta]} :> \[Zeta],
{e, \[Gamma]} :> A,