This file contains 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
# Additional Fish completions for Jujutsu | |
# https://gist.github.com/bnjmnt4n/9f47082b8b6e6ed2b2a805a1516090c8 | |
# TODO: passthru other args? E.g.. --at-operation, --repository | |
function __jj | |
command jj --ignore-working-copy --color=never --quiet $argv 2> /dev/null | |
end | |
# Aliases | |
# Based on https://github.com/fish-shell/fish-shell/blob/cd71359c42f633d9d71a63591ae16d150407a2b2/share/completions/git.fish#L625. |
This file contains 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
#!/bin/sh -- | |
sysd=/etc/systemd/system | |
set -e | |
mkdir -p "$sysd/systemd-suspend.service.d" | |
cat > "$sysd/systemd-suspend.service.d/99-trigger-system-back-after-suspend.conf" <<'EOF' | |
[Service] |
This file contains 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
fn print_hist(histogram: &Histogram) { | |
fn print_percentile(percentile: f64, hist: &Histogram) { | |
let bucket = hist.percentile(percentile).unwrap(); | |
println!( | |
"Percentile {}% from {} to {} => {} count", | |
percentile, | |
bucket.low(), | |
bucket.high(), | |
bucket.count() |
This file contains 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
use anyhow::Result; | |
use everscale_jrpc_client::JrpcClientOptions; | |
use tracing::log; | |
#[tokio::main] | |
async fn main() -> Result<()> { | |
env_logger::builder() | |
.filter(Some("everscale_jrpc_client"), log::LevelFilter::Debug) | |
.init(); | |
let client = everscale_jrpc_client::JrpcClient::new( |
This file contains 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
#[cfg(test)] | |
mod test { | |
#[tokio::test] | |
async fn test() { | |
use sqlx::Executor; | |
let pool = sqlx::mysql::MySqlPoolOptions::new() | |
.connect(std::env!("DATABASE_URL")) | |
.await | |
.unwrap(); |
This file contains 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
isPrime :: Int -> Bool isPrime n = millerRabinTest n (factorizeN (n-1)) {- factorizeN finds a number s and odd number d such that n -1 = (2^s)d by succesively dividing n by two if it is even. -} factorizeN :: Int -> (Int, Int) factorizeN n = fN n 0 where fN n s | even n = fN (n `div` 2) (s + 1) | otherwise = (n,s) {- this is the main function. it takes w values from a set of witnesses and checks if n passes the test. If it doesn't, n is not prime, if it does for all w, it is probably prime. -} millerRabinTest :: Int -> (Int,Int) -> Bool millerRabinTest n (d,s) = and [test n (expmod w d n) s | w <- onesToCheck] {- this is the test that is used in the millerRabinTest function. it sees if w^d = 1 mod n or n-1 mod n, if not it multiplies by two and checks again for a total of s-1 times. If it is never true then the number is not prime -} test :: Int -> Int -> Int -> Bool test n w s | w `elem` [1,n-1] = True | otherwise = or [ (expmod w (2^k) n) `elem` [1,n-1]| k <- [1..s]] {- set of witnesses that should make the |
This file contains 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
def jacobi(a, n): | |
assert(n > a > 0 and n%2 == 1) | |
t = 1 | |
while a != 0: | |
while a % 2 == 0: | |
a /= 2 | |
r = n % 8 | |
if r == 3 or r == 5: | |
t = -t | |
a, n = n, a |
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
def isPrime(a): | |
return all(a % i for i in xrange(2, a)) | |
# http://stackoverflow.com/a/14793082/562769 | |
def factorize(n): | |
factors = [] |
This file contains 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
public class MinDistanceSolver { | |
public static void main(String[] args) { | |
double currentRowState, p = 2.555 * Math.pow(10, -3), q = 1 - p, pTransformation = Math.pow(10, -11); // Данные | |
int dMinimum = 1, n = 31, k = 1; //Данные | |
double pInhibition; // Данные | |
System.out.println("-------------------------------------------------------"); //декоратор | |
do { //расчет Д минимум | |
System.out.print(dMinimum + " "); | |
currentRowState = combinator(n, dMinimum) * Math.pow(p, dMinimum) * Math.pow(q, n - dMinimum) * (((dMinimum + 1) * q) / ((dMinimum + 1) - ((n + 1) * p))); | |
System.out.println(currentRowState); |