Skip to content

Instantly share code, notes, and snippets.

View youthlin's full-sized avatar

Youth.霖 youthlin

View GitHub Profile
@acheong08
acheong08 / htmj.js
Created November 5, 2023 17:21
HTMX but with JSON
class HTMJ {
constructor() {
this.init();
}
init() {
document.addEventListener("DOMContentLoaded", () => {
this.parseTemplates();
});
}
@lukassup
lukassup / synology-dsm7-fix.diff
Created January 28, 2022 18:38
Fix for Synology DSM v7 nginx config
diff --git a/usr/syno/share/nginx/DSM.mustache.orig b/usr/syno/share/nginx/DSM.mustache
index f4aa1cc..c648799 100644
--- a/usr/syno/share/nginx/DSM.mustache.orig
+++ b/usr/syno/share/nginx/DSM.mustache
@@ -1,9 +1,9 @@
{{#DSM}}
server {
- listen {{port}} default_server;
- listen [::]:{{port}} default_server;
+ listen {{port}};
@imhet
imhet / Mac OS 上关闭 SIP.md
Created November 4, 2019 15:59
Mac OS 上关闭 SIP

SIP 是 System Integrity Protection 的简写,译为系统完整性保护。 SIP 是 OS X El Capitan 时开始采用的一项安全技术,目的是为了限制 root 账户对系统的完全控制权,也叫 Rootless 保护机制。

Mac 系统中 SIP 状态默认是开启的。近期更新了系统版本导致该状态重新被打开,在终端运行一些命令时提示 "Operation not permitted" 。

查看 SIP 状态

终端输入 csrutil status 即可看到 SIP 的状态是 disable 还是 enable 。

关闭或开启 SIP

@liangzai-cool
liangzai-cool / gitee.com-2-github.com.sh
Last active May 18, 2021 11:59
gitee.com所有仓库同步到github私有仓库
source_code_dir="~/sourcecode/gitee.com/"
token="your_gitee_com_token"
gh_token="your_github_com_token"
current_dir=$(pwd)
response=$(curl -X GET "https://gitee.com/api/v5/user/repos?access_token=${token}&sort=created&page=1&per_page=20")
project_count=$(echo $response | jq '. | length')
echo $project_count
for(( i = 0; i < $project_count; i = i + 1 ))
do
operation="clone"
  1. Install the Proxy Server package. Just go to Package Manager in DSM and install Proxy Server.

  2. Edit squid.conf to tell it about your ad file. Ssh to the box, and edit the file /var/packages/ProxyServer/target/squid/etc/squid.conf (vi is installed by default)

You're going to add 2 lines to this file. First, under the auth_param section, you're going to add:

acl ads dstdom_regex -i "/var/packages/ProxyServer/target/squid/etc/squid.adservers"
@goodevilgenius
goodevilgenius / fortune_variety_quotes.py
Last active October 28, 2023 05:09
[Variety fortune plugin] Plugin for Variety background changer that uses the UNIX fortune program as a quotes source
#!/usr/bin/python
from variety.plugins.IQuoteSource import IQuoteSource
import subprocess, re
from locale import gettext as _
class FortuneSource(IQuoteSource):
@classmethod
def get_info(cls):
return {
@klange
klange / _.md
Last active May 23, 2024 13:45
It's a résumé, as a readable and compilable C source file. Since Hacker News got here, this has been updated to be most of my actual résumé. This isn't a serious document, just a concept to annoy people who talk about recruiting and the formats they accept résumés in. It's also relatively representative of my coding style.

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le
@wendal
wendal / test.java
Created August 28, 2012 05:13
获取Classpath中所有jar的路径
public static void main(String[] args) throws Throwable {
Enumeration<URL> urls = SimpleDaoTest.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
while (urls.hasMoreElements()) {
URL url = (URL) urls.nextElement();
System.out.println(url);
}
}
@yangbajing
yangbajing / gist:2601146
Created May 5, 2012 09:17
基于cookie的WEB自动登陆功能设计和账户安全性

基于cookie的WEB自动登陆功能设计和账户安全性

目标

设计一个基于cookie的安全的自动登陆功能。 简单说就是不在cookie中保存密码,且token值在每次使用后都会更新 ( 类似lift那样 )

计划