This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## ----setup---- | |
| library(polynom) | |
| library(HEtools) | |
| ## ----params---- | |
| d = 4 | |
| n = 2^d | |
| p = (n/2)-1 | |
| t = p | |
| q = 868 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## ----setup---- | |
| library(polynom) | |
| library(HomomorphicEncryption) | |
| ## ----seed----- | |
| set.seed(123) | |
| ## ----params----- | |
| M <- 8 | |
| N <- M / 2 |