Skip to content

Instantly share code, notes, and snippets.

View SourLemonJuice's full-sized avatar

酸柠檬猹 SourLemonJuice

View GitHub Profile
@SourLemonJuice
SourLemonJuice / undefined-jock.c
Last active June 9, 2024 19:17
What is the result of (++i)+(++i)? Is Undifined.
// side note: https://www.bilibili.com/video/BV1ZL411n7Yd
// in clang you will get:
// warning: multiple unsequenced modifications to 'i'
#include <stdio.h>
int main(void)
{
int i,b;
i = 1;
b = (++i)+(++i);
@SourLemonJuice
SourLemonJuice / .clang-format
Last active October 31, 2024 08:34
A clang-format config file(.clang-format) for SourLemonJuice(myself).
---
BasedOnStyle: Microsoft
IndentWidth: 4
UseTab: Never
LineEnding: DeriveLF
MaxEmptyLinesToKeep: 1
BreakBeforeBraces: Linux
AllowShortBlocksOnASingleLine: Never
AllowShortIfStatementsOnASingleLine: Never
IndentCaseLabels: false
@SourLemonJuice
SourLemonJuice / blink.cpp
Created June 16, 2024 17:49
Some simple Arduino LED blink cpp code.
@SourLemonJuice
SourLemonJuice / clash_permission.sh
Created July 10, 2024 00:34
快速为普通用户配置 clash 运行 tun 模式的执行权限。详情在注释链接的 issue 里,这个活本身是 GUI 软件干的,但不也是有点用对吧。
# https://github.com/zzzgydi/clash-verge/issues/182
# as root
setcap cap_net_bind_service,cap_net_admin=+ep /usr/bin/clash
@SourLemonJuice
SourLemonJuice / main.c
Last active August 19, 2024 19:07
It's an example, of using a UDP socket to receive server messages on port 1907. Example server command: "netcat -l -u -p 1907 localhost"
#include <error.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
@SourLemonJuice
SourLemonJuice / strnstr.c
Created September 22, 2024 06:06
A strnstr() function in C. I was going to use this: https://stackoverflow.com/a/25705264/25416550, but its "n" start with "needle". So I implemented my own version
// This is free and unencumbered software released into the public domain.
/*
Search "needle" in "haystack", limited to the first "len" chars of haystack
*/
char *strnstr(char haystack[const restrict static 1], char needle[const restrict static 1], int len)
{
if (len <= 0)
return NULL;
@SourLemonJuice
SourLemonJuice / .prettierrc.yaml
Last active May 10, 2025 17:45
SourLemonJuice's .prettierrc file, a JavaScript formatter
useTabs: false
tabWidth: 2
trailingComma: all
printWidth: 120
singleQuote: true
semi: false
@SourLemonJuice
SourLemonJuice / hello.asm
Last active December 3, 2024 11:15
x86_64 Linux assmbely(nasm) example for printing Hello World.
; Thanks for:
; https://p403n1x87.github.io/getting-started-with-x86-64-assembly-on-linux.html
global _start
SYS_WRITE equ 1
SYS_EXIT equ 60
STDOUT equ 1
SECTION .data
@SourLemonJuice
SourLemonJuice / chrony.conf
Last active August 16, 2025 20:46
Some example configs of Chrony NTP client. Those config files come from ArchWiki and Fedora default configurations.
# /etc/chrony.conf
# cloudflare time server with NTS
server time.cloudflare.com iburst nts
driftfile /var/lib/chrony/drift
rtcfile /var/lib/chrony/rtc
# storage UTC time to RTC
rtconutc
@SourLemonJuice
SourLemonJuice / activate-linux.service
Last active October 26, 2025 03:37
An example systemd user unit for activate-linux, make this watermark autostart. It's really funny, haha.
# put it in: /etc/systemd/user/
# and reload units(run as user self): systemctl --user daemon-reload
# use for: https://github.com/MrGlockenspiel/activate-linux
#
# that reminds me of this: https://github.com/USSURATONCACHI/activate-linux-toggle
# well, I don't like that "toggle", you can use `systemctl --user <operation> <unit-name>` to control any user unit.
[Unit]
Description=Activate Windows Watermark on Linux
After=graphical-session.target