Skip to content

Instantly share code, notes, and snippets.

# A model of computation
for(i in 1:3)
{
print("To calculate two times two, please enter: 2*2")
scan(what="char")
print("Sorry, that's incorrect.")
}
print("To calculate two times two, please enter: 2*2")
scan(what="char")
@binary10
binary10 / cocalc-nbconvert-to-latex.md
Last active November 29, 2022 19:01
How can I export PDFs with custom LaTeX templates using the export button in cocalc?

The problem

Cocalc exports notebooks to LaTeX using a default provided by nbconvert when File > PDF via LaTeX is clicked in the menu.

I wanted to be able to customize the default LaTeX settings (found at /ext/jupyter/nbconvert/templates/latex), however this contains read-only files on the system. So, I created a local config, but they do not automatically override the system settings. After interpreting the docs, I found how to override the system default.

The recipe

  1. First, copy the folder /ext/jupyter/nbconvert/templates/latex to /home/user/.local/share/jupyter/nbconvert/templates/latex.

So I say to you, walk with the wind, brothers and sisters, and let the spirit of peace and the power of everlasting love be your guide.

John Lewis RIP

@binary10
binary10 / gist:0a88880d21e6567877e40ec124580111
Last active August 19, 2021 04:45
Overfitting in Education
Overfitting happens in education; it's called specialization.
import numpy as np
A = np.eye(20)
A @ A # `@` is the matrix multiplication operator

Project Name

A one or two line description.

Features

Enables you to do...

Project Contents

Setup

Requirements

import base64
# Create a string and encode to bytes
s = 'Convert me to base64!'
sb = s.encode('utf-8')
# Take bytes and encode to base64 string
sb64 = base64.b64encode(sb).decode()
# Q29udmVydCBtZSB0byBiYXNlNjQh
# Initialize two signals with arbitrary length
n, m = 5, 7
convolution_length = n+m-1
u = np.random.randint(0, 255, n)
v = np.random.randint(0, 255, m)
# Convolve the two signals
cv = sp.signal.convolve(u, v)
def scramble2Decrypt(cipherText):
halfLength = len(cipherText) // 2
oddChars = cipherText[:halfLength]
evenChars = cipherText[halfLength:]
plainText = ""
for i in range(halfLength):
plainText = plainText + evenChars[i]
plainText = plainText + oddChars[i]
if len(oddChars) < len(evenChars):
plainText = plainText + evenChars[-1]
def elim(row, minus_row, scale, n=3):
m = np.eye(n)
m[row, minus_row] = -scale
return m