Skip to content

Instantly share code, notes, and snippets.

Avatar
🐈
Stray Episode

秋葉 Hanaasagi

🐈
Stray Episode
View GitHub Profile
View TLP-1.4-Test_Battery-Care_Lenovo.md

TLP 1.4 Test: Battery Care for Lenovo Laptops (non-ThinkPad series)

Read the overview document first.

Supported Features

Lenovo laptop series using the ideapad_laptop driver have a feature called 'battery conservation mode', basically a fixed stop charge threshold at 60%. The hardware behaviour is:

  1. Connected to the charger, charging stops when the charge level reaches the stop threshold
@Hanaasagi
Hanaasagi / init.sh
Created Dec 8, 2021
initramfs-linux.img
View init.sh
#!/usr/bin/ash
udevd_running=0
mount_handler=default_mount_handler
init=/sbin/init
rd_logmask=0
. /init_functions
mount_setup
View invisable.py
if "hello" == "hello":
print("correct")
else:
print("incorrect")
View 📊 Weekly development breakdown
YAML 0 secs █████████████████████ 100.0%
@Hanaasagi
Hanaasagi / is_big_endian.c
Created Jun 30, 2019
判断字节序,返回 true 为 Little-Endian 否则为 Big-Endian
View is_big_endian.c
int is_little_endian(void) {
union t
{
int a;
char b;
} c;
c.a = 1;
return c.b == 1;
}
// 如果为 big endian,存储为下(Hex表示,int 占 32 bit,char 占 8 bit)
@Hanaasagi
Hanaasagi / type-apply.py
Created Apr 8, 2019
一种通过 MonkeyType + Pytest 来自动注解的方法(准确率不高,仍需要人工修改)
View type-apply.py
```
python type-apply.py
```
import os
import subprocess
DIR = ""
for root, dirs, files in os.walk(DIR, topdown=False):
View git-clean-reflog.sh
#!/usr/bin/bash
git reflog expire --expire-unreachable=now --all
git gc --prune=now
View keybase.md

Keybase proof

I hereby claim:

  • I am Hanaasagi on github.
  • I am hanaasagi (https://keybase.io/hanaasagi) on keybase.
  • I have a public key whose fingerprint is BF53 8DF8 E365 57CC 516D 9A8B A524 26A3 B59F F8EC

To claim this, I am signing this object:

View sqrt.rs
fn my_sqrt(x: i32) -> i32 {
let mut n = x as f64;
let half = 0.5 * n;
let mut i = unsafe {
std::mem::transmute::<f64, i64>(n)
};
i = 0x5fe6ec85e7de30da - (i>>1);
n = unsafe{
std::mem::transmute::<i64, f64>(i)
};
@Hanaasagi
Hanaasagi / hijacking-write.rs
Created Dec 26, 2018
hijacking write call in Linux
View hijacking-write.rs
use libc;
use std::ffi::CString;
use std::mem::transmute;
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::os::raw::c_void;
#[no_mangle]
extern "C" fn strcmp(s1: *const c_char, s2: *const c_char) -> c_int {
println!("strcmp");