Skip to content

Instantly share code, notes, and snippets.

View peterwillcn's full-sized avatar
📡
011010001000100010101010101

open source peterwillcn

📡
011010001000100010101010101
View GitHub Profile
@peterwillcn
peterwillcn / ubxconfig.sh
Created June 17, 2024 12:41 — forked from hdoverobinson/ubxconfig.sh
Configure u-blox GPS/GNSS modules with Bash
#!/bin/bash
###AUTHOR###
#Harry Dove-Robinson 5/8/2017
#[email protected]
#https://gist.github.com/hdoverobinson
#https://github.com/hdoverobinson
###USAGE###
#This is a script used to configure u-blox GPS/GNSS modules from a text file generated by u-center.
@peterwillcn
peterwillcn / layernorm.rs
Created April 17, 2024 04:07 — forked from ZhangHanDong/layernorm.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 {
@peterwillcn
peterwillcn / Public_Recursive_Name_Servers.md
Created January 14, 2022 14:19 — forked from mutin-sa/Top_Public_Recursive_Name_Servers.md
List of Top Public Recursive Name Servers
IPv4 Addr IPv6 Addr ASn Loc Svc Org
8.8.8.8 2001:4860:4860::8888 AS15169 Worldwide (Anycast) Google Public DNS Google
8.8.4.4 2001:4860:4860::8844 AS15169 Worldwide (Anycast) Google Public DNS Google
77.88.8.8 2a02:6b8::feed:0ff AS13238 Worldwide (Anycast) Yandex.DNS Yandex
77.88.8.1 2a02:6b8:0:1::feed:0ff AS13238 Worldwide (Anycast) Yandex.DNS Yandex
1.1.1.1 2606:4700:4700::1111 AS13335 Worldwide (Anycast) Cloudflare-DNS Cloudflare/APNIC
1.0.0.1 2606:4700:4700::1001 AS13335 Worldwide (Anycast) Cloudflare-DNS Clou
@peterwillcn
peterwillcn / how-to-upgrade-nvmw-ssd-firmware-on-linux.md
Created April 27, 2021 13:25 — forked from klingtnet/how-to-upgrade-nvmw-ssd-firmware-on-linux.md
How to upgrade [Lenovo] NVMe SSD firmware on Linux

The instructions were tested on a Lenovo X1 Carbon 5th Gen (X1C5) on Arch Linux but should be applicable to other Lenovo models and Linux distributions.

BACKUP YOUR DATA! I created a bootable Ubuntu Image like this:

$ sudo sh -c 'curl --location --silent --fail "http://releases.ubuntu.com/18.04/ubuntu-18.04.1-desktop-amd64.iso" | pv > /dev/<your-usb-drive>'
# note that pv is only there to show progress, it is perfectly fine to redirect curl to the usb drive directly.

then I booted from this drive by pressing F12 on reboot and dumped my NVMe disk to an external hard drive like this:

@peterwillcn
peterwillcn / readme.md
Created February 8, 2021 08:47 — forked from jasonkarns/readme.md
Git send-email using Gmail
  1. Configure git.
# ~/.config/git/config
[sendemail]
  confirm = auto
  smtpServer = smtp.gmail.com
  smtpServerPort = 587
  smtpEncryption = tls
  smtpUser = <gmail email address>
@peterwillcn
peterwillcn / server.ex
Created August 11, 2020 16:37 — forked from adnils/server.ex
Elixir TCP echo server
defmodule Echo.Server do
def start(port) do
tcp_options = [:binary, {:packet, 0}, {:active, false}]
{:ok, socket} = :gen_tcp.listen(port, tcp_options)
listen(socket)
end
defp listen(socket) do
{:ok, conn} = :gen_tcp.accept(socket)
spawn(fn -> recv(conn) end)
@peterwillcn
peterwillcn / change.rb
Created April 26, 2020 14:23
Example of dynamic programming in Ruby
INFINITY = 1.0/0
@changes = {}
@coins = [1, 3, 4]
def change(target_value)
return 0 if target_value == 0
return INFINITY if target_value < 0
@changes[target_value] ||= @coins.map do |coin|
change(target_value - coin) + 1

MySQL Download URL

https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz

Open the terminal and follow along:

  • Uninstall any existing version of MySQL
sudo rm /var/lib/mysql/ -R
#!/bin/bash
: << '#__REM__'
指定さたライブラリをiOS用にフルオートで作成します。ダウンロード、複数のアーキテクチャのビルドも自動的に行います。デフォルトではi386、x86_64、armv7、armv7s、arm64のアーキテクチャを作成します。
Create a full-auto to iOS for the library specified. I do also builds the architecture download, more than one. Create architecture i386, x86_64, armv7, armv7s, arm64 by default.
#__REM__
TARGET_VERSION="1.3.1"
@peterwillcn
peterwillcn / htpasswd.py
Created June 12, 2019 09:56 — forked from eculver/htpasswd.py
htpasswd script in python (no need to install apache utils)
#!/usr/local/bin/python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find