Skip to content

Instantly share code, notes, and snippets.

View bquast's full-sized avatar
🌴
On vacation, but I love this stuff, so still working 😄

Bastiaan Quast bquast

🌴
On vacation, but I love this stuff, so still working 😄
View GitHub Profile
@bquast
bquast / BGV-2.py
Created January 3, 2024 14:05
BGV in Python
import numpy as np
from numpy.polynomial import Polynomial
def polynomial_modulo(polynomial, mod):
"""
Perform polynomial modulo operation using divmod.
"""
q, r = divmod(polynomial, mod)
return r
// ==UserScript==
// @name Google Docs Side Panel Hide
// @namespace http://tampermonkey.net/
// @version 2024-04-21
// @description Hide the Google Docs Side Panel (Calendar, Keep, Maps, etc.) toggle button for a clean slate.
// @author Bastiaan Quast
// @match https://docs.google.com/document/d/*
// @icon none
// @grant GM_addStyle
// ==/UserScript==
gelu <- function(x) {
return(0.5 * x * (1 + tanh(sqrt(2 / pi) * (x + 0.044715 * x^3))))
}
softmax <- function(x) {
exp_x <- exp(x - apply(x, 1, max))
return(exp_x / rowSums(exp_x))
}
layer_norm <- function(x, g, b, eps = 1e-5) {
@bquast
bquast / poisson_integer_arima.py
Created June 21, 2024 16:54
ARIMA for count data Poisson process INAR from blog post
import math
import numpy as np
import statsmodels.api as sm
from statsmodels.base.model import GenericLikelihoodModel
from scipy.stats import poisson
from scipy.stats import binom
from patsy import dmatrices
import statsmodels.graphics.tsaplots as tsa
from matplotlib import pyplot as plt
## ----setup----
library(polynom)
library(HEtools)
## ----params----
d = 4
n = 2^d
p = (n/2)-1
t = p
q = 868
import numpy as np
from numpy.polynomial import Polynomial
def polynomial_modulo(polynomial, mod):
q, r = divmod(polynomial, mod)
return r
def mod_on_coefficients(polynomial, modulo):
coefs = polynomial.coef
mod_coefs = [c % modulo for c in coefs]
const { Readability } = require('@mozilla/readability');
const jsdom = require('jsdom');
const fs = require('fs');
const path = require('path');
const os = require('os');
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
// Helper to download an image and return the local filename
async function downloadImage(imgUrl, folder, idx) {
try {
import Foundation
import AVFoundation
import Vision
import CoreImage
class CameraCapture: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate {
var foundQR: String?
let qrQueue = DispatchQueue(label: "qrqueue")
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
import numpy as np
from numpy.polynomial import Polynomial
# Set the parameters
M = 8
N = M // 2
scale = 64
xi = np.exp(2 * np.pi * 1j / M)
def vandermonde(xi: np.complex128, M: int) -> np.array:
## ----setup----
library(polynom)
library(HomomorphicEncryption)
## ----seed-----
set.seed(123)
## ----params-----
M <- 8
N <- M / 2