Skip to content

Instantly share code, notes, and snippets.

@ZhangHanDong
ZhangHanDong / layernorm.rs
Created April 9, 2024 06:59 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::fs::File;
use std::io::prelude::*;
use std::mem;
fn layernorm_forward(output: &mut [f32], mean: &mut [f32], rstd: &mut [f32],
input: &[f32], weight: &[f32], bias: &[f32],
batch_size: usize, time_steps: usize, channels: usize) {
let epsilon = 1e-5;
for b in 0..batch_size {
for t in 0..time_steps {
@laixintao
laixintao / decent_request.py
Last active February 20, 2024 12:05
Send HTTP requests using python-requests with timeout, tcp reuse(session) and retry.
from requests.adapters import HTTPAdapter, Retry
from requests import Session
retries = Retry(
total=5, backoff_factor=1, status_forcelist=[502, 503, 504]
)
session = Session() # reuse tcp connection
session.mount("http://", HTTPAdapter(max_retries=retries))
session.mount("https://", HTTPAdapter(max_retries=retries))
@lewangdev
lewangdev / qiniu_sslcert.py
Last active July 6, 2023 11:26
qiniu_sslcert
#!/usr/bin/env python
## Dependencies:
#
# pip install qiniu
#
## Tips for Deploy certs to Qiniu:
#
# export DOMAIN=lewangdev.com
# export QINIU_DOMAIN=images.${DOMAIN},staticfiles.${DOMAIN}
@Victrid
Victrid / gitgraft.sh
Created August 29, 2022 17:09
Find which commit your no-git friend is working on and generate patches for attaching their works onto git tree.
#!/bin/bash
hash git 2>/dev/null || { echo >&2 "Required command 'git' is not installed. ( hmm... why are you using this? ) Aborting."; exit 1; }
hash realpath 2>/dev/null || { echo >&2 "Required command 'realpath' is not installed. Aborting."; exit 1; }
hash pwd 2>/dev/null || { echo >&2 "Required command 'pwd' is not installed. Aborting."; exit 1; }
hash cd 2>/dev/null || { echo >&2 "Required command 'cd' is not installed. Aborting."; exit 1; }
hash echo 2>/dev/null || { echo >&2 "Required command 'echo' is not installed. Aborting."; exit 1; }
hash mv 2>/dev/null || { echo >&2 "Required command 'mv' is not installed. Aborting."; exit 1; }
hash diff 2>/dev/null || { echo >&2 "Required command 'diff' is not installed. Aborting."; exit 1; }
hash diffstat 2>/dev/null || { echo >&2 "Required command 'diffstat' is not installed. Aborting."; exit 1; }
@chenshaoju
chenshaoju / sunlogin.sh
Created March 16, 2022 08:23
auto enable/start sunlogin services and running, disable/stop services when exit sunlogin.
#!/usr/bin/sudo bash
#
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
systemctl enable runsunloginclient.service
systemctl start runsunloginclient.service
# change USERNAME to your current non-root username
sudo -u USERNAME /usr/local/sunlogin/bin/sunloginclient &
@Tristor
Tristor / 06-kids.conf
Created December 15, 2020 23:49
Force Pi-Hole SafeSearch
# This DNSMasq configuration forces restrictions to be enabled for YouTube, Bing, and Google Search
# for more information see: https://learn.akamai.com/en-us/webhelp/enterprise-threat-protector/enterprise-threat-protector/GUID-0FCB1221-60DC-4A01-9B09-0C25B16BF3D0.html
# or see: https://support.google.com/youtube/answer/6214622?hl=en
# Put this file in /etc/dnsmasq.d/
## YouTube
cname=www.youtube.com,restrictmoderate.youtube.com
cname=m.youtube.com,restrictmoderate.youtube.com
cname=youtube.googleapis.com,restrictmoderate.youtube.com
cname=youtubei.googleapis.com,restrictmoderate.youtube.com
@jn7163
jn7163 / 计算机基础轻松学——1 轻松学习汇编语言.md 这个系列分享一些不需要多少基础,能一边吃泡面一边随意翻翻就学会的书籍、教程和笔记,涉及汇编、C语言操作系统编译原理等。

轻松学习汇编语言

汇编是直接跟硬件打交道的, 于是在学习汇编的同时,不经意间就了解到计算机的工作原理。

《穿越计算机的迷雾 by 李忠》

这是饭前开胃菜,作者从什么是电流开始,讲加法器、数字逻辑、触发器、CPU 原理、外设等,是计算机(硬件)组成原理的科普向轻松读物

《汇编语言 by 王爽》

@hemashushu
hemashushu / 计算机基础轻松学——1 轻松学习汇编语言.md
Created July 8, 2020 03:57
这个系列分享一些不需要多少基础,能一边吃泡面一边随意翻翻就学会的书籍、教程和笔记,涉及汇编、C语言操作系统编译原理等。

轻松学习汇编语言

汇编是直接跟硬件打交道的, 于是在学习汇编的同时,不经意间就了解到计算机的工作原理。

《穿越计算机的迷雾 by 李忠》

这是饭前开胃菜,作者从什么是电流开始,讲加法器、数字逻辑、触发器、CPU 原理、外设等,是计算机(硬件)组成原理的科普向轻松读物

《汇编语言 by 王爽》

@maxme
maxme / raspberry-power-supply-check.sh
Last active August 5, 2023 06:45
Check your Raspberry pi power supply and USB cable
#!/bin/bash
# Before running this script, make sure you have sysbench installed:
# sudo apt-get install sysbench
#
# This script helps you check if your Raspberry pi is correctly powered.
# You can read more about Raspberry pi powering issues here: https://ownyourbits.com/2019/02/02/whats-wrong-with-the-raspberry-pi/
# If you're pi is correctly powered (stable power supply and quality cable), after running the script, you should get something like:
@extremecoders-re
extremecoders-re / openwrt-qemu.md
Last active March 22, 2024 13:20
Running OpenWRT ARM under QEMU

Environment

The steps shown below are done on a Ubuntu VM using Qemu 3.0

$ qemu-system-arm -version
QEMU emulator version 3.0.0
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

To quit Qemu at any time press Ctrl+a x, i.e. Ctrl+a and then x