Skip to content

Instantly share code, notes, and snippets.

View ShabbirHasan1's full-sized avatar
:octocat:
Building Things

Shabbir Hasan ShabbirHasan1

:octocat:
Building Things
  • India
View GitHub Profile
@ShabbirHasan1
ShabbirHasan1 / README.md
Created August 5, 2024 15:49 — forked from adtac/README.md
Using your Kindle as an e-ink monitor

using your Kindle as an e-ink monitor

demo: https://x.com/adtac_/status/1820127470613622950 (3.5 fps, Paperwhite 3)

step 1: jailbreak your Kindle

mobileread.com is your best resource here, follow the instructions from the LanguageBreak thread

I didn't really follow the LanguageBreak instructions because I didn't care about most of the features + I was curious to do it myself, but the LanguageBreak github repo was invaluable for debugging

Rust Optimization Tips (or, Why Rust Is Faster Than Python)

If you're looking to write fast code in Rust, good news! Rust makes it really easy to write really fast code. The focus on zero-cost abstractions, the lack of implicit boxing and the lifetime system that means memory is managed statically means that even naïve code is often faster than the equivalent in most other languages out there, and certainly faster than naïve code in any equivalently-safe language. Maybe, though, like most programmers you've spent your whole programming career safely insulated from having to think about any of this, and now you want to dig a little deeper and find out the real reason that

import numpy as np
import pandas as pd
from scipy.stats import norm
from scipy.optimize import brentq
import time
def black_scholes_merton(S, K, T, r, sigma, option_type):
d1 = (np.log(S / K) + (r + 0.5 * sigma**2) * T) / (sigma * np.sqrt(T))
d2 = d1 - sigma * np.sqrt(T)
@ShabbirHasan1
ShabbirHasan1 / BSM_WithAdjoints.py
Created July 27, 2024 14:53 — forked from jace48/OptionPremium_WithGreeks.py
Black Scholes Merton with Greeks (Adjoints) with respect to Inputs
import math
from scipy.stats import norm
def BSM_withAdjoints(S0, r, y, sig, K, T):
#Evaluation
sqrtT = math.sqrt(T)
df = math.exp(-r * T)
@ShabbirHasan1
ShabbirHasan1 / global_arena.rs
Created July 18, 2024 14:33 — forked from AndrewGaspar/global_arena.rs
Global Arena Rust
use std::cell::RefCell;
// `generational_arena` is a special type of arena that allows elements to be recycled, and the
// handles allocated from the arena do not hold a borrow on the arena. The handles are later used to
// retrieve concrete borrows on the arena temporarily. The check for live-ness is essentially
// performed at runtime, rather than being checked by the borrow checker.
use generational_arena::{Arena, Index};
// Allocate `ARENA` at global/thread scope. The arena is wrapped in a RefCell so we can get
// runtime-checked mutable borrows of the arena.

NOTE: This was first authored on 26 Feb 2014. Things may have changed since then.

C++'s Templates

C++'s templates could be seen as forming a duck typed, purely functional code generation program that is run at compile time. Types are not checked at the initial invocation stage, rather the template continues to expand until it is either successful, or runs into an operation that is not supported by that specific type – in that case the compiler spits out a 'stack trace' of the state of the template expansion.

To see this in action, lets look at a very simple example:

template 
@ShabbirHasan1
ShabbirHasan1 / silence.sh
Created July 17, 2024 10:22 — forked from v0lkan/silence.sh
How to Have a Silent and High-Performing Western Digital MyCloud Mirror
#
# Needless to say, I (Volkan Ozcelik) take no responsibility, whatsoever,
# about what will happen to your NAS when you try these.
# When did it to mine, I observed *ENORMOUS* performance gain and a zen-like silence.
#
# +----------------------------------------------------------+
# | WHAT YOU ARE GOING TO DO CAN LIKELY VOID YOUR WARRANTY |
# | SO PROCEED WITH CAUTION |
# +----------------------------------------------------------+
#
@ShabbirHasan1
ShabbirHasan1 / playground.rs
Created July 8, 2024 22:06 — forked from rust-play/playground.rs
Code shared from the Rust Playground
fn check_safe_transmute<T: Copy>(buf: &[u8]) {
if buf.len() < ::std::mem::size_of::<T>() {
panic!("Slice has insufficient capacity!");
}
let p = buf.as_ptr() as usize;
let align_of = ::std::mem::align_of::<T>();
if align_of > 0 && (p & (align_of - 1)) != 0 {
panic!("Slice has bad alignment!");
}
}
@ShabbirHasan1
ShabbirHasan1 / fix_coverage.rs
Created July 5, 2024 14:20 — forked from lewsmith/fix_coverage.rs
Rust `await` coverage temporary fix
/// This is a temporary fix for a bug in coverage reports where awaits show as not covered.
///
/// The idea is that once the bug is fixed, you can easily remove all `.fix_cov()` calls and imports,
/// delete the `fix_coverage.rs` and eveything works as it previouslt did.
///
/// To use it just simply import the `FixCoverage` trait and add `.fix_cov` to any future, before the `.await`.
///
/// # Example
/// ```
/// use FixCov;