Skip to content

Instantly share code, notes, and snippets.

View install_hide_firefox_titlebar.sh
#!/bin/bash
# date: 2017-11-17
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
echo 'install: ~/.mozilla/native-messaging-hosts/hide_titlebar.json'
[[ -d ~/.mozilla/native-messaging-hosts ]] || mkdir -p ~/.mozilla/native-messaging-hosts
cat > ~/.mozilla/native-messaging-hosts/hide_titlebar.json << EOF
{
"name": "hide_titlebar",
@nanpuyue
nanpuyue / openwrt-hc5611.patch
Created January 26, 2018 15:38
Add support for HiWiFi HC5611 for OpenWrt
View openwrt-hc5611.patch
diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds b/target/linux/ramips/base-files/etc/board.d/01_leds
index 37630cde66..f90ed13d12 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -205,6 +205,9 @@ hc5661a)
ucidef_set_led_netdev "internet" "internet" "$boardname:blue:internet" "eth0.2"
set_wifi_led "$boardname:blue:wlan2g"
;;
+hc5611)
+ ucidef_set_led_default "system" "system" "$boardname:green:system" "1"
View docker-htop.sh
#!/bin/bash
docker() {
case "$1" in
htop)
local container="$2"
if [ -z "$container" ]; then
echo -e '"docker htop" requires at least 1 argument.\n'
echo -e 'Usage:\n\tdocker htop CONTAINER [htop OPTIONS]'
return 1
View push_array.rs
// date: 2022-05-09
// license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
use std::mem::take;
fn push(buf: &mut &mut [u8], value: u8) {
buf[0] = value;
*buf = &mut take(buf)[1..];
}
@nanpuyue
nanpuyue / .gitignore
Last active April 30, 2022 13:35
executable-cdylib
View .gitignore
/target
Cargo.lock
View deserialize-colon-separated.rs
// date: 2022-04-24
// license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
use std::fmt::{self, Debug, Display, Formatter};
use std::iter::Peekable;
use std::str::Lines;
use std::{error, result};
use serde::de::{self, Visitor};
View gist:2798c214a97b0c017074e26ca24e59ad
use std::marker::PhantomData;
#[derive(Debug)]
struct S<'a> {
_pd: PhantomData<&'a mut &'a ()>
}
impl<'a> Drop for S<'a> { fn drop(&mut self) {} }
impl<'a> S<'a> {
View gist:df0b0c0386b8934d30af1b3d5b03b4a0
struct S<'a> {
a: &'a (),
}
impl<'a> S<'a> {
fn feed(&self, data: &'a [u8]) {
drop(data);
}
fn get_a(&self) -> &() {
View biliintl.js
let url = $request.url;
let body = $request.body;
url = url.replace(/&sim_code=[0-9]+/g,'');
body = body.replace(/&sim_code=[0-9]+/g,'');
$done({url, body});
@nanpuyue
nanpuyue / live_initrd_on_exfat.sh
Last active June 14, 2021 00:44
Generate the initrd for Debian/Deepin/Ubuntu Live that supported boot from iso on an exfat partition, then you can generate the new iso by “ISO Master”. Tested for Deepin 15.3, Debian 8.5 & Ubuntu 16.04.1.
View live_initrd_on_exfat.sh
#!/bin/bash
# (c) 2016 nanpuyue <nanpuyue@gmail.com>
# usage:sudo ./live_initrd_on_exfat.sh deepin-15.3-amd64.iso
NAMESERVER="1.2.4.8"
EXFAT_BIN="sbin/mount.exfat"
FILE_LIST="sbin/mount.exfat sbin/mount.exfat-fuse lib/x86_64-linux-gnu/libfuse.so.*"
ISO=$(readlink -f "$1")