Skip to content

Instantly share code, notes, and snippets.

View jinyangustc's full-sized avatar

Jinyang Li jinyangustc

View GitHub Profile
@jinyangustc
jinyangustc / RPiWiFiFreeze.md
Created March 27, 2024 03:41 — forked from Paraphraser/RPiWiFiFreeze.md
Do your Raspberry Pi's Network Interfaces freeze? This may solve it.

Do your Raspberry Pi's Network Interfaces freeze?

My Raspberry Pi 4 kept losing its wlan0 interface. I could usually reconnect via Ethernet but, from time to time, I noticed that the eth0 interface would also go walkabout.

I tried a lot of things but the one described here seems to have cured the problem. I have no idea why it works. It just does.

Step 0 - are you a Windows user?

The script shown in the next step should be created on your Raspberry Pi. Please do not make the mistake of selecting the text, copying it into a text editor on your Windows machine, saving the file, and then moving the file to your Raspberry Pi. Unless you take precautions, Windows will add its 0x0d 0x0a (CR+LF) line endings and those will stop the script from working properly on your Raspberry Pi.

@jinyangustc
jinyangustc / Checking your Raspberry Pi's view of its power supply.md
Created March 26, 2024 19:00 — forked from Paraphraser/Checking your Raspberry Pi's view of its power supply.md
Checking your Raspberry Pi's view of its power supply (sometimes it's not the wall-wart)

Checking your Raspberry Pi's view of its power supply

Sometimes it seems like the first (and sometimes only) advice you get offered for almost any problem with a Raspberry Pi is "check your power supply". You think something like:

"hey, I'm using an official power supply sold as being matched with my Pi so how can there be any problem?"

You look up the specs then stick a controlled load across your supply and confirm that it can deliver the required number of Watts.

Yet your problems persist…

@jinyangustc
jinyangustc / htop.usage
Created December 23, 2023 22:20 — forked from makeittotop/htop.usage
htop explanation
System wide cpu usage:
The numbers on the top left from 1 to 8 represents the number of cpu's/cores in my system with the progress bar next to them representing the load of cpu/core. As you would have noticed the progress bars can be comprised of different colors. The following list will explain what each color means.
Blue: low priority processes (nice > 0)
Green: normal (user) processes
Red: kernel processes
Yellow: IRQ time
Magenta: Soft IRQ time
Grey: IO Wait time
@jinyangustc
jinyangustc / ssh
Created February 11, 2023 04:21 — forked from danydev/ssh
Update iTerm Badge with hostname of the server used to ssh
#!/bin/bash
# Script that updates the iTerm Badge with the hostname of the server that you are
# connecting to with ssh.
#
# Instructions:
# - Put this script in ~/bin/ssh (this will override the default ssh binary)
# - Run 'chmod +x ~/bin/ssh' to give execution permission to the script
# - Open iTerm\Preferences\Profiles, select your profile and put '\(user.current_ssh_host)' in the Badge text box
# - Enjoy!
set nocompatible
filetype indent on
syntax on
set hidden
set wildmenu
set showcmd
set incsearch
set nohlsearch
hi Search ctermbg=Grey
set backspace=indent,eol,start
@jinyangustc
jinyangustc / Acme.sublime-color-scheme
Created December 28, 2021 03:24 — forked from multiversecoder/Acme.sublime-color-scheme
A new Sublime Text color scheme inspired by Plan9 and Acme
{
"name": "Acme",
"author": "Adriano Romanazzo (multiversecoder)",
"globals":
{
"foreground": "#000",
"background": "#FFFEEC",
"border": "13px solid #000",
"accent": "#000",
"caret": "#000",
@jinyangustc
jinyangustc / python_cheatsheet.md
Last active December 5, 2019 21:11
Python cheatsheet

How to sort dict...

By value

Return as a list of tuples:

x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
sorted_x = sorted(x.items(), key=lambda kv: kv[1])
#=> [(0, 0), (2, 1), (1, 2), (4, 3), (3, 4)]
"""
`datetime` is included in the standard library.
time format:
%d: Day of the month as a zero-padded decimal number. 01, 02, ..., 31
%m: Month as a zero-padded decimal number. 01, 02, ..., 12
%Y: Year with century as a decimal number.
%H: Hour (24-hour clock) as a zero-padded decimal number. 00, 01, ..., 23
%M: Minute as a zero-padded decimal number. 00, 01, ..., 59
"""
@jinyangustc
jinyangustc / config2.json
Created July 22, 2019 23:20 — forked from pmav99/config2.json
Python logging configuration using JSON. If you want an updated example also covering YAML files, check here: https://github.com/pmav99/python-logging-example
{
"logging": {
"version": 1,
"disable_existing_loggers": true,
"formatters": {
"brief": {
"class": "logging.Formatter",
"datefmt": "%I:%M:%S",
"format": "%(levelname)-8s; %(name)-15s; %(message)s"
},
@jinyangustc
jinyangustc / script.pl
Created July 21, 2019 20:48 — forked from bessarabov/script.pl
Script to generate data shown in post 'At what time of day does famous programmers work? Part 2. Workweek vs Weekend.' — https://ivan.bessarabov.com/blog/famous-programmers-work-time-part-2-workweek-vs-weekend
#!/usr/bin/perl
# This script is made to show graphs with git commit time made on workweek vs weekend
#
# The desription of this script and results of its usage is avaliable at:
# https://ivan.bessarabov.com/blog/famous-programmers-work-time-part-2-workweek-vs-weekend
#
# usage:
#
# git log --author="Sebastian Riedel" --format="%H %ai" | perl script.pl