Skip to content

Instantly share code, notes, and snippets.

View Axect's full-sized avatar
😀
So nice day to programming

Tae-Geun Kim Axect

😀
So nice day to programming
View GitHub Profile
@Axect
Axect / install_galprop.sh
Created March 5, 2024 00:33
Modified Galprop install script (on Arch linux - boost, clhep required)
#!/usr/bin/env bash
# Below are 2 example settings to build for OSX (10.15) or Linux (CentOS 8). Uncomment/modify the variables appropriate for your system -- you need to set these system variables
# User-defined variables -- this example is for OSX using a macports installation for the various tools
#MY_CMAKE=/opt/local/bin/cmake
#MY_AUTOCONF=/opt/local/bin/autoconf
#MY_CC=/opt/local/bin/clang-mp-12
#MY_CXX=/opt/local/bin/clang++-mp-12
@Axect
Axect / bisection_test.rs
Created December 11, 2023 04:39
Bisection test with Peroxide
use peroxide::fuga::*;
fn main() {
let h = |x: AD| -> AD {
let y = if x.x() < 5.0 { -5.0 } else { 5.0 };
println!("y = {:>2}", y);
AD0(y)
};
let sol = bisection(h, (0.0, 10.0), 5, 0.0001);
match sol {
def sliding_window(data, seq_length, pred_length):
x = []
y = []
for i in range(len(data) - seq_length - pred_length):
_x = data[i:(i+seq_length)]
_y = data[i+seq_length:i+seq_length+pred_length]
x.append(_x)
y.append(_y)
function r(l::T, psi::T) where { T <: Number }
return sqrt(RSOLAR^2 - 2*RSOLAR*l*cos(psi) + l^2)
end
function lmax(psi::T) where { T <: Number }
return sqrt(RH^2 - RSOLAR^2*sin(psi)^2) + RSOLAR * cos(psi)
end
function rho_nfw(l::T, psi::T) where { T<: Number }
return 0.4 * (RSOLAR/r(l,psi)) * ((1+RSOLAR/RS) / (1+r(l,psi)/RS))^2
@Axect
Axect / lazy5.hs
Created February 17, 2018 20:15
lazy5
primeFactors'' n = factors n (takeWhile (\p -> p*p <= n) primes')
@Axect
Axect / lazy4.hs
Created February 17, 2018 20:13
lazy4
factors :: Integral a => a -> [a] -> [a]
factors 1 _ = []
factors m (p:ps) | m < p*p = [m]
| r==0 = p:factors q (p:ps)
| otherwise = factors m ps
where (q,r) = quotRem m p
@Axect
Axect / lazy3.hs
Created February 17, 2018 20:10
lazy3
primeFactors' n = filter (\p -> mod n p == 0) (takeWhile (\p -> p*p <= n) primes')
@Axect
Axect / lazy2.hs
Created February 17, 2018 20:06
Lazy 2
primes' = 2 : [x | x <- [3..], isPrime' x]
isPrime' x = all (\p -> x `rem` p > 0) (factorsToTry x)
where
factorsToTry x = takeWhile (\p -> p*p <= x) primes'
@Axect
Axect / lazy1.hs
Last active February 17, 2018 19:58
Lazy1
main = print $ head [1..]
@Axect
Axect / memoryError.py
Created February 17, 2018 19:51
Memory Errors 1
print [i for i in range(1,100000000001)][0]